9

I need help on this, ignore if its already answered.

Ok so today i was wondering, could you get a $8$ in minesweeper and how rare it is?

All i know is that it will be rare. Very rare indeed. I dont really know how to say it. Its so annoying to be honest (tbh). I also dont know what you'd need to answer, so its complicated, well, because of that. If your answering, it might be hard.

Oh, i probably dont know but heres a predicted formula of how rare it is

First, this variable.
p8 = How rare it is to get 8 mines forming a hole like below. X = empty / O = mine
O O O
O X O
O O O
Rc = How rare it is to randomly click inside a patch that has minesweepers all directions you look, using the same
example as the square mines forming a hole in the middle (This means there is no middle mine therefore)
And then, the predicted formula below. It isnt advanced so you could make a better formula. It would please  me.
p8 ÷ Rc = 8r
Forgot to mention. 8r = formula result

So yeah. Not much to explain because im new to stack exchange. Anyways, the end of this probably.

  • 1
    That depends on how many bombs there are in how large a plot, and whether all placements are equally likely. ¶ At any rate, this turns out to be a rather tricky problem; I suspect that the most effective approach practically (except for the smallest boards) will be simulation. – Brian Tung Jul 27 '20 at 19:48
  • To properly answer this, a number of clarifications need to be made about the current board state, rules, and distribution of mines. For instance, in the official minesweeper game (not clones of the game) the first move always will have no mines surrounding it, guaranteeing at least nine squares be revealed if it were performed in the center. The positions of the mines aren't determined until after you have made your first selection. Imagine if you will then a $5\times 5$ board with $16$ mines following these rules. By placing in the center, you guarantee the probability of an 8 is $0$ – JMoravitz Jul 27 '20 at 19:49
  • And on how the bombs (actually, mines) are arranged. When I play the built-in Expert level I find I always have to guess a mine location. I do not expect that to be consistently true unless there is some bias in the way the mines are put in when you hit the first square. – Oscar Lanzi Jul 27 '20 at 19:51
  • With enough rule-changes and simplifications to the problem... we could eventually arrive at something like a hypergeometric distribution. The problem is similar to that of drawing nine balls in sequence out of a bag with $M$ red balls (representing mines) and $S$ white balls (representing safe spaces) without replacement and asking if the first (representing the middle space) is white while the remaining $8$ are all red. That is $\dfrac{S\binom{M}{8}}{9\binom{M+S}{9}}$, but this ignores a lot of the nuance of the true rules – JMoravitz Jul 27 '20 at 19:56
  • I've been playing the expert mode of this game for over 20 years. I don't remember getting an eight in either a lost game or a game I won. I got this one today and won the game. – Richard King Sep 30 '21 at 01:19

2 Answers2

6

It depends on the size of the grid and the number of mines. In the version of Minesweeper that comes with Windows, the options are:

Easy: $9\times9$ grid with $10$ mines ($\approx 12.3\%$ of the squares have mines)

Intermediate: $16\times16$ grid with $40$ mines ($\approx 15.6\%$ of the squares have mines)

Expert: $30\times16$ grid with $99$ mines ($\approx 20.6\%$ of the squares have mines)

In the easy grid, there are $\binom{81}{10}$, which is about $1.88$ trillion, ways to distribute the mines.

None of the border squares can be surrounded by $8$ mines, only squares in the middle $7\times7$ portion of the grid can possibly be an $8$.

Suppose the upper left square in the middle $7\times7$ grid is surrounded by $8$ mines. Then there are $81-9=72$ squares left to place the remaining $2$ mines. That can be done in $\binom{72}{2}=2556$ ways.

Thus each of the $7\times7=49$ non-border squares has $2556$ ways to be surrounded by $8$ mines. I don't think I double counted any arrangements, but maybe I am overlooking something.

We have $49\times2556=125244$ ways for an easy grid to have an $8$ somewhere. Out of the $1.88$ trillion total easy grids, this gives a probability of about $6\times10^{-8}$. So, very rare indeed!

