Game Development Reference
In-Depth Information
The analysis of this code is very similar to the fox's move code. It begins with a
quick victory check and then goes on to catalog the available moves. After the
same defensive code, it checks to see if it can employ a heuristic on moves
without doing any looking ahead. Putting the line back together is always a good
thing for the hounds. The sorting, when combined with the final version of the
evaluation function, makes it very easy for the hounds to pick among their good
moves. It also helps when they have to break the line. Putting a broken line back
together involves the exact same kind of look-ahead that the fox uses; just ask the
future about the results of the candidate moves.
Hounds' Look-Ahead
The hounds' look-ahead carries the same structure as the fox's look-ahead. There
are some differences worth pointing out, however. Add the following code to the
region:
'Give me the future result of this move.
Private Function HoundsLookAhead(ByVal GS As GameState, _
ByVal depth As Integer) As GameState
'Evaluate this hounds move they gave me.
If GS.GameRank > UNREACHABLE Then
Debug.WriteLine("**************** HoundsLookAhead: line is good, " & _
"so why am I looking ahead?.")
Return GS
End If
'It can reform the first broken line in 11, 10, and 5 moves.
If depth > 6 Then
'Debug.WriteLine("Hounds: terminating early at " & Depth.ToString)
Return GS
End If
'I'm not moving if I already won or lost.
If GS.GameRank = 0 Or GS.GameRank = TRAPPED Then Return GS
'I need to put the line back together, which I can't do
'until I see the fox move.
Dim TheirMove As GameState = Fox2(GS, depth, True)
'If they win, this move stinks and all futures based on it are
Search Nedrilad ::




Custom Search