Calculating odds of Minesweeper is this correct

combinationscombinatoricsprobability

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):

enter image description here

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):

enter image description here

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?

Best Answer

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.

Related Question