Game Development Reference
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
Return GeneralNeighbors(Row, Col, FarNeighborOffsets)
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
Change this line:
Dim CloseNeighbors As Collection = theField.NearNeighbors
Dim OuterNeighbors As Collection = theField.FarNeighbors
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,
That line should be changed to read as follows:
Call AI.TwoSquareMatcher(RevealedSquare, OuterNeighbors, SimonSays,
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