Game Development Reference
In-Depth Information
'Tell me the future outcome of this move.
Private Function FoxLookAhead(ByVal GS As GameState, _
ByVal depth As Integer) As GameState
'Evaluate the candidate they passed in.
Debug.WriteLine("**************** FoxLookAhead: line is " & _
"broken, so why am I looking ahead?.")
Return GS
End If
'If you set the depth too low, it won't see how to break the wall.
'It needs at least 5. It can break the line from the start in
'5 moves at square 8, in 7 moves at square 10, and in 10 moves at 14.
If depth > 5 Then
'Debug.WriteLine("Terminating Fox on depth.")
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'm enclosed, or I would not be here. I can't tell one
'enclosed move from another, so I need to see the hounds' response.
Dim TheirMove As GameState = Hounds2(GS, depth, True)
'If I broke them, it's a great move.
If TheirMove.GameRank < UNREACHABLE Then
Debug.WriteLine("Fox can break the line at " & GS.FoxAt.ToString & _
" in " & depth.ToString & " moves.")
Return TheirMove
End If
'I am looking ahead, I give back results from the future.
Return Fox2(TheirMove, depth + 1, False)
End Function
Much like the Fox2() function, the FoxLookAhead() function starts by checking
that the code is operating as expected. The job of this routine is to foretell how
good the move passed in will turn out to be. Early on it checks for how deep the
search is going. The fox needs five levels of search to see the first place it can break
the line when the fox starts at the back row. There are later moves that break the
Search Nedrilad ::

Custom Search