Game Development Reference
middle board. Moving the end hound, which is not part of the line, does not
improve their position at all. The fox steps forward on move 43, leaving the
hounds no choice but to let it out on their next move.
The evaluation function needs a way to judge which UNREACHABLE move is better.
One way to describe the better move for the hounds is that the better move keeps
pressing the fox. In Figure 6.6, the hounds threw away a chance to close in on the
fox in favor of wasting time with a ''free'' move. We need a way to turn words like
''close in'' and ''pressing'' into something our AI can compute. One of the finer
arts of AI programming is the ability to turn these concepts into code.
The next step in the evolution is to come up with a number to indicate ''better''
UNREACHABLE moves, with ''better'' meaning ''fewer black squares.'' Recall that the
black squares have no path to freedom and that the hounds try to keep the fox
restricted to black squares. The idea is that the smaller the number of squares left
to the fox, the closer the fox is to being pinned by the hounds. There is a subtle
difference between ''fewer black squares'' and ''fewer squares available to the
fox,'' however, as we shall soon see.
It is easy to simply count the number of black squares. This gives an evaluation
function that generates board rank as follows: If the fox can move but not reach
freedom, the value for rank is 127 (the value when the fox is pinned) reduced by
the number of black squares. Note that the number of black squares in this
situation is at least six; the four squares the hounds sit upon are always black, the
fox is on a black square, and since the fox is not pinned, there is one or more
black square, to which it can move. The opening board shown in Figure 6.2 has
32 black squares, for a board rank of 95. This is as low as the rank can go and still
have the fox behind an unbroken wall. The value of 95 is well above the value of
64 used to mark UNREACHABLE , so all such boards would have a rank that is greater
than or equal to UNREACHABLE , making the code changes easy to implement.
This new evaluation makes judgments between different UNREACHABLE boards.
Any ties are broken using the idea that good things should happen sooner and
bad things should happen later. A rank of 102 is always better than a rank of 104.
A rank of 102 on turn 36 is better than a rank of 102 on turn 38.
This step in the evolution fixes the problem illustrated in Figure 6.6. This eva-
luation function proved to be the most interesting, even though it has flaws.
The interesting part is that the hounds appeared to ''toy'' with the fox after the
fox had broken the line. The hounds would see one move that reformed their line