The Puzzle Solver


The solver always chooses the optimal solution, i.e., with the fewest number of moves (it uses the A* search strategy, with the manhattan distance of each piece to its ultimate goal as the search heuristic). Due to the size of the problem, I've fudged a bit with the randomization algorithm at the beginning to limit the size of the search space, but still, occasionally you may get a puzzle that takes the machine a while to solve. (Most, however, take under 10 seconds.)

To use the Puzzle Solver, click on "New" to get a new puzzle. Then click "Solve" to have the applet find an optimal solution path. You can then view the animation by clicking on "Run" or step through it using "Step".

For those who are interested, here's the source.

email comments to