Game Development Reference

In-Depth Information

'Add the hounds.

Fori=0To3

Squares(Hounds(i)).Holds = Checker.Hound

Next

'Start coloring the top row of green.

Fori=0To3

StateSquare = Squares(i)

If StateSquare.Holds <> Checker.Hound Then

StateSquare.Kind = SquareColor.Green

StateSquare.Steps = 0

End If

Next i

'I am green if all of my parents are green

'and no hound sits on me.

Fori=4To31

StateSquare = Squares(i)

If StateSquare.Holds <> Checker.Hound Then

Dim AmGreen As Boolean = True

For Each ss In Moves.MovesUp(i)

AmGreen = AmGreen And (Squares(ss).Kind = SquareColor.Green)

Next

If AmGreen Then

StateSquare.Kind = SquareColor.Green

StateSquare.Steps = 0

End If

End If

Next

'Renumber the squares if the hounds left an opening.

'Keep renumbering until the numbers stabilize (at most

'something like 11 times).

Dim NeedsMorePasses As Boolean = True

While NeedsMorePasses

'We are done unless we do something.

NeedsMorePasses = False

'Start at 4, the top row is never white.

Fori=4To31

StateSquare = Squares(i)