Game Development Reference
In-Depth Information
Switch to the file PlayingField.vb. There is a code tab and a design tab; we will do
the code first. Find the AI Related region and add the following code to it:
Public Sub ExecuteBook()
'Store the pairs of moves in collections.
Dim FirstSquares As New Collection
Dim SecondSquares As New Collection
'Add in pairs of moves to the collections in order.
'Add in the corners first.
'Add the upper-left corner.
FirstSquares.Add(Field(1, 1))
SecondSquares.Add(Field(0, 0))
'Add the lower-right corner.
FirstSquares.Add(Field(NumRows - 2, NumCols - 2))
SecondSquares.Add(Field(NumRows - 1, NumCols - 1))
'You can figure out from here how to add the other two corners.
'Then add some edge moves, from center outward.
Dim Col As Integer
For Col = 1 To NumCols \ 4
'Add moves on upper edge going right.
FirstSquares.Add(Field(1, NumCols \ 2 + Col))
SecondSquares.Add(Field(0, NumCols \ 2 + Col))
'Add moves on upper edge going left.
FirstSquares.Add(Field(1, NumCols \ 2 - Col))
SecondSquares.Add(Field(0, NumCols \ 2 - Col))
'You can figure out how to add the lower edge.
Next
'If we wanted the left and right edge, we'd add them here.
'Now walk down the list in two passes.
Dim pass As Integer
For pass = 1 To 2
Dim FirstMove As Square
Dim SecondMove As Square
Dim i As Integer
For i = 1 To FirstSquares.Count
 
Search Nedrilad ::




Custom Search