Working out the probabilities for the bigger boards would be trickier due to the possibility of over-counting, though as the proportion of mines in the grid increases, the likeliness of an $8$ also increases. Also, people in the comments have pointed out other intricacies in the rules of the game on Microsoft that may change the true probability. Interesting question though!

DreiCleaner
  • 1,497
1

We can estimate the probability by instead computing the expected value; this is much easier due to linearity of expectation, and it's going to be close to the probability (but a slight overestimate) because the error between the two scales roughly like the probability of getting at least two $8$s, which is even smaller.

Here is how the calculation goes. If we distribute $k$ mines on an $m \times n$ grid, there are $(m-2)(n-2)$ possible $3 \times 3$ blocks, and the probability that any particular $3 \times 3$ block has an $8$ in the center is

$$\frac{ {mn-9 \choose k-8} }{ {mn \choose k} } = \frac{(mn-k)k(k-1) \dots (k-7)}{mn(mn-1)\dots(mn-8)}$$

(the numerator counts the number of ways to distribute $k-8$ mines among the squares not in the $3 \times 3$ block, and the denominator is the total number of ways to distribute $k$ mines among all the squares in the grid), so the expected number of $8$s on the grid is

$$\boxed{ (m-2)(n-2) \frac{ {mn-9 \choose k-8} }{ {mn \choose k} } }.$$

This is a slight overestimate of the probability of getting an $8$. It may be a little hard to tell how big this is, but as long as $m, n, k$ are not too small it is approximately $(m-2)(n-2) (1 - p) p^8$ where $p = \frac{k}{mn}$ is the density of mines, or equivalently the probability that any given square contains a mine. This is the expected value we would calculate if mines were distributed independently with probability $p$: this gives almost the same distribution over mine locations as distributing a fixed number of mines in general, although the two will differ more the smaller $m, n, k$ are.

Now let's calculate:

  1. On easy we have $m = n = 9, k = 10$, which gives $7^2 \frac{ {9^2 - 9 \choose 2} }{ {9^2 \choose 10} } = \boxed{ 6.7 \times 10^{-8} }$ expected $8$s. This is very close to DreiCleaner's answer but slightly bigger, as it would have to be.

  2. On intermediate we have $m = n = 16, k = 40$, which gives $14^2 \frac{ {16^2 - 9 \choose 32} }{ {16^2 \choose 40} } = \boxed{ 3.2 \times 10^{-5} }$ expected $8$s. The expected number has gotten bigger, both because the grid is bigger and because the density of mines is higher.

  3. On expert we have $m = 30, n = 16, k = 99$, which gives $28 \times 14 \frac{ {30 \times 16 - 9 \choose 91} }{ {30 \times 16 \choose 99}} = \boxed{ 8.2 \times 10^{-4} }$ expected $8$s. So it's gotten bigger again.

So $8$s are rare but not astronomically rare. The expected number on expert is a bit less than one in a thousand, so if you played one game of expert a day you'd expect to get one every $3$ years or so. That's assuming you actually get to see it, since $8$s are not exactly easy to find even if they are on the grid!

Generally speaking, for rare events like this which can happen in many different ways which are almost but not quite independent, the distribution of the number of events is asymptotically Poisson. What this means is that if $\lambda$ is the expected number of events, which we calculated exactly above, then the probability that at least one event occurs is

$$1 - e^{-\lambda} \approx \lambda - \frac{\lambda^2}{2} + O(\lambda^3).$$

This is a way to make more precise the claim I made above that the error between the probability and the expected value scales roughly like the probability of getting at least two $8$s; in other words all of the above estimates are quite close, with errors roughly half their square.

Edit: These calculations are verified via simulation in this Youtube video, starting around 9:33. He gives $\frac{1}{p}$ instead of the probability and uses $8 \times 8$ for the size of the beginner board but it's easy to adjust for these changes.

Qiaochu Yuan
  • 419,620
  • I am ignoring the rule subtleties mentioned in the comments; on a large enough grid they shouldn't matter very much anyway. – Qiaochu Yuan Oct 27 '22 at 19:47