Game Development Reference
In-Depth Information
'Don't number hound squares.
If StateSquare.Holds <> Checker.Hound Then
'Use the neighbors to see if I have a lower number.
For Each ss In Moves.Neighbors(i)
'Can my neighbor lower my steps count?
If Squares(ss).Steps + 1 < StateSquare.Steps Then
StateSquare.Steps = Squares(ss).Steps + 1
'That makes me a white square.
StateSquare.Kind = SquareColor.White
'We changed stuff, have to keep looping.
NeedsMorePasses = True
End If
Next ss
End If
Next i
End While
'Is the fox trapped?
StateSquare = Squares(Fox)
Dim CanMove As Boolean = False
For Each ss In Moves.Neighbors(Fox)
If Squares(ss).Holds <> Checker.Hound Then
CanMove = True
End If
'Set the game rank (and maybe change fox from UNREACHABLE to TRAPPED).
If Not CanMove Then
StateSquare.Steps = TRAPPED
'It can move, is it on black or white?
If StateSquare.Steps < UNREACHABLE Then
'Use the steps value if on white.
Rank = StateSquare.Steps
'The first version of the code was happy with UNREACHABLE.
'See Figure 6.6 to see this fail.
'Rank is higher the fewer black squares remain,
'but always lower than TRAPPED (four hounds are black)
'and always higher than UNREACHABLE.
Search Nedrilad ::

Custom Search