Minesweeper Probability Solver, Explained
After reading this you will know how a minesweeper position turns into an exact mine probability for every hidden cell, why some open-territory clicks beat the frontier, and how to read the heatmap so you guess where the odds are best.
What the solver does, with one example
Minesweeper looks like luck near the end, but most positions carry more information than your eye extracts. The solver rebuilds your board, reads every revealed number, and reports the exact probability that each hidden cell hides a mine. Not a simulation, not an estimate: a true posterior given the total mine count.
Here is the hook. Suppose one revealed 1 sits next to two hidden cells, and elsewhere a revealed 1 sits next to three hidden cells. Both regions contain exactly one mine. In the first region each hidden cell carries probability 1/2 = 0.5. In the second, each carries 1/3 \approx 0.333. Same clue value, different odds. Your gut treats both as "a 1", but the correct click is any cell touching the second number. The solver makes that difference explicit, cell by cell.
When to use it, and when not
Use it when you are genuinely stuck: no cell is provably safe, and you must guess. That is exactly when human intuition fails, because the safe-looking cells are often the dangerous ones. Use it also to check your own logic after a game, to learn which deductions you missed.
Do not reach for it while cells remain that basic logic already settles. If a revealed 1 already touches one flagged mine, every other neighbor is safe, and you do not need probability to see that. The solver will confirm it (those cells read 0%), but you should train the pattern by hand first.
Always clear the 0% cells and flag the 100% cells before you spend a single guess. Those are logical certainties, free information that changes the counts on every remaining cell.
The formula and the intuition behind it
Split the hidden cells into two kinds. Frontier cells touch at least one revealed number. Interior cells touch no number at all. The frontier is constrained; the interior is not.
The solver enumerates every mine layout that satisfies the frontier constraints. Each layout uses some number of mines m on the frontier, which leaves M - m mines to scatter across the U interior cells. The number of ways to do that scattering is a binomial coefficient, and that count is the weight of the layout.
Here L is one consistent frontier layout, m(L) is how many mines it places on the frontier, M is the total mine count you entered, and U is the number of interior cells. A layout that leaves more mines for a large interior counts for far more than one that leaves few, because there are simply more ways to fill the interior.
The probability that a given frontier cell holds a mine is the weighted fraction of layouts in which that cell is a mine.
The numerator sums the weights of layouts where the cell is a mine; the denominator sums the weights of all consistent layouts. For an interior cell the probability is the expected leftover mine count divided by U: average M - m(L) over all layouts, then divide by the number of interior cells.
One practical detail makes this fast: independent regions of the frontier are solved separately and combined, so a board with three unconnected clusters is three small enumerations, not one giant one.
A worked example using the demo board
Reproducing the default position
Load the demo and you get a small position with a total mine count set, a few revealed numbers, and the rest hidden. The reasoning below uses a clean version of that shape so you can follow every count.
Take a 4-by-4 board, 3 mines total, with two revealed clues in the top-left corner. A 1 borders two hidden cells, call them A and B. A separate 2 borders three hidden cells C, D and E. The remaining 8 cells are interior, touching no number.
- Region 1 (the
1) needs exactly one mine among A and B. Two layouts: {A} or {B}. Each places1mine. - Region 2 (the
2) needs exactly two mines among C, D, E. Three layouts: {C,D}, {C,E}, {D,E}. Each places2mines. - Combine the regions. Total frontier mines range from
3(1 + 2). Since M = 3, that leaves M - m = 0 mines for the interior in every combined layout. - Interior weight is \binom{8}{0} = 1 for every layout, so all 6 combined layouts (2 times 3) carry equal weight.
- Cell A is a mine in half the region-1 layouts, so P(A) = 1/2 = 0.5. Each of C, D, E is a mine in two of the three region-2 layouts, so P(C) = 2/3 \approx 0.667.
- Interior cells hold 0 mines here, so each reads 0/8 = 0. Every interior cell is proven safe.
The lesson: with all 3 mines forced onto the frontier, the wide-open interior is completely safe, and the safest click is not on the frontier at all.
How the interior density shifts with the mine count
Change the total mine count and the interior stops being free. Keep the same two clues, but set M = 5. Now the frontier still holds exactly 3 mines in every layout, so M - m = 2 mines must land in the interior. Each interior cell then carries 2/8 = 0.25. That is lower than the frontier cells (0.5 and 0.667), so a blind interior click is still the best move, but it is no longer risk-free.
The relationship is linear in the leftover count. With k leftover mines spread over 8 interior cells, each cell reads k/8. Move the slider below and watch the interior density climb while the frontier odds stay fixed by the clues.
Reading and interpreting the heatmap
The output colors each hidden cell by probability. Read it in this order.
- Green (0%)
- Proven safe. Click every one before anything else. These are deductions, not guesses.
- Red (100%)
- Certain mine. Flag it. A flag turns a hidden cell into a known constraint and often forces new 0% cells nearby.
- In between
- The true percentage. When you must guess, pick the lowest number on the whole board, whether it sits on the frontier or in the interior.
Compare the frontier minimum against the interior value directly. If the best frontier cell reads 30% and the interior reads 22%, click the interior. If the interior reads 40% because the board is dense with spare mines, take the 30% frontier cell instead. The color is a shortcut; the number is the decision.
Common mistakes
The most expensive error is treating equal clue values as equal risk. A 1 on two cells (50%) is twice as dangerous per cell as a 1 on four cells (25%). Count the hidden neighbors, not the clue.
A second mistake is ignoring the total mine count. Probability near the frontier depends on how many mines remain for the interior, so an incorrect total corrupts every number. Enter the board's real mine count and subtract nothing for flags you already placed if the tool expects the original total; check the field label.
A third is guessing before clearing certainties. Every 0% click and 100% flag you take first rewrites the constraints and can turn a 40% frontier into a 0% one. Solve the free cells, then re-read the board.
A fourth applies to huge positions. Very large connected constraint regions (over 40 linked cells) are refused rather than freezing your browser, because exact enumeration of such a region is astronomically expensive. Real games almost never build a single connected frontier that large; if you hit the limit, clear a safe cell to break the region into smaller independent pieces.
Related solvers on this site
If you like exact-reasoning puzzle tools, several neighbors use the same honest, deduction-first approach. The Sudoku Solver names the human technique behind every move. The Nonogram Solver explains each deduced cell line by line. The Kakuro Solver spells out the sum-combination reasoning at every step. For word games, the Wordle Solver & Explorer ranks your best next guess, and the Scrabble Best Move Finder returns the highest-scoring legal plays from your rack.
Frequently asked questions
Is the probability exact or simulated?
Exact. Connected constraint regions are enumerated completely, and each layout is weighted by the binomial count of placing leftover mines on the interior. The percentages are true posterior probabilities given your total mine count, not a Monte Carlo estimate.
Why does a far-off empty cell show a nonzero percentage?
Interior cells that touch no number still hold their share of the leftover mines. If 2 mines must land somewhere in 8 interior cells, each reads 25%. That density is often lower than the frontier, which is why a random-looking click into open space is sometimes the best move.
Does clicking a safe cell change the other probabilities?
Yes. Every revealed cell adds a constraint (or removes a hidden cell from the count), so re-enter the board after each certain move. A 40% frontier can collapse to 0% once a neighboring green cell is opened.
What if two cells tie for the lowest probability?
Either is an equally good guess by the numbers. Some players prefer the cell whose reveal is likely to expose the most new information, but on probability alone the tie is a true tie.
Why was my large board refused?
A single connected frontier of more than 40 hidden cells makes exact enumeration too slow to finish in the browser. Clear a proven-safe cell to split the region, then run the solver on the smaller pieces.