r/LoopHero • u/RLutz • Mar 13 '21
Solving for the optimal river thicket placement
I was inspired by /u/code_chris post to try and find the actual optimal river/thicket placement for a 5x12 area, so I wrote a brute force solver in order to try and solve the problem.
It's currently still running and has been crunching away at the problem using 21 threads on my 3950x for 7 hours. The highest attack speed it has found so far is 222--here's the layout: https://loopherolayout.xyz?c=211121121112121121211212112112112112112122121211212121121112
I sort of have a feeling that this is the optimal solution, but I will update this post once the solver finishes running if it finds a better solution. For any software engineers, feel free to make suggestions on how to make the solver better! I did attempt to memoize it, but that resulted in creating a 30 GB ConcurrentHashMap and I think it was slower than just always calculating the score for every generated solution.
Here's a picture of the solution in case /u/code_chris app goes down: https://i.imgur.com/qbc6YSy.png
Edit: So far 222 is still in the lead and I have identified 4 unique 222 solutions, though the first one still uses the least thickets. Here are the other three:
https://loopherolayout.xyz?c=111221211211211211212211221212212112112122121211212121121112
https://loopherolayout.xyz?c=211122121121121221122121221211211212212121121112111211211122
https://loopherolayout.xyz?c=111221211211211211211211212212121121212212112112112112122111
Edit2: We have a 224!
https://loopherolayout.xyz?c=111221211211211211212211211212212112112122121211212121121112
I'm just going to hold off on updating until this thing finishes running from here on out.
Edit3: I realized I forgot that rivers necessarily have to start on the edge of a map, which means I don't need to test 21 different starting positions, only 8. I believe exhaustively searching from these 8 starting positions is all that is needed: https://loopherolayout.xyz?c=111001000010000100001000010000000000000000000000000000000000 as everything else should be a mirror. I've made some code changes and I'm rerunning the search now.
Edit4: The search for the optimal 5x12 is still running, and so far 234 is the highest score found: https://loopherolayout.xyz/?c=111221211211211211211211211211211212212121121112111211211122
For a 4x12, the optimal score is 176: https://loopherolayout.xyz/?c=211101121012110211201121012110121201111021210112101211011120
FinalEdit: The optimal solution is in fact 234. /u/cubeconquerer wrote a really cool MaxSat solver which runs in a fraction of the time as my brute force solver (turns out NP-hard problems are hard!)
You can find his code here: https://github.com/vwinkler/ThicketSolver
4
u/SL4M_DunkN Mar 13 '21
I thought the thicket values were 2/4/8/16/32 for 0/1/2/3/4 adjacent rivers? Do they go to 12 instead?
5
u/code_chris Mar 13 '21
Really interesting, the only thing I noticed is that they don't end at the top or bottom, which is something I've been doing to ensure it can go to the other side of the map without using bridges. But perhaps there is often enough room to carry on anyway.
1
u/dame_tu_cosita Mar 13 '21
Could you give e the mirror image too? And about that, are the script you doing doing the mirrors or skipping them?
1
u/[deleted] Mar 14 '21
Do you think you could edit this to solve for 4x12 areas? Not every map is generous enough to provide 5 tiles of horizontal space on each side, would be interesting to see how much attack speed is possible with that area.
1
u/[deleted] Mar 15 '21
I know several people have asked for a 4x12 layout, and your response was to just restart until you have a 5x12, but I wouldn't want to do this, personally. I like using what I am given, being that its random, and I dont wanna game the system by just restarting until I like the map. So, I too would like a 4x12, if you'd be so kind
1
u/sineme Mar 17 '21 edited Mar 17 '21
If you mirror the 4x12 solution along the y-axis, it aligns nicely with the current 5x12 solution and the second solution looks like the 5x12 but scaled down. This could help people remember/memorize the patterns if they don't restart for the 5x12.
Also the card weights are River: 14, Forest: 12 and Thicket: 10, so you probably want a 14:10 ratio which actually makes the "scaled down" 4x12 perfect with a ratio of 28:20 or 14:10, the other one has a ratio of 34:14 or 18:7. (you can check the weights in the variables.ini)
Finally, I hope you'll be posting every solution somewhere, so we can look through them. Thanks for your hard work! (don't mind me comming up with naming conventions)
4x12-176-34:14 (mirrored): https://loopherolayout.xyz/?c=111201211011210211201211011210212101111012120121101121021110
the following are the same as in OP's post above, I just put them here, so there's no need to scroll back up.
4x12-176-28:20 (scaled down 5x12-234, perfect 4x12?): https://loopherolayout.xyz/?c=222201112012110112102112012110112102121011210121101112022220
5x12-234-38:22 (as a reference):https://loopherolayout.xyz/?c=111221211211211211211211211211211212212121121112111211211122
Edit: the perfect ratio for the 5x12 would be 35:25
1
u/Xineph Mar 25 '21
Can anybody speak to optimal river placement *specifically when starting from the top right or top left* of a 5x12 grid? Many of these assume a mid-map start point, and I'm having trouble figuring out ideal placement after my river makes it over the top to the other side of the map.
2
u/taggedjc Mar 13 '21
I wonder if /u/code_chris can also include desert tiles which could change adjacent river tiles to oasis tiles.
0
u/vitross Mar 13 '21
That is literally not a valid solution, that river has no starting point, both ends of the river is in the middle of the map.
1
u/crookster Mar 13 '21 edited Mar 14 '21
Edit: nvm
1
u/DetourDunnDee Mar 15 '21
Do we have a version of this with 2-5 Storm towers for making a burned setup (better for warrior once Priestess down), ideally with 1 on each end? 212% is the best I could come up with for that: https://loopherolayout.xyz?c=000021112212112112112112112112112112112121121112111211211120
1
u/LamestHoax Mar 19 '21
By placing rivers as reeds, we can get up to 238% on the 5x12 and 184% on the 4x12. While this is definitely difficult to automate a search using this path, it's a good way to snag a few % and get a few more kills every loop. Effectively, this turns enemy spawn tiles into buff tiles for you with a very low addition to the boss meter. There are 3 identical solutions for the 5x12 and 2 for the 4x12. Reed placement is in the 6th or 5th column which I cant mark properly on the tool so I've included a photoshopped image. A 6th "reed only" row would be a great way to implement this for easier testing.
5x12:
https://loopherolayout.xyz/?c=111221211211211211211211211211211222212121121112111211211122
https://loopherolayout.xyz/?c=111221211211211211211211211211211212212221121112111211211122
https://loopherolayout.xyz/?c=111221211211211211211211211211211212212121122112111211211122
4x12:
https://loopherolayout.xyz/?c=211101122012110211201121012110121201111021220112101211011120
https://loopherolayout.xyz/?c=211101122012110211201121012110121201111021210112201211011120
Gallery:
https://imgur.com/a/HlqvEIu
1
u/[deleted] Mar 23 '21
Isn't it an NP problem, i.e. it could take billions of years to go through all possible combinations, depending on the size?
1
u/billyswaggins Mar 29 '21 edited Mar 29 '21
Hey I just want to say this is a really cool guide. I want to ask how would this optimal build change if we were to add desert to create oasis and maximize the atk speed reduction? I think incorporating the desert into this would be too much to ask so I am thinking we can make 1 side of the map thickets/river only and 1 side with oasis/desert only to simplify this build. But the problem is this optimal build requires us to end the river and can’t run it towards the other side. So I guess now the more simplified question is what is the most optimal way to place river that maximize the thickets attack speed and that is still open ended (to run the river to the other side)?
edit: sorry I am stupid this build you linked should connect to the other side
https://loopherolayout.xyz/?c=111221211211211211211211211211211212212121121112111211211122
0
u/[deleted] Mar 13 '21
[deleted] — view deleted comment
0
u/[deleted] Mar 13 '21
[deleted] — view deleted comment
4
u/[deleted] Mar 14 '21
[removed] — view removed comment