each a distance of one from their final destinations while tiles 3 and 6 are each a
distance of two from home). In fact, it actually takes seven moves to return this
puzzle configuration to the solved configuration.
Now that we have a heuristic for the eight-puzzle, the next step is to incorporate
it into our decision-making process. Recall that a human faced with a decision
tends to select the option that appears closest to the goal. Thus our search
procedure should consider the heuristic of each leaf node in the search tree and
pursue the search from a leaf node associated with the smallest value. This is the
strategy adopted in Figure 11.10, which presents an algorithm for developing a
search tree and executing the solution obtained.
Let us apply this algorithm to the eight-puzzle, starting from the initial configuration
in Figure 11.6. First, we establish this initial state as the root node and
record its heuristic value, which is five. Then, the first pass through the body of
the while statement instructs us to add the three nodes that can be reached from
the initial state, as shown in Figure 11.11. Note that we have recorded the heuristic
value of each leaf node in parentheses beneath the node.
The goal node has not been reached, so we again pass through the body of
the while statement, this time extending our search from the leftmost node (“the