Iím sure everyone has wasted a few hours playing Minesweeper on earlier version of Windows. Itís a timeless puzzle game.
[ As I was researching this post I discovered that the version of Minesweeper that ships with Windows 7 (developed by Oberon) has different starting logic and so Iím reverting to the earlier classic versions of Minesweeper for this analysis. ]
Minesweeper is a great little game and the only annoying part is that, sometimes, you have to guess in order to continue. Itís not hard to expose a situation where it is a coin toss as to the exact location of a mine. For example, in the image to the right, either of the top two squares could be a mine. Thereís no way to find any additional information to disambiguate.
When you lose a coin flip, the result is that youíre usually very eager to start a new game and get invested into the next game very quickly. This requires opening up the board as fast as possible.
When starting a game, ideally, what youíd like to see happen is to have a nice large blob open up so that you can walk around the edge, just like in the image below. If you click on a square that is entirely surrounded by safe areas, then minesweeper automatically Ďclicksí on these areas and the region expands.
Windows Minesweeper always allows makes your first click safe. No matter how ridiculously dense the board, if your first click would have landed you on a bomb, the program swaps this bomb with a blank space. After this you are on your own.
Using the criteria that we want the first click to be a click that Maximizes the chances that we click on a square entirely surrounded by other blank spaces, where is the best place to click? A Corner, an Edge, or a Middle square?
Letís do the math …
To create an exposed blob, we need all the squares around the square we click to also be empty spaces.
We already know that the first click square is going to be an empty space (our freebie). We now need to calculate the probability that the first touching square is also an empty space.
If there are N squares in the grid, then, because we've already exposed one cell, there are N - 1 squares left, and the number of empty squares (not mines) is N - M - 1
(Where M is the total number of mines in the puzzle.)
The probability that the first touching cell is also an empty cell is therefore: (N - M - 1) / (N - 1)
If the center cell is empty, and the first touching cell is empty, then the probability that the second touching square will also empty can be calculated.
It's not hard to see that the denominator changes to N - 2 (There are now two less unidentified squares on the grid), and the numerator changes to N - M - 2 (There are two less possible empty spaces).
The probability that the second touching cell is an empty cell is therefore: (N - M - 2) / (N - 2)
We can carry this on around all eight touching squares. Mathematically, we need to AND all these probabilities together, which we do by multiplying them.
The probability that a hole is created when a click is made in the middle of the board is therefore:
Similarly, if we click on a corner or edge we can see that the calculations are similar, but this time there are less touching squares. (Only three touching squares for a corner click, and five touching squares for an edge click).
Classic Minesweeper has three default difficulty settings: Beginner, Intermediate and Expert.
Below are details of the settings
Plugging these numbers into formula reveals these probabilities:
|Beginner||66.626 %||50.345 %||32.567 %|
|Intermediate||59.805 %||42.294 %||25.010 %|
|Expert||49.846 %||31.251 %||15.449 %|
It should be no surprise now that we've walked through the math that it is always best to click in a corner to maximize the chances that a cascade will occur. This should now be obvious, as the corner is the place that minimizes the number of adjacent squares!
Check out other interesting blog articles.