几乎每台老式 Windows 电脑里都躺着一个扫雷。它没有花哨的画面,没有背景音乐,可一旦点开,半小时就悄悄过去了。很多人以为扫雷拼的是手气——其实恰恰相反:扫雷是一道可以被严格推理的逻辑题,运气只在极少数关口才登场。
它本是一节"鼠标教学课"
扫雷于 1989 年由微软的 Robert Donner 与 Curt Johnson 编写,随后随 Windows 3.1 一起分发,并长期内置于此后的 Windows 系统。它表面是消遣,实则身负一项隐秘任务:教会当年的新用户使用鼠标——左键点开、右键插旗,正好把鼠标的两个键都练了个遍。靠着操作系统的捆绑,它成了人类历史上被打开次数最多的游戏之一。
核心:一道约束满足题
扫雷的每个数字都是一条约束:它精确告诉你,相邻 8 格里恰好有几颗雷。把整片雷区的所有数字放在一起,就构成了一个庞大的约束方程组。所谓"会玩扫雷",本质就是在解这组方程。
最基础的两条规则,可以解决盘面上绝大多数格子:
- 数字已满足 → 其余安全。如果一个 2 旁边已经确定了两颗雷,那它周围其余的未知格全部安全,可以放心翻开。
- 未知数恰好等于剩余雷数 → 全是雷。如果一个 3 旁边还差 3 颗雷,而恰好只剩 3 个未知格,那这 3 格必然都是雷。
反复套用这两条,盘面会像多米诺骨牌一样被一段段解开。
认花样,比硬算快
高手很少每一步都从头推理,他们靠的是记住固定花样。最著名的是贴着边线的 "1-2-1":当墙边连续出现 1、2、1 三个数字时,解永远唯一——两个 1 正下方是雷,2 的正下方一定安全。类似地还有 "1-2-2-1":两端的雷在外侧,中间安全。认出这些形状,几秒钟就能下一片,根本不必动笔。
扫雷的"段位",很大程度上就是你脑中存了多少个这样的局部花样,以及多快能把它们认出来。
什么时候必须"赌"?
这是扫雷最诚实、也最迷人的地方:有时候,再聪明也得猜。当一片区域的约束无论如何都无法唯一确定每颗雷的位置时,逻辑就走到了尽头。这时真正的高手做两件事:
- 算概率,挑最小。比较每个可疑格"是雷"的概率,翻开概率最低的那个。比如某条边上 5 个格里有 2 颗雷,每格是雷的概率约 40%;而盘面另一角的孤立格,按全局剩余雷数算可能只有 15%——那就先翻那个。
- 优先翻信息量大的格。同样是赌,翻开能解锁更多新数字的格子,往往能把后续一整片都顺出来。
正因为"被迫猜测"的存在,即使完美发挥,也不能保证 100% 通关——这跟井字棋"完美必平"完全不同,反而更接近真实世界的决策:信息不全时,好的选择不是消除风险,而是把风险降到最低。
一个价值连城的小游戏?
2000 年,数学家 Richard Kaye 证明了一个惊人的结论:判断"一张给定的扫雷盘面是否自洽(存在一种合法的布雷方式)"这一问题,是 NP 完全的。也就是说,扫雷和旅行商问题、布尔可满足性问题属于同一计算复杂度量级——它们是否存在快速通用解法,正是悬赏百万美元的 P 对 NP 世纪难题的核心。
当然,这并不意味着你家这局 9×9 解不出来。它说的是:当雷区大到任意规模时,没有已知的高效算法能保证总在合理时间内判定任意盘面。一个躺在系统附件里、用来教人用鼠标的小游戏,竟与数学界最著名的未解之谜遥相呼应——这大概就是经典之所以为经典。
下次再点开扫雷,不妨慢一点:先找数字、套规则、认花样,把能算的都算尽,只在真正无解时才动手去赌。你会发现,所谓"手气好",多半是推理到位的另一种说法。
Almost every old Windows PC had a copy of Minesweeper tucked away. No flashy graphics, no music — yet open it once and half an hour quietly disappears. Many assume it is a game of luck. It is the opposite: Minesweeper is a logic problem you can solve rigorously, and luck enters only at a few rare forks.
It was secretly a mouse tutorial
Minesweeper was written in 1989 by Microsoft's Robert Donner and Curt Johnson, then shipped with Windows 3.1 and bundled with Windows for years afterward. It looked like a time-waster, but it had a hidden job: teaching new users the mouse — left-click to open, right-click to flag, exercising both buttons. Thanks to that bundling, it became one of the most-opened games in history.
At heart, a constraint problem
Every number in Minesweeper is a constraint: it states exactly how many mines sit among its 8 neighbours. Put all the numbers on the board together and you have a large system of constraints. "Being good at Minesweeper" is, fundamentally, solving that system.
Two basic rules already crack most of the board:
- Satisfied number → the rest is safe. If a 2 already has two known mines beside it, every other unknown neighbour is safe to open.
- Unknowns equal remaining mines → all mines. If a 3 still needs three mines and has exactly three unknown neighbours, all three must be mines.
Apply these repeatedly and the board falls open in cascades, like dominoes.
Patterns beat raw calculation
Experts rarely reason from scratch each move — they memorise fixed patterns. The most famous is the wall-hugging "1-2-1": when 1, 2, 1 appear in a row along an edge, the solution is always unique — mines sit directly under the two 1s, and the tile under the 2 is always safe. There is also "1-2-2-1": mines on the outer ends, safe in the middle. Recognise the shape and you clear a strip in seconds, no pencil needed.
Your Minesweeper "rank" is largely how many of these local patterns you keep in your head — and how fast you spot them.
When must you gamble?
This is the most honest, most fascinating part of the game: sometimes even genius has to guess. When a region's constraints simply cannot pin down every mine, logic hits a wall. Strong players then do two things:
- Compute the odds, pick the lowest. Compare the "mine here" probability of each suspect tile and open the smallest. If 5 edge tiles hide 2 mines, each is ~40%; an isolated corner tile, by the global mine count, might be only 15% — open that one.
- Prefer high-information tiles. When you must gamble, opening a tile that unlocks more new numbers often unravels a whole region next.
Because forced guesses exist, even perfect play cannot guarantee a 100% win — unlike Tic-Tac-Toe's "perfect play always draws". That makes Minesweeper closer to real decision-making: under incomplete information, the goal isn't to remove risk but to minimise it.
A million-dollar puzzle?
In 2000, mathematician Richard Kaye proved a striking result: deciding whether a given Minesweeper board is consistent (whether any legal mine layout fits the numbers) is NP-complete. That puts Minesweeper in the same complexity class as the travelling-salesman and Boolean-satisfiability problems — whose efficient general solvability is the heart of the million-dollar P vs NP question.
This does not mean your 9×9 game is unsolvable. It means that as boards grow to arbitrary size, no known efficient algorithm can always decide any board in reasonable time. A little accessory game, built to teach the mouse, quietly echoes mathematics' most famous open problem — which is exactly what makes a classic a classic.
Next time you open Minesweeper, slow down: find the numbers, apply the rules, spot the patterns, exhaust everything provable — and only gamble when there is truly no other move. You'll find that "good luck" is usually just deduction done well.
想亲手试试?Want to try it yourself?
清空一片雷区,用推理而不是运气通关。Clear a field with logic, not luck.