Every hidden cell shows its exact mine probability while an AI plays the safest move.
Each revealed number is a constraint on its hidden neighbours, so the frontier becomes a small constraint satisfaction problem. The oracle splits it into independent regions, counts every consistent mine layout in each by backtracking with pruning, and tallies the counts by how many mines a layout uses. Layouts are not equally likely: one that uses k mines leaves the rest to be spread over the U unconstrained cells in C(U, M - k) ways, so convolving the regions' tables and weighting by that binomial gives the exact posterior for every cell, drawn as a heat tint from mint to red. The AI flags every certain mine, reveals every proven-safe cell, and when nothing is certain it pauses on the least dangerous cell, shows the odds and takes the guess.
Try it. Click to reveal and right-click or Shift-click to flag; clicking a satisfied number reveals around it. Toggle the oracle overlay (O) or the AI (A), press Space for a single AI move, N for a new game and D to switch between Beginner, Intermediate and Expert. Hover a hidden cell to read its probability. Leave it alone and the AI takes over again.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a Minesweeper game in JavaScript and the HTML canvas element where every hidden cell is tinted by its exact probability of being a mine, and an AI plays by always clicking the safest cell. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a 16 x 16 board with 40 mines on a canvas that stays sharp on high-DPI screens. Place the mines after the first click so it is always safe, flood-fill openings from zero cells, and support right-click flags.
- The frontier is every hidden cell next to a revealed number, and each number says how many mines its hidden neighbours hold. Enumerate every mine assignment to the frontier that satisfies all the numbers, with backtracking that abandons a branch as soon as any number is over or under its count.
- Assignments are not equally likely. One that uses k mines leaves the rest to be spread over the U hidden cells that touch no number, in C(U, remaining - k) ways, so weight it by that binomial (use log factorials). A cell's probability is its weighted share of assignments with a mine there; the unconstrained cells share the leftover expected mines.
- Tint hidden cells from green (safe) to red (certain mine) and print the percentage on frontier cells.
Once that works, make it beautiful and smart:
- Add an AI that reveals 0% cells, flags 100% cells, and otherwise clicks the safest cell, with an animated cursor and a label like 'safest is 18.5%'.
- Split the frontier into independent groups, enumerate each separately and combine their tables by convolution, so Expert boards stay fast.
- Animate openings as a ripple and add a seven-segment mine counter.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as spreading the search over animation frames for huge frontiers, measuring the AI's win rate over thousands of games, or breaking ties between equally safe cells by expected information gain.