Game Development Reference
In-Depth Information
'This is how many moves we can make
Return Me.SquaresList.Count
End Function
End Class
The routine declares the numbers it needs and sets them to zero. It gets the
neighboring squares from the playing field. Armed with all that, it gets the basic
statistics and the collection of nearby blank squares. The decision will be to flag
all the blanks as mines, click all of them because they are safe, or do nothing.
Since this is the only rule, we can test it without writing the framework.
Switch to Square.vb. Find the MouseUp event handler. Look for the comment about
a placeholder for AI. When the user right-clicks a revealed square, that user is
asking the AI to run. Replace the placeholder comment with the following code:
'Placeholder for AI
theField.FirstThought("Thinking about Square at Row=" & _
Row.ToString & ", Col=" & Col.ToString)
Dim R1 As New RuleOne
If R1.Matches(Me) > 0 Then
End If
'End placeholder
This is sufficient to test the rule. Run the game and right-click every revealed
square. If the AI makes a move, you may want to click again on revealed squares
previously clicked to see if the AI now has enough information to make another
move. Armed with this single simple rule, after you get a game started, the AI can
make around 90 percent of the moves needed to solve the game. You will have to
help it now and then by using the information of more than one square. This rule
proves that Minesweeper is less about thinking hard than it is about never making
a mistake.
This rule executes perfectly, giving it an advantage over human players. Does it
make the game more or less fun? If the fun part of the game is making the hard
moves and the thrill of making a non-fatal guess, then the rule takes away the
boring, repetitive part of play. If the fun part of the game is the challenge of
holding to discipline and demonstrating the perfection of your play, then this
rule trashes the fun right out of the game. Recall in the earlier discussion that the
programmer must mediate between an AI that is stupid and thus boring versus
one that is too smart and thus frustrating. With only one rule in place, we can
clearly see this need.
Search Nedrilad ::

Custom Search