Game Development Reference
'...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), _
'If I can't move, return the existing game.
If SortedMoves.Count = 0 Then
Debug.WriteLine(depth.ToString & " Hounds2:
'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.
If GS.GameRank < UNREACHABLE Then
'Oh, happy day, this move fixes a broken line.
Debug.WriteLine(depth.ToString & _ "
"Hounds found a way to win or restore the line.")
'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.
'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.