0% found this document useful (0 votes)
32 views67 pages

ASE2003

The document discusses the game Minesweeper and explains how its complexity relates to an important unsolved problem in mathematics. It describes that determining whether a given Minesweeper configuration is consistent is computationally difficult, requiring searching through an exponentially large number of possibilities for mine placements. While faster algorithms may exist, none are currently known. The document also introduces electronic components like wires, splitters, and gates that can model Minesweeper puzzles and shows how signals in one part of the board can affect others.

Uploaded by

ACHRAF EL MINOR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views67 pages

ASE2003

The document discusses the game Minesweeper and explains how its complexity relates to an important unsolved problem in mathematics. It describes that determining whether a given Minesweeper configuration is consistent is computationally difficult, requiring searching through an exponentially large number of possibilities for mine placements. While faster algorithms may exist, none are currently known. The document also introduces electronic components like wires, splitters, and gates that can model Minesweeper puzzles and shows how signals in one part of the board can affect others.

Uploaded by

ACHRAF EL MINOR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

How Complicated is Minesweeper?

Richard Kaye
http://web.mat.bham.ac.uk/R.W.Kaye/
[email protected]

Birmingham University

ASE2003 – p. 1
Minesweeper
• Minesweeper is a familiar computer game
requiring you to locate the mines in a
minefield without being blown up.
• When skilfully played, the task can be
completed without having to take many risky
guesses!

ASE2003 – p. 2
Minesweeper
• Minesweeper is a familiar computer game
requiring you to locate the mines in a
minefield without being blown up.
• When skilfully played, the task can be
completed without having to take many risky
guesses!
• In fact the complexity of minesweeper is related to an
important unsolved problem in mathematics, which in
turn relates to cracking codes on the internet.

ASE2003 – p. 2
Playing the game

Does (2,6) have a mine?

ASE2003 – p. 3
Playing the game

These must have mines

ASE2003 – p. 3
Playing the game

Does (5,2) have a mine?

ASE2003 – p. 3
Playing the game

If so, does (5,7) have a mine?

ASE2003 – p. 3
Playing the game

If (5,2) and (5,7) have mines

ASE2003 – p. 3
Playing the game

If (5,2) has a mine but (5,7) hasn’t

ASE2003 – p. 3
Playing the game

If (5,2) is clear

ASE2003 – p. 3
Playing the game

So (2,6) is clear!

ASE2003 – p. 3
A puzzle

Determine the location of all mines!

ASE2003 – p. 4
A puzzle

Can this be a mine?

ASE2003 – p. 4
A puzzle

If this is a mine the one next to it is clear. . .

ASE2003 – p. 4
A puzzle

So. . .

ASE2003 – p. 4
A puzzle

. . . which is impossible!

ASE2003 – p. 4
A puzzle

Therefore. . .

ASE2003 – p. 4
A puzzle

Solved!

ASE2003 – p. 4
What is the question?
• Minesweeper appears to be difficult to play
well. How difficult is it?

ASE2003 – p. 5
What is the question?
• Minesweeper appears to be difficult to play
well. How difficult is it?
• To formulate this question precisely we need
to specify what we mean by playing ‘well’. We
can at least assume a good player will not
take stupid risks:

ASE2003 – p. 5
What is the question?
• Minesweeper appears to be difficult to play
well. How difficult is it?
• To formulate this question precisely we need
to specify what we mean by playing ‘well’. We
can at least assume a good player will not
take stupid risks:
• We want to play in such a way that we never
make a risky move when there is some
square which can be uncovered safely.

ASE2003 – p. 5
The consistency problem
• Given a minesweeper configuration, is it
consistent? I.e., could it have arisen from
some pattern of mines?

ASE2003 – p. 6
The consistency problem
• Given a minesweeper configuration, is it
consistent? I.e., could it have arisen from
some pattern of mines?
• To determine if a square is free of any mines
change the configuration marking it with a
mine. Then ask if the result is consistent. If
not, it is safe to clear the square!

ASE2003 – p. 6
How might we solve it?
• Problems like this are quite general and
require a computer algorithm or computer
program as the solution.

ASE2003 – p. 7
How might we solve it?
• Problems like this are quite general and
require a computer algorithm or computer
program as the solution.
• There is an algorithm that solves this problem
and solves the consistency problem. All you
need to do is go though all the different
combinations for the mines on the minefield in
turn.

ASE2003 – p. 7
So what’s the difficulty?
• Typical minesweeper configurations have
many squares. (The so-called ‘advanced’
board has 99 mines in 480 squares, that’s
5602209993374213454290589857758. . . 9570631168198385673295159633481600

or over 10100 possible ways of placing these


99 mines.)

ASE2003 – p. 8
So what’s the difficulty?
• Typical minesweeper configurations have
many squares. (The so-called ‘advanced’
board has 99 mines in 480 squares, that’s
5602209993374213454290589857758. . . 9570631168198385673295159633481600

or over 10100 possible ways of placing these


99 mines.)
• No known method can search through all
these possibilities in reasonable time.

ASE2003 – p. 8
Can we avoid this difficulty?
• Possibly. In fact no-one knows the answer to
this question.

ASE2003 – p. 9
Can we avoid this difficulty?
• Possibly. In fact no-one knows the answer to
this question.
• We can hope for a fast or efficient algorithm
that takes time proportional to a fixed
polynomial in the number of squares in the
input configuration (Polynomial Time) rather
than Exponential Time.

