Minesweeper how to solve using system of linear equations or another technique

704 Views Asked by At

Maybe you all have heard of Minesweeper, the game where you need to look for the places of the bomb and flag them so that the mine squad can deactivate them.

Well I wondered if there was a mathematical approach of solving this game for each level of difficulty. Like a system of equations or some on its kind.

Here there is an exemple where I failed even though I was close to finishing it.

The first image I'll show you is from where I was stuck.

enter image description here

The second image is where I gave up and just chose a random tile.

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

Minesweeper is a game that involves luck. Denote $F$ as bomb. Focusing on the $3 \times 4$ block at top right corner.

\begin{bmatrix} F & F & F & 2 \\ 3 & 5 & F & 3 \\ 3 & F & 5 & F \end{bmatrix}

\begin{bmatrix} F & F & F & 2 \\ 3 & F & F & 3 \\ 3 & 5 & 5 & F \end{bmatrix}

are both valid solution. As in the given information on the board doesn't determine the solution uniquely.

0
On

Generally, NO. Minesweeper is not solvable.
See the answer by sdcvvc to the Minesweeper Deterministic Solvability Conditions question, and the article linked there.

And the simplest unsolvable piece is two squares in the corner, surrounded by a wall of 4 mines (similary: delimited by a short wall of two mines) and one mine missing.

$$\begin{array}{|ccccc} \hline \square & \square & F & \color{green} 2 & \\ F & F & F & \color{green} 2 \\ \color{green} 2 & \color{red} 3 & \color{green} 2 & \color{blue} 1 \\ \ \end{array} \qquad \begin{array}{|ccccc} \hline \square & \square & F & \color{green} 2 & \\ \color{blue} 1 & \color{red} 3 & F & \color{green} 2 \\ & \color{blue} 1 & \color{blue} 1 & \color{blue} 1 \\ \ \end{array}$$

Another one is like this:

$$\begin{array}{|ccccc} \ \\ & \color{blue} 1 & \color{blue} 1 & \color{blue} 1 \\ \color{blue} 1 & \color{red} 3 & F & \color{green} 2 \\ \square & \square & F & \color{red} 3 \\ \color{blue} 1 & \color{red} 3 & F & \color{green} 2 \\ & \color{blue} 1 & \color{blue} 1 & \color{blue} 1 \\ \ \end{array}$$

'F' denotes a flag, squares are un-tested locations, lines are the board edges.
In both cases you know there is one mine at one of two un-tested places, but there is no clue to find out which one. It's just fifty-fifty, you must guess.

What concerns your game, you should have noted that all 3 remaining mines must be adjacent to the top-right-most $3$ and exactly one of them must be adjacent to the second rightmost $3$ (so it had to be in the row number 3).
Then you could clear the square in the column number 3 (counting from right) and see the number. If it were $6$ you're done. If it were $5$ or $4$ you would still have to guess.