The 15 puzzle program does not do any searching as it solves a puzzle. It uses an explicitly described method. (See the original post for details of this method) However, in applying this method, the program repeatedly needs to find a way to move a numbered tile from one position to another, without disturbing the positions of certain other "locked" tiles.
To do this, the program makes use of a simple maze pathfinding algorithm.
It uses the pathfinder to plot the path a tile must take to reach its target position without disturbing "locked" tiles. Once the path is plotted, the program typically tries to move the tile along the path.
However, since the tile can only move into an empty space, the empty space must be moved to the next spot the tile needs to move into (to progress it along its path). So, the program uses the pathfinding algorithm to plot a course for the empty space as well (again, without disturbing "locked" tiles, which would now typically include the tile trying to reach its destination).
Here is a description of the simple maze pathfinding algorithm:
1) Mark the destination on the maze with the number zero.
2) Every iteration of the following represents a single step in the maze, so the number of iterations doesn't need to be any higher than the maximum number of steps you are willing to take. (Theoretical maximum is width * length of the maze) For every iteration:
- Make a pass along every cell in the maze.
- If the cell is not a "wall" cell, check its immediate 4 neighbours.
- If one of these neighbour cells is marked with the number of the previous step, mark the current cell with the number of the current step.
After running this algorithm, you end up with a maze (or whatever you were writing on) marked with the number of steps it will take to reach the goal from any cell in the maze.
So to plot a course from a particular point, you simply find the neighbouring cell with fewer steps remaining than the current one, and you keep doing this until you inevitably reach the goal cell.
In the 15 puzzle solver, this number is displayed in small print at the top right corner of each cell.
Cells shaded yellow are cells that have been marked as "walls".
I may release another version which displays more details about the steps it is taking, as well as displaying the path finding being done for the empty space (which was initially omitted for clarity).