Real game AI, not a chatbot: why these opponents don't use an LLM
Real game AI, not a chatbot: why these opponents don’t use an LLM
真正的游戏 AI,而非聊天机器人:为什么这些对手不使用大语言模型
The engines are playable in your browser at lkforge.com/games; the harness that produced these numbers is public and seeded. Every “AI” in a product now seems to mean a large language model. The AI that plays against you on my site doesn’t — it’s classical game-tree search: minimax, expectimax, breadth-first search. That’s a deliberate engineering choice, and it’s the difference between an opponent that’s provably correct and instant and one that’s plausible and slow. 这些引擎可以在你的浏览器中通过 lkforge.com/games 试玩;产生这些数据的测试框架是公开且可复现的。如今,产品中的每一个“AI”似乎都意味着大语言模型(LLM)。但我网站上与你对弈的 AI 并非如此——它采用的是经典的博弈树搜索:极小化极大算法(minimax)、期望极大算法(expectimax)和广度优先搜索(BFS)。这是一个经过深思熟虑的工程选择,它区分了一个“可证明正确且瞬时响应”的对手和一个“看似合理但缓慢”的对手。
The core point: My tic-tac-toe engine returns a provably-optimal move in about 0.3 ms, on your device, with zero network calls — and it has lost 0 of 1,200 test games. Those are properties a language model, by construction, cannot offer: determinism, a correctness proof, and sub-frame latency without a server. 核心观点:我的井字棋引擎能在约 0.3 毫秒内,在你的设备上返回一个可证明的最优走法,且无需任何网络调用——在 1,200 场测试对局中,它一场未输。这些是语言模型从架构上无法提供的特性:确定性、正确性证明以及无需服务器的亚帧级延迟。
“Why not just use an LLM?” Fair question in 2026 — you could prompt a model with the board and ask for a move. The reason I don’t: a language model is trained to predict the next token of text, not to search a game tree. It can explain tic-tac-toe strategy fluently and still play a losing move, because fluent text and optimal play are different objectives. Winning a solved game is a search problem, and we already have exact, fast algorithms for it. “为什么不直接用 LLM?”在 2026 年这是一个合理的问题——你可以将棋盘状态输入模型并要求它给出一个走法。我不这么做的原因是:语言模型被训练的目标是预测下一个文本 Token,而不是搜索博弈树。它可以流利地解释井字棋策略,却依然可能走出导致失败的一步,因为“流利的文本”和“最优的博弈”是完全不同的目标。赢得一个已解的游戏是一个搜索问题,而我们已经拥有了精确且快速的算法。
The three engines — minimax + alpha-beta for tic-tac-toe, expectimax for 2048, and BFS for Color Lines — are textbook, deterministic, and run in well under a millisecond in a browser tab. 这三个引擎——用于井字棋的极小化极大算法加 Alpha-Beta 剪枝、用于 2048 的期望极大算法,以及用于 Color Lines 的广度优先搜索——都是教科书式的、确定性的算法,并且在浏览器标签页中运行时间远低于一毫秒。
Search vs. a language model, point by point
搜索与语言模型的逐项对比
| Game-tree search (mine) | A language model |
|---|---|
| Decides a move by searching the tree of legal positions | predicting likely next tokens |
| Correctness provable at full depth | none — fluent ≠ optimal |
| Same board → same move (deterministic) | varies with sampling/phrasing |
| Latency sub-millisecond, on-device | a network round-trip |
| Needs a server: no | yes |
| 博弈树搜索(我的) | 大语言模型 |
|---|---|
| 通过搜索合法位置树来决定走法 | 预测可能的下一个 Token |
| 在全深度下可证明正确性 | 无——流利不等于最优 |
| 相同棋盘 → 相同走法(确定性) | 随采样/措辞而变化 |
| 延迟:亚毫秒级,设备端运行 | 需要网络往返 |
| 需要服务器:否 | 是 |
Every row is an architectural difference — how each system decides — not a quoted benchmark. The only measured numbers here are mine. 每一行都是架构上的差异——即系统如何做出决策——而不是引用的基准测试。这里唯一测量的数据是我自己的。
The payoff: a strength number you can actually pin down. Because the engines are deterministic, I can put an exact figure on how strong they are — run the shipped code headlessly, hundreds of times, and count. That’s far harder for a model whose output shifts with sampling and phrasing. 回报在于:一个你可以真正确定的强度数值。因为引擎是确定性的,我可以给它们的强度一个精确的数字——在无头模式下运行发布的代码数百次并进行统计。对于输出会随采样和措辞而变化的模型来说,这要困难得多。
2048 solver, 250 self-play games: 69.6% of games reach the 2048 tile, 30% reach 4096, and none of the 250 reached 8192 — the honest ceiling of a corner-snake expectimax search at ~0.5 ms/move. A number, with error bars you could compute, precisely because the same board always drives the same search. 2048 求解器,250 场自对弈:69.6% 的对局达到 2048 方块,30% 达到 4096,250 场中没有一场达到 8192——这是“角落蛇形”期望极大搜索在约 0.5 毫秒/步下的真实上限。这是一个带有可计算误差范围的数值,正是因为相同的棋盘总是驱动相同的搜索过程。
Tic-tac-toe is the cleaner case: full-depth minimax is provably optimal, so “unbeatable” is a theorem, not a vibe. Across 1,200 self-play games (1,000 vs random, 200 vs a perfect copy) it lost none. Alpha-beta keeps full depth cheap: 36,528 nodes instead of 549,945 at the opening move — a 93% cut — in about 0.3 ms. 井字棋是一个更清晰的案例:全深度极小化极大算法是可证明最优的,因此“不可战胜”是一个定理,而不是一种感觉。在 1,200 场自对弈中(1,000 场对阵随机,200 场对阵完美副本),它一场未输。Alpha-Beta 剪枝让全深度搜索变得廉价:在开局时只需搜索 36,528 个节点,而不是 549,945 个——减少了 93%——耗时约 0.3 毫秒。
The right tool, not the trendy one. None of this is anti-LLM. Language models are extraordinary at language — and a couple of the tools on my site that are genuinely language tasks could use one. But a board game with fixed rules and a finite tree is exactly the problem classical search was invented for. 选择合适的工具,而不是时髦的工具。这并非反 LLM。语言模型在处理语言方面非常出色——我网站上的一些真正属于语言任务的工具确实可以使用它们。但对于规则固定且博弈树有限的棋盘游戏,这正是经典搜索算法被发明出来要解决的问题。