Minesweeper Math
74
Welcome!
Welcome to the second installment of what I am going to dub the "X Math" series! Seeing some interest in my Zombie Math article has inspired me to continue in the same vein, demonstrating how math can be used (contrary to popular belief) for fun! If you find this to be an entertaining, or interesting, and are intrigued by zombies and/or the coming Zombocalypse then I suggest you head on over to Zombie Math too. And of course, comments are encouraged and will always be accepted except for inappropriate-ness.
Introduction
There are three categories of people in the world - people who have played and understand Minesweeper, people who have tried but do not understand Minesweeper, and people who have never even attempted this most time-devouring game. Hopefully, this article will be accessible to all three categories of person. To this end we start out with a brief introduction to the great game of Minesweeper.
Minesweeper has been included with versions of windows beginning since the 90's and still retains its addictive quality after nearly two decades. The basic premise of the game is that a grid is laid out with a certain number of game-ending squares (mines) hidden throughout. The player can click a square to reveal a number (provided that it isn't a mine!) which tells the player how many of the adjacent squares are dangerous.
fig. 1 - One mine hidden in the three adjacent squares
For example, if John clicks a square and it changes to a number 1, then he knows that there is only one mine in the adjacent squares (see fig. 1). In fig. 1 we see that if John clicks a random adjacent square, then he has a 1 out of 3 chance to hit a mine, or about 33%. Now, consider that the best chance John can have of hitting a mine (best as in best-for-John, not as in greatest) is 1 out of 8, or about 12%. Continuing the pattern of clicking a random adjacent square each time results in about 56% likelihood that John's game will be over after only 6 clicks at best!
Fortunately, we can use some analysis and basic probability to maximize the chances of uncovering every mine and winning the game.
Square Analysis - Matrix Logic
One of the tools that we have at our disposal is good old-fashioned problem solving skills. In fig. 2(a) below, you can see that we have clicked on two of the original three adjacent squares, revealing yet more numbers. But, there still remains one unrevealed square - this is a mine! In mathematics, this type of analysis is called matrix logic and is often used in problems that utilize a process of elimination. In fig. 2(b) we have marked the dangerous square as a mine; knowing where one mine is can give us valuable clues about other squares too! Notice that the two safe squares are also 1's. Now, since we have located the one mine in these squares surrounding areas, then all of the other adjacent spaces must be safe! In fig. 2(c) we see that this is indeed the case. Congratulations! You now have one more anti-mine strategy in your arsenal!
fig. 2 - Matrix logic used to reveal safe squares
fig. 3 - Elimination is paramount to victory!
Eliminating Null Solutions
In fig. 3 we see another variation of the matrix logic strategy in effect. Notice that if we randomly clicked a square adjacent to the 1, we would have a 50% chance of LOSING!! Obviously this is very bad, but there is hope. We have mathematics and logic, after all. Suppose first that the mine is located in the lower square of the two, outlined in blue in fig. 3. Since this is the location of the 1's mine, the the other mine adjacent to the 2 must be located directly underneath it (also outlined in blue). But this cannot be! Look closely below the 2 - there is already another mine there, making three mines within the adjacent squares of the 2. Therefore, the mine must be in the square outlined in red in the figure. We see after checking that it is.
fig 4 - Uncertainty rears its ugly head
Probability Analysis - Making the Most of Guesswork
Many games of Minesweeper will eventually come to the point where matrix analysis leaves multiple possibilities for the location of one or more mines. In these instances, it is crucial to be able to determine the BEST choice when making the next click. Note that probability analysis cannot guarantee success, but it can make your chances of completing the board the best that they can be. So without further ado, we continue to our first sticky situation.
In fig. 4 we see that the board has come to a point at which we can no longer be certain of the locations of any mines. But don't just click randomly! Using some basic probability concepts and a variation on the matrix analysis approach, we can navigate through the treacherous situation. To begin with, note that the bottom row of revealed squares is made up of 1's, 2's, and a 3. We will first eliminate the most dangerous choices - highlighted in green are the squares adjacent to the 3 and one of the 2's. We can easily see that there is 50% chance of hitting the mine by clicking adjacent to the 2 and a 67% chance by clicking adjacent to the 3! We want much better chances than that.
A good key to Minesweeper is to look to any unrevealed squares around a 1 first. In fig. 4 we have a streak of three of them! Now in any of the adjacent squares to these 1's, there is only a 33% chance of hitting a mine with a random click - a lot better than 50% or 67%. But we can use another technique to better our chances even further! Note that the triplets of adjacent squares to the 1's are outlined in boxes and that certain squares are included in only one box, whereas other squares are included in more boxes. A secret about Minesweeper is that some versions are written so that the MOST logical choice is a correct choice. Notice that the square directly beneath the middle 1 is contained in all three of the boxes. Minesweeper is more likely to have set this square as the mine than any of the others. Further analysis is required to determine to what extent this property effects the actual probability, however. For now, though, we mark this square as a mine and continue on.
Godspeed!
Now you are equipped with the know-how to maximize your mine-sweeping potential. I certainly hope that you have found this hub to be informative and enjoyable, and as always I encourage comments and feedback. Thanks for reading and good luck!
CommentsLoading...
I hope so! Lately I've been getting unlucky, hitting bombs on the first or second guess... but I'm sure practice will help me out (I mean not with random guessing but you know).
Hey a similar thought process occurs in Sudoku, if I'm not mistaken? You should make a Hub for that, I'm sure it'd help people out!
I just liked it mathcguy. I always do maths for pure fun. I also enjoy minsweeper so much. I normally deduce by using that one square unrevealed which must then contain the bomb then form another three by three set of squares containing the one I already know to contain the bomb such that the centre square shows a 1 then feel the rest like a piece of cacke. I never knew that it has something to do with matrices and probability. I always look until I am completely certain.
I was very glad when I suceeded teaching a young boy the game. Latter, he feeled the beginners one in 30 seconds! It took me long to beat him!








mrpopo 13 months ago
A fun game to play. I like the probability technique, that hadn't occurred to me before. Will try it in the future!
Thanks for a great Hub!