Christopher Hodgson and Gregory Tyler Loftis Minesweeper A minesweeper board consists of a grid x by y composed of either a value denoting the number of mines in cells adjacent to it or a mine Cells are hidden until probed The player can mark a cell believed to be a mine ID: 343089
Download Presentation The PPT/PDF document "Winning Minesweeper" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Winning Minesweeper
Christopher Hodgson and Gregory Tyler LoftisSlide2
Minesweeper
A minesweeper board consists of a grid x by y composed of either a value denoting the number of mines in cells adjacent to it, or a mine.
Cells are hidden until probed. The player can mark a cell believed to be a mine.
The game is won when all cells that are not mines are revealed. The game is lost if a mine is probed.Slide3
A Difficult Problem
Deceptively hard game to win. Each game consists of only an X by Y grid, and N number of mines, randomly placed.
Due to the nature of the game, there is no way to “backtrack” once a mistake is made. Probing a mine results in instant failure.
Due to the random placement of the mines, it is difficult to isolate patterns from game to game, though there are patterns that do exist.
For the purposes of our algorithms, we have a set of interactions that the program can take with the Minesweeper board: look, probe, mark, unmark. Slide4
Programmer’s Minesweeper and Strategies
Programmer’s Minesweeper is a program from Northeastern University designed to implement minesweeper strategies. It is open source and we are using it to analyze the algorithms and modifying it for our purposes.
We discovered three strategies for approaching the game computationally: Single Point Strategy, Equation Strategy, and Constraint Satisfaction Problem Strategy (
CSPStrategy
).Slide5
Minesweeper Strategies
Strategies can be broken into to parts:
What to do when you have enough data to work with
What to do when you lack dataThe overall goal of a strategy is to win.Slide6
Single Point
Strategy – A Naïve Approach
Three Rules:
1. If the number of mines adjacent to the square is equal to the value in the square, then all adjacent squares can be probed safely.2. If the number of unknown adjacent squares + the number of marked adjacent squares is equal to the value in the square, then all unknown adjacent squares can be marked safely.
3. If the strategy cannot find either of these situations on the board, it probes a random square.Slide7
Single Point Strategy – A Naïve Approach
Rule 1:
Rule 2 and 3:Slide8
Single Point Strategy – A Naïve Approach
Lowest win rate of examined strategies
Required to make random probes: high probability that board winds up in a state where rule 3 is applied.
Only works with known information and makes no logical inferences based on probability.Slide9
Equation Strategy
Choose a starting point to add to probe set
while game not won or you lose
if probe set is empty
choose an
unprobed
point to add probe set
for all points in probe set
apply single equation rule to point apply equation difference rule to point
remove point from probe set
if mines remaining < some number
start comparing to global equationSlide10
Equation
Off board = 0
Probed points = 0
Marked points = 1Unprobed points = ?
Mine Sweeper Board
1
1
1
1 = x + 0 + 0 + 0 + 0 + 0 + 0 + 0
xSlide11
Global Equation
pValues
are the values of the points that are
unprobed
when the limit is reached
r is the number of mines remaining when the limit is reachedSlide12
Mine Sweeper Board
Single Equation Rule
0
If c for the point equals 0, then add all the points around it to the probe set.
If c for the point equals the number of unmarked points, then mark all the points around it.
0
1
1
2
2
0
0
1
2 = x + 1 + 0 + 0 + 0 + 0 + 0 + 0
1 = x
xSlide13
Mine Sweeper Board
Equation Difference
Rule
2
1
2
1
0
0
0
0
Take the equation for a point and the equation of an adjacent point and subtract them
If the value of the new c value equals the number of unknown points left, then mark them and probe the
unprobed
points that appear in both equations.
C
1
C
2
x
y
(2-1) = (x + 1 + y + 0 + 0 + 0 + 0 + 0) – (x + 1 + 0 + 0 + 0 + 0 + 0 + 0)
1 = ySlide14
Choosing where to probe
Choose at random
Choose base on probability of being a mine
Use pattern matching to find mines where the strategy might fail.Slide15
Pattern Matching
Mine Sweeper Board
2
1
2
1
0
0
0
0Slide16
Win Rates
Minesweeper defines three difficulty levels
Beginner: 9 x 9 grid, 10 mines
Intermediate: 16 x 16 grid, 40 minesExpert: 16 x 30 grid, 99 minesSlide17
Win RatesSlide18
Win RatesSlide19
Win RatesSlide20