Game Development Reference
In-Depth Information
has taken us from ''clearly impossible'' to ''maybe.'' The code for the Twixt game
shown in the figures is on the CD included with this topic. Adding AI to the game
is left as an exercise for the motivated reader. While the topic of moves for Twixt
appears straightforward, the rest of a hybrid AI that exploits that book is a
daunting challenge.
The AI for Minesweeper given in Chapter 4 proved to be pretty awesome once the
player got it started. So how could it benefit from a book of moves when the
general rules seemed to get nearly all of the deterministic moves? One question
that comes to mind is, ''What is the best first move at Minesweeper ?'' That
question might initially get the response of ''The first move is safe, so why does it
matter?'' But the best first move is one that either exposes the most squares or
that gives the best follow-up moves when the player is forced to start taking
chances. So if the first move did not expose more than one square, a good second
move needs to be a move that can quickly generate the highest number of
deterministic moves. We will look at the numbers and apply them to the various
first moves to see if we can come up with something useful.
The Basic Numbers
In Minesweeper , there are 99 mines in 480 squares. After the first move, that
reduces to 479 squares. This gives a density of 0.207 mines per square on average,
which is the same as having a 79.3 percent probability of being clear. These
numbers are averages; the mines are not evenly spread out. We can use these
numbers to give an expected value of how many mines surround a square before
we click it. We will add or multiply these numbers as needed to evaluate different
moves that could go into our topic of moves. We will not compute the exact
values of all the numbers needed to exactly evaluate the different first moves in
order to keep the statistics from interfering with the analysis.
A Middle First Move
For our purposes, a middle move has two or more squares between it and any
edge. As a first move, it either exposes eight more squares or presents the user with
a number between one and eight. The player has a 0.793 8 chance of getting lucky
on his or her first move and selecting a square with zero surrounding mines. That
works out to getting eight squares 15.7 percent of the time. The average yield of
the first move in isolation is thus 1.26 squares. The other 84.3 percent of the time,
Search Nedrilad ::

Custom Search