Game Development Reference
In-Depth Information
For col = 0 To 3
ss = row * 4 + col
'Everybody gets a collection even if it might stay empty.
MovesUp(ss) = New Collection
MovesDown(ss) = New Collection
Neighbors(ss) = New Collection
'Treat even and odd rows differently.
'The changing order in which up-left and up-right
'moves are added is by design to make the fox zigzag
'upward instead of going up diagonally.
If offset = 0 Then
'Do moves up first (helps fox AI).
'Don't fall off the top of the board.
If row > 0 Then
'The last col in even rows lacks the
'neighbors to the right.
If col <> 3 Then
'up and right.
finalss = ss - 3
MovesUp(ss).Add(finalss, finalss.ToString)
Neighbors(ss).Add(finalss, finalss.ToString)
End If
'up and left.
finalss = ss - 4
MovesUp(ss).Add(finalss, finalss.ToString)
Neighbors(ss).Add(finalss, finalss.ToString)
End If
'Now do moves down.
'Even rows always have an odd row below
'down and left.
finalss = ss + 4
MovesDown(ss).Add(finalss, finalss.ToString)
Neighbors(ss).Add(finalss, finalss.ToString)
'The last col in even rows lacks the
'two neighbors to the right.
If col <> 3 Then
'down and right.
finalss = ss + 5
Search Nedrilad ::




Custom Search