Game Development Reference
In-Depth Information
'...checking for possible moves . . .
For Each ss In Moves.MovesDown(Hounds(i))
'...that are not blocked.
If Not GS.HasChecker(ss) Then
'Store them away in the sorted list.
AddGameStateKeepSorted(GS.ProposeHoundTo(i, ss), _
End If
'If I can't move, return the existing game.
If SortedMoves.Count = 0 Then
Debug.WriteLine(depth.ToString & " Hounds2:
Return GS
End If
'Look at the highest steps move (the last one).
Dim Candidate As GameState
Candidate = CType(SortedMoves(SortedMoves.Count), GameState)
'Did I win or keep the fox in black? No need to look further.
If Candidate.GameRank >= UNREACHABLE Then
'It's a good move for the hounds.
'Oh, happy day, this move fixes a broken line.
Debug.WriteLine(depth.ToString & _ "
"Hounds found a way to win or restore the line.")
End If
'Here is where the naive counting of black squares leads to trouble.
'The bad moves wind up last in the list when there are ties.
'The better count doesn't have the problem.
Return Candidate
End If
'If we are here, the line is already broken or about to break.
'Is the line about to break?
If GS.GameRank >= UNREACHABLE Then
'Simple rule when we break the line - put the fox farthest
'from the hole.
Search Nedrilad ::

Custom Search