I am trying to calculate the odds, for every square (Except M or Q) of a mine being there, without knowing the total mines on the board.
I've found 2 different formulas online, which are similar except for one portion & although produce the same number for some sections, a very different answer is given for sections of the board. For example, the blue section I have 2 different answers for.
As you can see I've split up the squares into logical sections, where the probability will be the same.
For better explanation, the board looks like this:
ABCDE
F3G1H
IJ1KL
MNOPQ
The sections, broken up by the number they 'touch':
Section # of bombs in section:
------- ----------------------
(A+B+C+F+G+I+J) = 3
(C+D+E+G+H+K+L) = 1
(G+J+K+N+O+P) = 1
Note: that I am using the # of bombs to mean the number of bombs contained inside the squares. For example, The green section (A+B+F+I) are 4 squares. At most 4 squares can have 4 mines (1 mine per square). In our case green cannot contain 4 mines though, because of the '3'.
Further broken up, Here we get the sections you see in the image. By breaking up sections when we know which squares will give the same odds. I will call these the 'known solutions', or 'absolute solutions' (The right column is the # of bombs inside all of the squares combined):
(A+B+F+I) + (C) + (G) + (J) = 3
(G) + (C) + (D+E+H+L) + (K) = 1
(J) + (N+O+P) + (K) + (G) = 1
Here we calculate all of the possible solutions.
We do this by making assumptions. First we assume (C) has 1 bomb. In other words, the 'C' square is a bomb. (C is chosen at random, but I prefer to start with a small section). I'll call the first solution 'A1-1':
(C) = 1
Since (C) = 1, and ((G) + (C) + (D+E+H+L) + (K)) = 1, we know that (G), (K) and (DEHL) are must be 0:
(G) = 0
(D+E+H+L) = 0
(K) = 0
But now we need to make another assumption. I chose (J) = 1. Again, I prefer starting with small sections. This gives us an entire solution (A1-1):
Grouping # of bombs
-------- -----------
(C) = 1
(D+E+H+L) = 0
(K) = 0
(G) = 0
(J) = 1
(N+O+P) = 0
(A+F+I+B) = 1
I'll keep assuming (C) is 1 until we've come up with every solution (Note the 'absolute solutions' must always hold true, since that's how Minesweeper works, and we want to utilize what we know:
(a1-2) # of bombs
---- ----------
(C) = 1
(D+E+H+L) = 0
(K) = 0
(G) = 0
(J) = 0
(N+O+P) = 1
(A+F+I+B) = 2
That's all for C = 1, so next we assume G=1:
a2-1 # of bombs
---- ----------
(C) = 0
(G) = 1
(D+E+H+L) = 0
(K) = 0
(N+O+P) = 0
(J) = 0
(A+F+I+B) = 2
a2-2
----
(C) = 0
(G) = 0
(J) = 1
(A+F+I+B) = 2
(N+O+P) = 0
(D+E+H+L) = 1
(K) = 0
a2-3
----
(C) = 0
(G) = 0
(J) = 0
(K) = 1
(D+E+H+L) = 0
(A+F+I+B) = 3
(N+O+P) = 0
a2-4
----
(C) = 0
(G) = 0
(J) = 0
(K) = 0
(D+E+H+L) = 1
(A+F+I+B) = 3
(N+O+P) = 1
That gives us every solution.
Now we list the number of bombs in every possible solution:
Note that: (A+F+I+B) is Green, (C) is Pink, (D+E+H+L) is orange, (G) is brown, (J) is Yellow, (K) is Purple (N+O+P) is blue:
#: 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
Now we calculate the combinations possible for every solution. This is done by using nCr (Binomial coefficient).
Where N = Number of Squares and B = numberOfBombs.
Combinations = N NCR B.
For the first solution (A1-1) these are the combinations:
(GREEN) = 4 NCR 1 = 4
(PINK) = 1 NCR 1 = 1
(ORANGE) = 4 NCR 0 = 1
(BROWN) = 1 NCR 0 = 1
(YELLOW) = 1 NCR 1 = 1
(PURPLE) = 0 NCR 1 = 1
(BLUE) = 3 NCR 0 = 1
Multiplying these combinations we get: 4*1*1*1*1*1*1 = 4 combinations for this solution (A1-1).
Doing the same for all solutions we get:
#: 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
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.
Now for the part that I am conflicted on. I choose 'Blue' to demonstrate, since I am getting a different answer using either method.
Method 1:
For each solution take the number of mines divided by the number of squares (3) and multiply by the combinations:
A1-1 A1-2 A2-1 A2-2 A2-3 A2-4
(0/3*4) (1/3*18) (0/3*6) (0/3*24) (0/3*4) (1/3*48)
Adding those numbers up (Taking away the 0's to make it easier):
(1/3*18) + (1/3*48) = 22.
Now divide by the total combinations (104):
22/104 = 0.212.
However there are 3 squares, so we can divide by 3 if we want the odds of a single square in the section:
0.212/3 = 0.0705
Method 2
Multiply the total combinations for the non-zero values (48 + 18), divide by the total combinations (104):
1*66/104 = .635.
Again we can divide by 3 if we want the odds of a single square:
.635/3 = .212
So, are my odds for hitting a mine on any given blue square .212%, .0705%, or something else?
