How 22 passing tests missed a minesweeper solver bug that inverted life-or-death guesses
A developer built a minesweeper probability solver, validated it with 22 unit tests and cross-checked it against a brute-force implementation across 8,000 random boards, finding only floating-point-level differences. After integrating the solver into a playable website, roughly 300 games in, the solver flagged six squares as certain mines when only two actually were. The flaw was exposed by a telling anomaly: the per-cell mine probabilities summed to 13.96 on a board that had only 10 mines remaining, violating the mathematical requirement that those probabilities sum exactly to the mine count. The root cause was a mean-field approximation fallback used when a board component grew too large for exhaustive enumeration, producing estimates that were not true probabilities but were still being treated as certain by the finalize function. The case illustrates how a thorough test suite can miss critical bugs if the specific edge-case inputs that trigger a flawed code path are never exercised.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in