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
View all comments
Show parent comment
3
u/server_maintenance Mar 14 '21
Yeah doesn't make that much sense tbh but otherwise it would just be outright broken