Minesweeper Guide

Open a few squares first. When you run out of certain moves, press the button and every hidden square gets its exact mine probability.

Minesweeper Solver

Every Minesweeper game eventually reaches a position where no amount of staring will produce a certainty. The patterns are exhausted, every number is satisfied, and there are still covered squares. At that moment most players click something that *feels* safe and hope.

This page replaces the feeling with a number. Play the board above, and when you run out of deductions, press Show mine probabilities. Every hidden square gets labelled with its exact chance of hiding a mine: green for the squares that are provably safe, red for the ones that are provably mined, and a colour ramp in between for everything genuinely uncertain.

The solver behind it is open source and MIT-licensed: aijobclub/minesweeper-solver. The same file that runs in your browser on this page is the file in that repository — no server, no API call, no account. Your board never leaves the tab.

How to use it

  1. Play normally. Open squares, place flags, chord the numbers you've satisfied. The solver reads flags as claims that a mine is there, so wrong flags will produce wrong answers — more on that below.
  2. Get stuck. You'll know: you've checked every number against its neighbours and nothing new falls out.
  3. Press the button. Every covered square is labelled at once.
  4. Click a green square if one exists. Green means probability zero. Not "probably fine" — zero. If any green square is on the board, you have not actually run out of logic yet, and you should never be guessing.
  5. If nothing is green, click the lowest number. That's the best available guess, and the note under the board names the exact square so you don't have to hunt for it.

Press the button again to turn the overlay off. It refreshes automatically as you play, so you can leave it on and watch the numbers move as each new square resolves.

The button is deliberately inert before your first click. On an untouched board every square carries identical odds — 10 mines over 81 squares on Beginner — and showing 81 identical numbers would tell you nothing about where to click. The information only exists once there are numbers on the board to constrain it.

Why "how many mines are left" changes the answer

This is the part that separates a solver you can trust from one that will quietly kill you, and it is worth understanding even if you never use a solver again.

Here is a small board. Two clues, three rows, five columns, and the mine counter says exactly one mine remains:

?  1  ?  ?  ?
        ?  ?  ?  ?  ?
        ?  ?  ?  1  ?

Each 1 needs exactly one mine among its neighbours. There is precisely one square adjacent to *both* clues — the square at column 3, row 2, dead centre between them. With only one mine left on the entire board, that single mine has to satisfy both clues simultaneously. So the centre square is a guaranteed mine, and every other square on the board is guaranteed safe.

Now watch what a naive solver does with the same position. It enumerates the ways mines can sit on the frontier, treats each arrangement as equally likely, and reports:

.24  1  .24  .24  .24
        .24 .24  .06 .24  .24
        .24 .24  .24  1   .24

That .06 is the centre square — the certain mine. The naive solver rates it at 0.0588, the lowest number on the board, and would confidently recommend clicking the one square that is guaranteed to end your game. It is not slightly wrong. It is maximally wrong, and it is wrong in the most dangerous possible direction.

The mistake is treating every frontier arrangement as equally likely. They aren't. An arrangement that uses one mine and an arrangement that uses two mines leave different numbers of mines to be distributed among the squares no clue touches, and the number of ways to do *that* is a binomial coefficient that swings enormously. If 30 untouched squares must absorb the leftovers, arrangements leaving one mine are weighted C(30,1) = 30, and arrangements leaving two are weighted C(30,2) = 435. Calling those equally likely is off by more than an order of magnitude.

The solver on this page weights every arrangement by exactly that factor. On the board above it returns 1.0 for the centre square and 0.0 everywhere else — which is simply the truth.

The practical lesson generalises past this toy position: read the mine counter before you guess. The strategy page works the same idea by hand, showing how the remaining-mine count turns an apparent coin flip into a free move. The solver is that habit, automated and made exact.

How the probabilities are computed

Four steps, no machine learning, no heuristics, no lookup tables — just counting.

Extract the constraints. Every revealed number becomes one linear constraint: "exactly *k* mines among these specific covered squares," where *k* is the printed number minus the flags already touching it. A 3 with one flag and four covered neighbours becomes "exactly 2 mines among these 4 squares." Squares with no covered neighbours constrain nothing and are dropped.

Split into independent components. The constraints form a graph — two constraints are connected if they share a covered square. A late-game Expert board might have a frontier of 50 covered squares, which is 2^50 arrangements if you tackle it whole, but it almost always breaks into separate clusters of 5 to 15 squares that share nothing. Those clusters are statistically independent and can be enumerated separately. This decomposition is the difference between instant and never.

Enumerate each component exactly. Within a component, walk every assignment of mine/no-mine that satisfies every constraint, using the constraints themselves to prune branches the moment they become impossible. Crucially, the tally is kept *split by mine count*: not just "how many valid arrangements exist" but "how many valid arrangements use exactly *k* mines," for each *k*. Collapsing that into a single total is precisely the bug described in the previous section.

Recombine under the global mine budget. Convolve the per-component tallies to get the number of arrangements using *T* mines across the whole frontier, weight each *T* by C(*U*, *R* − *T*) — the number of ways the leftover mines fit into the *U* squares no clue touches — and normalise. That final weighting is what makes the numbers correct rather than merely plausible.

A useful consequence falls out of step four for free: the squares in the untouched interior get a real probability too, not an "unknown." Sometimes it's the lowest one on the board. When the frontier is ugly and the interior is roomy, the safest click is often the one furthest from anything you know — a genuinely counterintuitive result that no amount of pattern recognition will surface.

When the solver says "estimate" instead

If a single connected component grows past 32 covered squares, exact enumeration stops being instant and the solver falls back to an iterative approximation. When that happens the overlay stops showing green and red entirely and says so in plain language, because an approximate 0.0 is not a proof and must never be painted the same colour as one.

This is rare on Beginner — measured across a thousand positions, it never happened. On Expert it's common, because Expert frontiers get genuinely large. In that mode, read the numbers as a ranking of bad options rather than as certainties: lower is still better, but nothing is guaranteed.

What a real 50/50 is, and why you can't dodge it

Some positions are unwinnable and no solver can fix them. The classic shape appears against a wall at the end of a game:

1  2  1
        ?  ?  ?

Two arrangements satisfy every clue. Either the outer two squares are mined, or the middle one is — and both remain consistent with every number on the board and with the mine counter. Nothing distinguishes them. The solver reports 0.50 for each square, and it is not being lazy: the information required to break the tie does not exist on the board. There is nothing to compute.

This is a property of the position, not a limitation of the software. Any solver claiming to resolve a true 50/50 is either using information you don't have or lying. On Expert boards, forced guesses like this are the single largest cause of losses among strong players, which is why win rate is a poor measure of skill and decision quality is a good one.

What the solver *does* buy you is the ability to tell a real 50/50 apart from a fake one. Most positions that feel like coin flips aren't — they're positions where the deduction is available but subtle, and the mine counter or a distant constraint quietly settles it. Those are the ones the overlay lights up green, and they are far more common than genuine ties. Learning to spot the difference is most of what separates a 15% Expert win rate from a 35% one.

Two things worth knowing about the timing of forced guesses. Guess early when you can see one coming: a coin flip on move 20 costs you a young board, while the same flip on move 200 costs a nearly finished Expert run. And check the mine counter first, every time, because the count is the single most frequently ignored piece of information in the game.

Flags are claims, and wrong claims poison the output

The solver treats a flag as an assertion that a mine is there, and it takes that assertion at face value. It has to — reading flags is what lets a partially flagged board solve correctly at all.

The cost is that one misplaced flag corrupts every number downstream of it. Worse, it can make the position *contradictory*: a set of clues that no arrangement of mines can satisfy. When the solver detects this, it refuses to output probabilities and says so, rather than inventing numbers for an impossible board. If you see that message, the fastest fix is almost always to remove the flags you're least sure about and press the button again.

You never actually need flags to win — the win condition is revealing every safe square, and flags are bookkeeping for humans. If you want the solver's cleanest reading, flag only what you've proven and leave the rest covered.

Where this fits

Use the solver as a check on your reasoning, not a replacement for it. The fastest route to a better win rate is still recognising the standard patterns — 1-1, 1-2-1, 1-2-2-1 — instantly and without deliberation, because those cover the overwhelming majority of real decisions and no tool is faster than seeing the answer. The probabilities matter for the handful of positions per game where pattern recognition genuinely runs out.

The most productive way to use this page is diagnostic. Play until you're stuck, form your own opinion about which square is safest, *then* press the button. When you agree, you've confirmed your reading. When you disagree, you've found a specific hole in your model — and that disagreement is worth more than the individual square, because it usually reveals a class of position you've been misreading all along. In my experience the disagreements cluster around exactly two things: forgetting the mine counter, and undervaluing the untouched interior.

If you want to know what the engine is doing between your clicks — how mines get placed after your first click, why the first click is always safe, and why some boards are unsolvable from the start — the how it works page walks through the implementation. The solver source, including the test suite and a set of worked examples, is at github.com/aijobclub/minesweeper-solver.