Game Development Reference
In-Depth Information
context pointless. We know in advance that the early break is better. We also
know in advance that the fox loses unless the hounds make a blunder. We know
that the later break is as doomed as the early break, but the AI does not. Without
that foreknowledge, the AI would be correct in avoiding the doomed early break
in favor of the later break with the uncertain future. We optimize that away with
search depth to make a more interesting and effective AI. An AI that correctly
refuses to try anything because it knows it will fail is not very much fun. By taking
the early breaks, the fox is trying to force the hounds into a mistake instead of
letting them take an easy win.
The point here is that both sides could easily need to look ahead in other games.
Fox and Hounds is too straightforward and too full of rich heuristics to need it,
but other games will certainly call for it. Tic-Tac-Toe is one such game; looking
ahead on both sides is not limited to large and complex games.
The Hounds' Move
Having seen how the fox will look ahead, the hounds should be reasonably easy to
understand. Once we do the code for the hounds, we will be able to watch the two
AIs play each other. We start with the basic code that asks the hounds to take a
move. Add the following code to the region:
'Move a hound.
Private Function Hounds2(ByVal GS As GameState, ByVal depth As Integer, _
ByVal WantMove As Boolean) As GameState
'I'm not moving if I already won or lost.
If GS.GameRank = 0 Or GS.GameRank = TRAPPED Then
Debug.WriteLine("Hounds2: Game already over, not moving.")
Return GS
End If
'Look for move that has max fox steps/highest rank.
Dim ss As Integer
'We need to store the moves.
Dim SortedMoves As New Collection
Dim i As Integer
Dim Hounds() As Integer = GS.HoundsAt()
'Go through all four hounds . . .
Fori=0To3
Search Nedrilad ::




Custom Search