How the Minesweeper Solver Works: Constraints and Probability
Feed the Minesweeper solver a board you are stuck on and it does two very different jobs. First it finds every square it can prove is safe — or is certainly a mine — using pure logic. Only when logic runs out does it switch to computing the exact odds for each remaining cell. That split matters, because Minesweeper cannot always be won by logic alone: measured over complete games, a Beginner board is solvable without a single guess about 80% of the time, but an Expert board only 2% of the time.
Reading the Board as Constraints
Every revealed number is a small equation: "exactly this many mines sit among my hidden neighbours." The solver turns the board into a set of these constraints and applies two certainties:
- All clear. If a number's mine count is already met by flagged neighbours, every other hidden neighbour is provably safe.
- All mines. If a number's hidden neighbours are exactly as many as its mine count, every one of them is a mine.
Then it does the step most players do by eye without naming it — constraint subtraction. If one number's neighbours are entirely contained in another's, subtracting the two isolates a smaller group whose mine count is fixed, often revealing a safe cell or a mine that neither clue showed alone. Applying these rules in a loop, each new deduction feeding the next, is how it lights up whole regions as safe.
When Logic Runs Out: Exact Odds
Sometimes no cell is certain. Rather than guess blindly, the solver enumerates the arrangements — every way mines could be placed among the constrained cells that satisfies all the revealed numbers at once — and counts how often each cell holds a mine. That yields an exact probability per cell, so you can click the genuinely safest square. It is the difference between a coin-flip and a calculated risk.
How Often Can Logic Win Alone?
We drove the shipped solver through complete simulated games at each standard difficulty, letting it deduce and flag until either the board was solved or no certainty remained. The share of boards it cleared with zero guesses falls sharply as the mines get denser:
| Difficulty | Board | Mines | Solved with no guess | Avg guesses |
|---|---|---|---|---|
| Beginner | 9×9 | 10 | 80% | 0.25 |
| Intermediate | 16×16 | 40 | 52% | 0.86 |
| Expert | 30×16 | 99 | 2% | 3.42 |
The denser the mines, the more often logic hits a wall — and the more the solver's exact probabilities earn their keep. Expert boards almost always force at least one calculated guess.
Win Rate: How Often It Wins the Whole Board
No-guess solvability asks how often logic alone suffices. A different question is how often the solver, playing complete games and taking its best probabilistic guess whenever logic stalls, wins the entire board. Measured over 1,000 complete games at each standard difficulty, on classic board sizes with the first click guaranteed safe (the usual Minesweeper rule):
| Difficulty | Board | Mines | Win rate |
|---|---|---|---|
| Beginner | 9×9 | 10 | 95.5% |
| Intermediate | 16×16 | 40 | 85.6% |
| Expert | 30×16 | 99 | 36.2% |
1,000 complete games per difficulty, first click guaranteed safe. Expert Minesweeper is famously hard even for optimal play — the best-known solvers land in the ~34–40% range on classic 30×16 Expert with a safe first click, so 36.2% sits squarely in the expert-solver band. A materially higher figure usually reflects an easier rule, such as a guaranteed opening. Full per-difficulty data is published as the LK Forge Minesweeper Solver Benchmark dataset on Hugging Face.
Reproduce It Yourself
The engine is a DOM-free JavaScript file. Its analyze() takes a board state and returns provably safe cells, certain mines, and per-cell probabilities:
import fs from 'fs'; import vm from 'vm';
// grab the shipped engine: lkforge.com/tools/puzzles/js/minesweeper-engine.js
const ctx = {}; vm.createContext(ctx);
vm.runInContext(fs.readFileSync('minesweeper-engine.js','utf8') +
'\nglobalThis.LKMines = LKMines;', ctx);
const { newGame, analyze } = ctx.LKMines;
// build a state with some revealed numbers, then:
const r = analyze(state);
console.log(r.method); // 'deduction' | 'probability' | 'none'
console.log(r.safe, r.mines); // provably safe cells and certain mines
Frequently Asked Questions
Is there a Minesweeper solver?
Yes — this page's Minesweeper solver is a free in-browser tool. Enter the board you are stuck on and it highlights every provably safe cell, every certain mine, and the exact mine probability for the rest. No sign-up.
How does the Minesweeper solver find safe cells?
It reads each revealed number as a constraint on its hidden neighbours and combines them: a number that already touches all its mines makes its other neighbours safe; a number whose hidden neighbours equal its count makes them all mines. Subtracting overlapping constraints uncovers more. Only when no certainty remains does it fall back to probability.
Can Minesweeper always be solved without guessing?
No — about 80% of Beginner boards are solvable with pure logic, falling to 52% on Intermediate and 2% on Expert. The rest reach a position where no cell is certain, which is exactly when the solver's mine odds matter.
How does it calculate mine probability?
When logic stalls it enumerates the mine arrangements consistent with every revealed number and counts how often each cell is a mine, giving an exact probability so you can play the safest square.
Is the Minesweeper solver free?
Completely free, no account required. It runs client-side in your browser, so nothing you enter is uploaded.