Skip to content

Conversation

@truggeri
Copy link
Owner

Summary

The body of this solution is copied from day 16 (#20). Instead of "cost" per square, we use the number of moves it took to get to that square and no longer need to calculate the cost, it's all just based on moves. This technique worked for small puzzles, but it failed when running at the larger, 70x70 puzzle.

After debugging, it appeared the number of threads per iteration was growing exponentially around iteration 120. There was no possibility to cull threads because no solution had been found yet. To remedy this, we switch to a more depth first algorithm that processes new threads first, and limits the number to be processed per loop to a fixed number. With this technique, we can then find a solution faster, which allows us to shed more threads that aren't optimal so that we don't grow exponentially.

Finally, I swept the thread pool size manually. It appears that a smaller pool size resulted in a faster, more efficient path to the solution, but dropping it bellow ten resulted in the wrong answer and below seven resulted in no answer.

@truggeri truggeri self-assigned this Dec 31, 2024
@truggeri truggeri merged commit 733219b into main Dec 31, 2024
1 check passed
@truggeri truggeri mentioned this pull request Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants