Game Development Reference
In-Depth Information
New Point(1, -2), New Point(1, 2), _
New Point(2, -2), New Point(2, -1), New Point(2, 0), _
New Point(2, 1), New Point(2, 2)}
We also need a public routine to return a collection of Square objects.
GeneralNeighbors will do it for us if we pass in the new offsets. Add the following
code to the class:
Public Function FarNeighbors(ByVal Row As Integer, ByVal Col As Integer) As
Collection
Return GeneralNeighbors(Row, Col, FarNeighborOffsets)
End Function
This capability makes writing the rule refreshingly easy. Add another class to the
project and name it RuleTwoFar.vb. Copy everything inside the RuleTwoNear class
and paste it inside the RuleTwoFar class. Start with Inherits and be sure to get the
End Function line. We need to change the code that deals in getting the list of
potential helpers.
Change this line:
Dim CloseNeighbors As Collection = theField.NearNeighbors
(RevealedSquare.R, RevealedSquare.C)
Into this:
Dim OuterNeighbors As Collection = theField.FarNeighbors
(RevealedSquare.R, RevealedSquare.C)
Since we changed the variable name for clarity, we have to change it everywhere.
Just below the declaration is the following line:
Call AI.TwoSquareMatcher(RevealedSquare, CloseNeighbors, SimonSays,
SquaresList)
That line should be changed to read as follows:
Call AI.TwoSquareMatcher(RevealedSquare, OuterNeighbors, SimonSays,
SquaresList)
That completes the rule. Remember to put a copy of the rule into the framework.
Find the PlayingField Load event handler and add the following line after the
first two:
Brains.AddRule(New RuleTwoFar)
 
Search Nedrilad ::




Custom Search