Game Development Reference
The fox is behind a line with only one move.
versus AI game. The fox needs to look ahead to break the wall, but it has only one
move, so that is the move it must take. Most of the time, there are multiple moves
The fox then creates storage for the best move and for the future result that the
best move yields. Then, for each move it has, it asks the future for the outcome of
that move. Each result is used to decide whether the move is best. Once all the
moves are checked, there should always be a best move, and the code returns
either the move or the result of the move, depending on what the caller requested.
If something went wrong and no move or result was returned, the code com-
plains with an easily seen error message in the debugging output. These messages
are never seen when the current bug-free code executes, but the code was not
always bug free. Professionals never assume that code is bug free.
The Fox's Look-Ahead
All of this sounds perfectly reasonable, except that bit about asking the future. Let
us see what asking the future looks like in code. Add the following to the region: