# Calculating odds of Minesweeper is this correct?

## EDIT

Please see new question: Calculating Minesweeper Odds Is this calculation correct?

The answers here helped me create the new question (The post below has some errors which makes it harder to review)

## The below question is only kept for historical purposes.

So I originally asked this question here, given that the number of mines was unknown.

However user2661923 pointed out that the 104 different possibilities do not have an equal weight.

For example, having 4 mines in total is more likely than having 5 mines in total. We know this without knowing the total mines because in Minesweeper there are always a greater number of unmined cells than mined cells.

See this question & answer for a detailed explanation as to why the 104 combinations are not all equal weight

## Problem

I want to calculate the odds of hitting a mine in any of the spaces. I will apply my original calculation & the new information to this board where the number of mines is known (25):

N = number of mines = 25.

T = number of unidentified squares = 124

ABFI,B,C..NOP,RSTUVWXY (All labeled squares minus M & Q) I'll refer to as Section1

The grey squares (including M & Q) I'll refer to as Section2

I've broken up the board into colour groups based on the probabilities. Every square in the green group will have the same probability. Every square in the grey group will have the same probability and so on.

We know this based on the numbered squares the square is touching. For example, 'A' & 'B' both touch a '3'. There is no reason 'B' would have different odds than 'A'.

I've labeled the board for my own sake, to be able to refer to the squares of interest (M & Q are not interesting, they are part of section2 I just wanted a square of marked squares)

Based on this we know:

Section1 can have 4, or 5 or 6 mines.

Section2 can have 21, 20, or 19 mines. (Remember section2 is 'the rest' aka gray squares)

I'll refer to what we know as 'Rules'. We know the total number of mines surrounding a '1' must equal '1'.

Rules:

ColorGroups                          # of bombs in ColorGroups
-----------                          ----------------------------
(A+B+F+I) + (C) + (G) + (J) =        3
(D+E+H+L) (C) + (G) + (K)   =        1
(N+O+P) + (J) + (K) + (G)   =        1
(R+S+T+U+V+W+X+Y)           =        1


Before collecting every possible combination, Let's look at the formula for assigning weights (Found in the 'question & answer' linked at the top, Credit to user Joriki in the linked answer):

m = remaining mines (25)
t = remaining unidentified squares (124)
n = mines assigned
s = assigned squares


Let's assume Section1 has 4 mines (Section2 must have the remaining 21):

m = 25
t = 124
n = 4
s = 23 (Remember M & Q are not part of this section).

124 - 23 = 101
25 - 4 = 21
101 ncr 21 = 2577824781465941808570


Assuming Section1 has 5 mines:

m = 25
t = 124
n = 5
s = 23

124 - 23 = 101
25 - 5 = 20
101 ncr 20 = 668324943343021950370


Finally, assuming Section1 has 6 mines:

m = 25
t = 124
n = 6
s = 23

124 - 23 = 101
25 - 6 = 19
101 ncr 19 = 163006083742200475700


Calculating all of the possibilities (I refer to these as 'Scenarios') the same way we've done in the original post tells us there are 6 different possibilities for Section1:

#:      A1  A12 A21 A22 A23 A24
GREEN:  1   2   2   2   3   3
PINK:   1   1   0   0   0   0
ORANGE: 0   0   0   1   0   1
BROWN:  0   0   1   0   0   0
YELLOW: 1   0   0   1   0   0
PURPLE: 0   0   0   0   1   0
BLUE:   0   1   0   0   0   1
RED:    1   1   1   1   1   1
Total:  4   5   4   5   5   6


Note: I described & listed all scenerios in the original post.

As done in the original post, taking the NCR for all combinations (Adding Red here, gives us the same result since Red is always 1):

#:      A1  A12 A21 A22 A23 A24
GREEN:  4   6   6   6   4   4
PINK:   1   1   1   1   1   1
ORANGE: 1   1   1   4   1   4
BROWN:  1   1   1   1   1   1
YELLOW: 1   1   1   1   1   1
PURPLE: 1   1   1   1   1   1
BLUE:   1   3   1   1   1   3
RED:    1   1   1   1   1   1
TOTALS: 4   18  6   24  4   48

Total combinations = 104


Note: In the above table, to get 'TOTALS' we multiply all combinations to get the total combinations for that solution.

Tallying up the number of mines for the known sections we see there are 1 scenerios where the sections contains 6 mines, 2 scenarios which have 4 mines and 3 that have 5 mines.

To normalize the weights:

3 * 2577824781465941808570 = 7.7334743e+21
2 * 668324943343021950370 = 1.3366499e+21
1 * 163006083742200475700 = 163006083742200475700

7.7334743e+21 + 1.3366499e+21 + 163006083742200475700  = 9.2331303e+21

2577824781465941808570 / 9.2331303e+21 = 0.279%
668324943343021950370 / 9.2331303e+21 = 0.072%
163006083742200475700 / 9.2331303e+21 = 0.018%


So, for each 'scenario' for section1, we can assign the weights:

4 mine scenarios weight = 0.279%
5 mine scenarios weight = 0.072%
6 mine scenarios weight = 0.018%


Since 'Section1' is nearly identical to the scenario in my last question I can take the results but apply the weights:

m (number of mines), divide by t (squares) times c (total combinations for the solution) multiplied by the weight (based on total mines for the solution. 4 is 0.279, 5 is 0.072, 6 is 0.018)

## A11

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (1/4 * 4) *  0.279    =  0.279
Pink   = (1/1 * 4) *  0.279    =  1.116
Orange = (0/4 * 4) *  0.279    =  0.00
Brown  = (0/1 * 4) *  0.279    =  0.00
Yellow = (1/1 * 4) *  0.279    =  1.116
Purple = (0/1 * 4) *  0.279    =  0.00
Blue   = (0/1 * 4) *  0.279    =  0.00
Red    = (1/8 * 4) *  0.279    =  0.14


## A12

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (2/4 * 18) * 0.072    =  0.648
Pink   = (1/1 * 18) * 0.072    =  1.296
Orange = (0/4 * 18) * 0.072    =  0.00
Brown  = (0/1 * 18) * 0.072    =  0.00
Yellow = (0/1 * 18) * 0.072    =  0.00
Purple = (0/1 * 18) * 0.072    =  0.00
Blue   = (1/1 * 18) * 0.072    =  1.296
Red    = (1/8 * 18) * 0.072    =  0.162


## A21

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (2/4 * 6)  * 0.279    =  0.837
Pink   = (0/1 * 6)  * 0.279    =  0.00
Orange = (0/4 * 6)  * 0.279    =  0.00
Brown  = (1/1 * 6)  * 0.279    =  1.674
Yellow = (0/1 * 6)  * 0.279    =  0.00
Purple = (0/1 * 6)  * 0.279    =  0.00
Blue   = (0/1 * 6)  * 0.279    =  0.00
Red    = (1/8 * 6)  * 0.279    =  0.2093


## A22

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (2/4 * 24) * 0.279    =  3.348
Pink   = (0/1 * 24) * 0.279    =  0.00
Orange = (1/4 * 24) * 0.279    =  1.674
Brown  = (0/1 * 24) * 0.279    =  0.00
Yellow = (1/1 * 24) * 0.279    =  6.696
Purple = (0/1 * 24) * 0.279    =  0.00
Blue   = (0/1 * 24) * 0.279    =  0.00
Red    = (1/8 * 24) * 0.279    =  0.837


## A23

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (3/4 * 4)  * 0.072     = 0.216
Pink   = (0/1 * 4)  * 0.072     = 0.00
Orange = (0/4 * 4)  * 0.072     = 0.00
Brown  = (0/1 * 4)  * 0.072     = 0.00
Yellow = (0/1 * 4)  * 0.072     = 0.00
Purple = (1/1 * 4)  * 0.072     = 0.288
Blue   = (0/1 * 4)  * 0.072     = 0.00
Red    = (1/8 * 4)  * 0.072     = 0.036


## A24

Colour   m/t * c      Weight      Result
------   ----------   ------      ------
Green  = (3/4 * 48)  * 0.018    = 0.648
Pink   = (0/1 * 48)  * 0.018    = 0.00
Orange = (1/4 * 48)  * 0.018    = 0.216
Brown  = (0/1 * 48)  * 0.018    = 0.00
Yellow = (0/1 * 48)  * 0.018    = 0.00
Purple = (0/1 * 48)  * 0.018    = 0.00
Blue   = (1/1 * 48)  * 0.018    = 0.864
Red    = (1/8 * 48)  * 0.018    = 0.108


Adding up all the results, then divding by 104 (total combinations) we get the result. Then divide by the number of squares in the section to get the probability per square:

Green:    5.976 / 104 = 0.057 / 4 = %0.0144
Pink:     2.412 / 104 = 0.023 / 1 = %0.023
Orange:   1.89  / 104 = 0.018 / 4 = %0.0045
Brown:    1.674 / 104 = 0.016 / 1 = %0.016
Yellow:   7.812 / 104 = 0.075 / 1 = %0.075
Purple:   0.288 / 104 = 0.003 / 1 = %0.003
Blue:     2.16  / 104 = 0.208 / 3 = %0.0069
Red:      1.4923/ 104 = 0.014 / 8 = %0.0018


This means brown has the best odds. In a real game, the player should click one of the squares surrounding the '1'. Is this logic right?

• Your 2nd link (i.e. "See this question & answer for a detailed explanation.") seems broken. If so, please edit it. Also, I upvoted because you nicely linked the other two queries to this one. Dec 5, 2019 at 2:43
• @user2661923 I fixed the link, it was broken Dec 5, 2019 at 2:49
• more editing needed, I think. "Let's assume Section1 has 3 mines (section1 always has 1 & section2 must have the remaining 21): " Shouldn't this read "...(Section2 always has 1 & Section3 must have the remaining 21):" Dec 5, 2019 at 2:54
• I could be mistaken, but I think that you have made a critical mistake. You can not assign weights to Section1 independent of Section2. See next comment. Dec 5, 2019 at 3:05
• In reading this question I realized a mistake I'd made in my answer to the other one. I've edited it accordingly. It's also relevant to this question. Sorry about that. I won't have the time today to look at this question in detail but will try to do so tonight or tomorrow. Dec 5, 2019 at 6:00

This is slightly unnecessarily complicated.

There are two partly identified sections on the board, and in the right-hand one (with the $$8$$ red squares) the total of mines is known to be $$1$$. Thus, each red square has probability $$\frac18=0.125$$ of containing a mine, and we can deduct this one mine from the total of $$25$$ mines and calculate the left-hand section using $$t=124-8=116$$ and $$m=25-1=24$$ in my answer to the other question (with $$s=15$$ and $$n=3,4,5$$ as before). Note the correction to that answer (which you didn't have a chance to take into account yet in this calculation).

Some errors in the post:

There are some percent signs where there shouldn't be any; all the numbers seem to be probabilities out of $$1$$, not out of $$100$$.

It's not generally the case that the player should click on the square with the lowest marginal probability of containing a mine. The optimal strategy also depends on future opportunities to gain information. For instance, in the extreme case, there's no use in clicking on a square, no matter how low its marginal mine probability, if you already know that you won't gain any information by doing so.

This is also not correct:

For example, having 4 mines in total is more likely than having 5 mines in total. We know this without knowing the total mines because in Minesweeper there are always a greater number of unmined cells than mined cells.

If you have a total of $$t=100$$ unidentified squares with $$m=20$$ mines in them, even though there are a lot more unmined cells than mined cells, if you assign mines to $$s=30$$ squares you'd expect about $$6$$ mines to be in those $$30$$ squares, and solutions with $$5$$ mines will be more probable than solutions with $$4$$ mines.

• Although the simplification detailed in your answer is accurate, I still have a moderate criticism of it; it requires somewhat more sophisticated intuition to grasp its validity. When the student's (e.g. the OP's) intuition is still evolving, I advocate a less elegant approach whose validity is easier to "wrap one's brain around." Then, after the fact, the student can consider your elegant simplification and ponder why it leads to the same answer. Dec 5, 2019 at 7:08
• I'm creating another question with the mistakes fixed, ill be linkkng it when finished Dec 5, 2019 at 23:01
• I've created a new question here: math.stackexchange.com/questions/3466402/… I used the suggestions from this answer, but simplified using user2661923's approach Dec 7, 2019 at 3:44

I would like to give a (somewhat long-winded) discussion of an excerpt from Joriki's answer.

$$\underline{\text{Excerpt}}$$

This is also not correct:

For example, having 4 mines in total is more likely than having 5 mines in total. We know this without knowing the total mines because in Minesweeper there are always a greater number of unmined cells than mined cells.


If you have a total of t=100 unidentified squares with m=20 mines in them, even though there are a lot more unmined cells than mined cells, if you assign mines to s=30 squares you'd expect about 6 mines to be in those 30 squares, and solutions with 5 mines will be more probable than solutions with 4 mines.

$$\underline{\text{Discussion}}$$

I agree with Joriki's analysis (excerpted above). However...

I regard the intuition around assuming that a region is more likely to have 4 mines than 5 as reasonable. The reason that it is in error in Joriki's example is that the region in his example is a relatively large percentage of the number of remaining unidentified squares.

Joriki's rebuttal was based on $$\;1/5 \times 30 = 6\;$$ and 6 is closer to 5 than 4. Based on this approach, one would guesstimate that if the region is 22 instead of 30, since $$\;1/5 \times 22 < 4.5\;$$, the chances of the region (of 22 unknown squares) having 4 mines would be slightly larger than the chances of this region having 5 mines.

Therefore, for a significantly smaller region, (e.g. a region significantly smaller than 22 unknown squares), 4 mines is more likely than 5 mines. So the assertion (i.e. 4 mines is more likely than 5 mines), will generally hold for smaller regions of unknown squares.

This is a (somewhat long-winded) reaction to part of the OP's revised post. My analysis only covers the query up to AND INCLUDING the following excerpt. I ask the OP to consider my reaction, and consider making another edit to his post. Then, I can (iteratively) examine the rest of his query.

$$\underline{\text{Excerpt}}$$

To normalize the weights:

3 * 2577824781465941808570 = 7.7334743e+21
2 * 668324943343021950370 = 1.3366499e+21
1 * 163006083742200475700 = 163006083742200475700

7.7334743e+21 + 1.3366499e+21 + 163006083742200475700  = 9.2331303e+21

2577824781465941808570 / 9.2331303e+21 = 0.279%
668324943343021950370 / 9.2331303e+21 = 0.072%
163006083742200475700 / 9.2331303e+21 = 0.018%


So, for each 'scenario' for section1, we can assign the weights:

4 mine scenarios weight = 0.279%
5 mine scenarios weight = 0.072%
6 mine scenarios weight = 0.018%


$$\underline{\text{My Reactions}}$$

1) As Joriki already indicated, equations like

2577824781465941808570 / 9.2331303e+21 = 0.279%


are confusing, because of the "%" sign. I would eliminate all percent signs from your query, altering equations as needed.

2) Instead of defining $$104 \times 8 = 832$$ cases, you stuck with 104 cases, capitalizing on the fact that the RSTUVXYZ cells always collectively have 1 mine. This approach is doable but somewhat dangerous, since your intuition is evolving. The rest of my reaction (below) accepts your use of 104 cases, instead of 832 cases.

3) The math you are using is somewhat messy. I would advise labeling your weights as $$\binom{101}{21}, \binom{101}{20}, \;\text{and}\; \binom{101}{19}.$$ Eventually you will convert to relative weights, so you will avoid messy math. Unfortunately, it is premature to discuss relative weights, because of the issue in my next point (below). After you have edited your query, I will return to the issue of relative weights.

4) If I am not misinterpreting the Excerpt from your query, you are confused about how to assign the weights. You have delineated 104 cases: one of the weights [i.e. $$\;\binom{101}{21}, \binom{101}{20}, \;\text{or}\; \binom{101}{19}]\;$$ should be assigned to each of the 104 cases. In each of the 104 cases, the weight assigned will depend on how many mines are assigned to Section1 in that case.

Assume that case 1 is assigned W1 (i.e. the weight for case 1), case 2 is assigned W2 (the weight for case 2), ..., case 104 is assigned W104. Here, each of W1, W2, ..., W104 is one of the 3 values : $$\;\binom{101}{21}, \binom{101}{20}, \;\text{or}\; \binom{101}{19}]\;$$.

Let SUM_OF_WEIGHTS = W1 + W2 + ... + W104.
Let x be any integer in {1, 2, ..., 104}.

Then the probability of Case x is

{Wx : the weight assigned to case x} / {SUM_OF_WEIGHTS}.

Note that under this definition, the
(probability of case 1) + (probability of case 2) + ... + (probability of case 104) = 1.

5) Deferred issues until your posting is edited:

5a) Converting to relative weights to avoid messy math.

5b) Taking the next step in the analysis: once you assign a probability to each of the 104 cases, you then have to decide how to use this information to decide which minesweeper cell to click on. Analysis for taking the next step will probably be so complex as to defy using mathematics. You will probably have to merely consider what factors are relevant and then make an intuition-based judgement call.

• @dustytrash Partial reaction given to your posting - see my answer. Dec 5, 2019 at 19:12
• "This approach is doable but somewhat dangerous, since your intuition is evolving" My original post (before the edit) uses 104 cases. I don't believe it's complicated to consider the 8 squares will always have 1 mine (104 cases) Dec 5, 2019 at 19:19
• @dustytrash "...I don't believe it's complicated...". Reasonable reaction. My unspoken point is that if the righthand portion of Section1 (i.e. involving cells RSTUVXYZ) was more complicated, then you would need to understand how to design cases, so that each case specified a possible set of mine assignments, with the assignments spanning all of Section1. Dec 5, 2019 at 19:26
• @dustytrash "...I'm conflicted on editing my question...". Very good point. Assuming that you agree with the need for significant editing, I would : 1) Carefully prepare an edited query. 2) Then start a new query (new posting), which provides a link to this query (this posting) and which contains your revisions. 3) Then add a very brief addendum to the end of your query in this posting, where you explain the situation and add a link to the next query. Dec 5, 2019 at 19:28
• @dustytrash a moderate alternative to my last comment: because your query in this posting is so long many readers will not see your addendum. Instead, I recommend Starting this query, with an explanation and the link to the next query, then putting in a long "-----------------------" line, and below that leaving the query as is perhaps with a caption like ("Original query - posting retained for historical purposes"), or some caption like that, with the caption being in your own words. Dec 5, 2019 at 19:45