Game Development Reference
In-Depth Information
What Is Needed for Game State?
The minimum amount of state data we need is five integers. These correspond to
four hound subscripts plus one more for the fox. The locations of the checkers
are the only way we can tell one game apart from another. We will actually keep
far more state data. This data will make the game more pleasant for the player
and will make things easier on the AI. We will display some of this data gra-
phically. While the player merely enjoys knowing what the AI is thinking, the AI
programmer has a burning need to know exactly what the AI is thinking. Our
game will show some of the game state data. What other data would be useful in
the game state?
One very important bit of data would be the output of the evaluation function,
which we will call the rank, for this board. We will compute it once and store it,
trading space to gain speed. It would also be useful to know what the turn
number is for the board. As the AI generates multiple boards to represent pos-
sible future states of the game, if it sees two different ways to win, it can take the
one that comes sooner.
The AI and the display system also benefit from storing some per-square data.
We will store what the square holds, which is the fox, a hound, or nothing. We
will store what color we are going to paint the square. This color helps more
than the display; it will help the AI by providing a fast way to exploit heuristics.
We use three colors for our squares: white, black, and green. We color the
squares that the hounds cannot get to with green. As the hounds move, they
leave behind them a growing area of green, since the hounds do not move
backward. If the fox makes it to a green square, the fox wins. We internally
mark the squares that the hounds occupy as black, which we show graphically
using gray so that we can read the black ''Hnd'' labels on the buttons. The rest
of the squares we color black or white, depending on how the square relates to
the hounds and to the green squares. Any square that is not already green or
black and has a path that avoids the hounds and leads to a green we color white.
Any square that has no unblocked path to a green square is colored black.
Figure 6.3 is not in color, but there are green squares behind the hounds and
black squares in front of them. If the fox is hemmed in, the squares it can get to
are black, which we indicate by using a dark red for the fox as suggested in
Figure 6.3. If the fox has a path to freedom, those squares are white, and we use
a light red for the fox, as seen in Figure 6.5. Finally, we will store a number that
holds the number of steps each white square is away from a green square, also
seen in Figure 6.5 As you might expect, coloring and numbering are also used
 
 
Search Nedrilad ::




Custom Search