ASE2003 – p. 9
Can we avoid this difficulty?
• Possibly. In fact no-one knows the answer to
this question.
• We can hope for a fast or efficient algorithm
that takes time proportional to a fixed
polynomial in the number of squares in the
input configuration (Polynomial Time) rather
than Exponential Time.
• However, it seems unlikely that such an
algorithm exists.

ASE2003 – p. 9
A wire

Minesweeper is complicated by the fact that


something in one part of the board can affect the
whole board.

ASE2003 – p. 10
A wire

Minesweeper is complicated by the fact that


something in one part of the board can affect the
whole board.

ASE2003 – p. 10
A wire

Minesweeper is complicated by the fact that


something in one part of the board can affect the
whole board.

ASE2003 – p. 10
A wire

Minesweeper is complicated by the fact that


something in one part of the board can affect the
whole board.

ASE2003 – p. 10
A splitter

Use this to split, bend, or ‘invert’ wires.

ASE2003 – p. 11
A splitter

Use this to split, bend, or ‘invert’ wires.

ASE2003 – p. 11
A crossover

Use this to cross two wires over!


ASE2003 – p. 12
A crossover

Use this to cross two wires over!


ASE2003 – p. 12
A crossover

Use this to cross two wires over!


ASE2003 – p. 12
A crossover

Use this to cross two wires over!


ASE2003 – p. 12
An XOR gate

ASE2003 – p. 13
An XOR gate

ASE2003 – p. 13
An XOR gate

ASE2003 – p. 13
An AND gate

An AND gate. . .
ASE2003 – p. 14
An AND gate

. . . and its internal wires.


ASE2003 – p. 14
An AND gate

If t is a mine. . .
ASE2003 – p. 14
An AND gate

If t is not a mine. . .
ASE2003 – p. 14
An OR gate

An OR gate. . .
ASE2003 – p. 15
An OR gate

. . . with the internal wires shown.


ASE2003 – p. 15
An OR gate

If r is free. . .
ASE2003 – p. 15
An OR gate

If r has a mine (case 1). . .


ASE2003 – p. 15
An OR gate

If r has a mine (case 2). . .


ASE2003 – p. 15
Minesweeper electronics
• Wire: allows us to carry signals around

ASE2003 – p. 16
Minesweeper electronics
• Wire: allows us to carry signals around
• Splitter: allows us to bend, split and invert
signals in wires

ASE2003 – p. 16
Minesweeper electronics
• Wire: allows us to carry signals around
• Splitter: allows us to bend, split and invert
signals in wires
• Crossover: allows us to make arbitrary
circuits in the plain

ASE2003 – p. 16
Minesweeper electronics
• Wire: allows us to carry signals around
• Splitter: allows us to bend, split and invert
signals in wires
• Crossover: allows us to make arbitrary
circuits in the plain
• Logic gates: NOT AND OR XOR, etc.

ASE2003 – p. 16
NP-completeness
• We can build any logic circuits in
minesweeper, so. . .

ASE2003 – p. 17
NP-completeness
• We can build any logic circuits in
minesweeper, so. . .
• An algorithm solving the minesweeper
consistency problem would allow us to solve
questions about simple (propositional) logic.

ASE2003 – p. 17
NP-completeness
• We can build any logic circuits in
minesweeper, so. . .
• An algorithm solving the minesweeper
consistency problem would allow us to solve
questions about simple (propositional) logic.
• Many other problems can be phrased as logic
problems and therefore reduced to
minesweeper consistency problems.

ASE2003 – p. 17
NP-completeness
• We can build any logic circuits in
minesweeper, so. . .
• An algorithm solving the minesweeper
consistency problem would allow us to solve
questions about simple (propositional) logic.
• Many other problems can be phrased as logic
problems and therefore reduced to
minesweeper consistency problems.
• The Minesweeper Consistency Problem is
NP-complete.
ASE2003 – p. 17
Some interesting NP problems
• The travelling salesman problem

ASE2003 – p. 18
Some interesting NP problems
• The travelling salesman problem
• Many other problems is scheduling, packing,
decision maths, etc.

ASE2003 – p. 18
Some interesting NP problems
• The travelling salesman problem
• Many other problems is scheduling, packing,
decision maths, etc.
• Other games, such as Tetris

ASE2003 – p. 18
Some interesting NP problems
• The travelling salesman problem
• Many other problems is scheduling, packing,
decision maths, etc.
• Other games, such as Tetris
• Factorizing integers

ASE2003 – p. 18
Some interesting NP problems
• The travelling salesman problem
• Many other problems is scheduling, packing,
decision maths, etc.
• Other games, such as Tetris
• Factorizing integers
• Determining a computer user’s secret key
from his public key

ASE2003 – p. 18
The P equals NP question
• The ‘P equals NP question’ asks if every NP
problem has an efficient algorithm. No-one
knows the answer! A prize of $1,000,000 has
been offered for a proof either way.

ASE2003 – p. 19
The P equals NP question
• The ‘P equals NP question’ asks if every NP
problem has an efficient algorithm. No-one
knows the answer! A prize of $1,000,000 has
been offered for a proof either way.
• It would suffice to show
• either that the minesweeper consistency
problem has and efficient solution
• or that there is no such algorithm for the
minesweeper consistency problem

ASE2003 – p. 19

You might also like