April 20, 2023 @ 00:15
Recently I realised that me studying maths has meant I am no longer terrible at the logic game, Minesweeper. This post talks about basic use of propositional logic. This is useful when playing Minesweeper. Mostly, this is a loose application of Proof by Contradiction and Proof by Exhaustion.
When I was a kid playing Minesweeper on a Windows 2000, I would have liked to have known about propositional logic.
Consider this start in a game of Minesweeper below. I went ahead and marked all of the trivial mines with flags and I hope you can see I required no guesswork here. If a 3
has three empty squares that it touches then according to the rules of Minesweeper all of those empty squares must have mines. But then the opportunity to use this simple logic is no more.
What we can do next is propose something that contradicts itself.
There's a 3
in this picture that touches one mine already so there must be two other mines. The possible places are A
, B
, C
.
Suppose there are two mines in each of A
, B
. This is impossible because then there would be a 2
with three mines touching. So that means there can be at most one mine in either A
or B
. But then that means that C
must have a mine in it. It also means that since 2
is already touching two mines, with one in A
or B
, then nothing else can touch 2
.
So we get this:
Take a look at the 5,3
and the top right
Figuring this out will take a bit more work.
Consider the 5
by itself.
There are four cases, with mines in:
A,B,C
D
touches 5
and so D
has no mine. 3
requires there to be a mine in either E
or F
.A,B,D
A,C,D
3
and to its right 1
are touching the required number of mines.B,C,D
In all of the three possible cases, 1
touches its required mine in either D
, E
or F
. That means any other square that touches 1
has no mine. So the natural thing is to click the square directly right of 1
.
And so we end up with this
It seems to be very rare that we actually need to make guesses in Minesweeper.