Essays北极甜虾 · No. 16

玩物有理 · 第一篇

俄罗斯方块,
为什么注定会输

两块歪方块和一口井的宽度
2023 年底,一个 13 岁的少年把 NES 版俄罗斯方块玩到了死机,新闻说他“打通”了。数学家在 1990 年代证明过一件更彻底的事:只要方块随机发,再完美的玩家也会输。这篇用六条定理和几个小程序讲清楚为什么,再看游戏设计师后来怎么绕开了它。
SSSZZ×3×210 × 20 的井S、Z 交替,按车道竖着摆Z 道分到的块多先顶到了井口S 道分到的块少长得慢,消行也被拖住第 94 块 Z 被逼进 S 道右边留下一个两格高的洞
图 1十列的井里,S(红)和 Z(灰)交替落下。五条车道分不平,Z 道先顶到高处,下一块 Z 只好放进 S 道,留下一个填不上的洞(虚线框)。由本文的模拟程序画出。

2023 年 12 月 21 日,美国俄克拉何马州 13 岁的 Willis Gibson(网名 Blue Scuti)把 NES 版俄罗斯方块玩到了第 157 关,画面卡住,游戏死机。这款游戏没有结局,玩到死机就算通关。在他之前,只有 AI 做到过。

死机是程序的 bug,换一台没有 bug 的机器就不会发生。数学上还有一个更干净的问题:假如方块想落多慢就落多慢,玩家永远不累、不失误,能不能一直玩下去?

1992 年,John Brzustowski 在加拿大英属哥伦比亚大学(UBC)的硕士论文里系统研究过这个问题。1997 年,Heidi Burgiel 在《数学公报》(The Mathematical Gazette)上发了一篇短文,题目叫《怎样输掉俄罗斯方块》。结论是:只要方块是随机发的,再完美的玩家也必输。祸首是两块歪方块,S 和 Z。

这是“玩物有理”系列的第一篇,每篇拆一款游戏背后的一条定理。这一篇先把俄罗斯方块写成数学,再证六条结论,中间用程序算几口小井,最后看游戏设计师怎么绕开了“必死”。

先把游戏写成数学

俄罗斯方块的场地是一口井,宽 列、高 行,标准尺寸是 10 × 20。方块一共七种,每种由四个小方格拼成,按形状叫 I、O、T、S、Z、J、L。

IOTSZJLS 平放S 竖放Z 平放Z 竖放虚线格:落在平地上,底下悬空的那一格
图 2上:七种方块。下:S 和 Z 互为镜像,各有平放、竖放两种姿势(转 180° 和原来一样)。它们没有平底,放在平地上,底下一定会空出一格。

规则只有三条。方块落下之前,玩家可以旋转、左右平移,落定后锁死。某一行填满,这一行就消掉,上面的格子整体下移一行。格子堆出井口,游戏结束。

数学家要一个干净的版本,所以做两处理想化。一是不管速度,每一块想多久都行;二是不管分数,只问能不能永远玩下去。能永远玩下去,就叫有必胜策略。

如果只发一种方块,答案都是能。Brzustowski 给七种方块各找了一套循环打法,在 10 列的井里可以一直玩。麻烦出在组合上,尤其是 S 和 Z。看图 2 就明白:它们的底是错开的,放在平地上,下面一定悬空一格,成了一个“洞”。洞被上面的格子盖住,后来的方块落不进去,这一行就消不掉。

奇数宽的井:一次染色

先看比标准井更简单的情形:井宽是奇数,比如 9 列。这时连交替都不需要,只要发牌器只发 S 和 Z,顺序随便,玩家就必输。

定理 1奇数宽的井(Brzustowski,1992)

井宽 为奇数、高为 。如果只来 S 和 Z(顺序任意),无论怎么摆,最多消掉 行,最多放下 块,游戏一定会结束。

123456789放一块 S 或 Z深 2 · 浅 2,D 不变消掉一整行浅 5 · 深 4,D 加 1D = 深列格子数 − 浅列格子数
图 3把列从左到右编号,偶数列涂深。S、Z 无论怎么放,都是两格在深列、两格在浅列。一整行却是浅 5 格、深 4 格。

证明从左到右给列编号 1 到 。记 = 偶数列里的格子数 − 奇数列里的格子数。

放一块 S 或 Z, 不变。竖放时,它在相邻两列各占两格;平放时,它占三列,左右两列各一格、中间一列两格,而左右两列奇偶相同。两种放法都是两格在奇数列、两格在偶数列。

消一行, 加 1。 是奇数,一行里有 格在奇数列、 格在偶数列,消掉以后奇数列多少一格。

开局 ,消掉 行以后 。另一方面, 不超过偶数列里的格子数,而偶数列最多装 格,所以 。放下的格子要么被消掉,要么还在井里,所以块数 满足 ,代入即得。∎

9 列 20 行的井,最多消 80 行、放 225 块。这个论证只看列的奇偶,所以方块怎么滑、怎么转都不影响。它还能推广:O 块也总是两格对两格,所以 S、Z、O 怎么混着发都必死。T、I、J、L 各有某种放法是三格对一格,或者四格对零格,染色就管不住了。

可惜标准的井是 10 列。偶数宽的井里,一行正好一半在奇数列、一半在偶数列,消一行 不变,这一招失效。要对付 10 列的井,得换一本账。

十列的井:一本列账

Burgiel 的第一步是记账。把开局以来放进第 列的格子总数记作 ,后来被消掉的也算在内。

引理 1列账本

任何时刻,任意两列的累计格子数相差不超过井高:。

证明每消一行,每一列都恰好少一格。消掉 行以后,第 列现有的格子数是 ,它在 和 之间。两列相减, 抵消。∎

这条引理看着平淡,用处很大。不管消了多少行,各列历史上收到的格子必须齐头并进,谁也不能比别人多出一口井的高度。

再把 10 列两两分组:第 1、2 列是第一条车道,第 3、4 列是第二条,一直到第 9、10 列,一共五条。一块 S 或 Z 有三种放法:竖着放进一条车道;竖着放、但跨在两条车道之间(占第 2、3 列这样的位置);横着放。

12345678910+2+2车道内竖放规矩的放法+2+2跨车道竖放例外+1+2+1横放例外引理 2 的四个量从井壁往里,每隔两列最多加 20≤20X2≤40X4≤40X6≤20X8X00X100合计 ≤ 120
图 4上:三种放法给各列加的格子数。下:引理 2 证明里四个量的上界,两头被井壁卡住,中间最多 40,合起来 120。
引理 2例外的放法有上限(Burgiel,1997)

在 10 × 20 的井里只放 S 和 Z。整局游戏中,横放的块数加上跨车道竖放的块数,不超过 120。

证明记 为竖放在第 、 列的块数, 为横放、中间一格在第 列的块数(它占第 、、 列)。竖放的块给两列各加 2 格,横放的块给三列分别加 1、2、1 格,所以

令 ,直接相减可得 。井壁外面放不了方块,所以 。由引理 1,相邻两列的差不超过 20,从左往右得 、,从右往左得 、。四式相加,左边正好是全部横放的块数,加上 ,也就是跨车道竖放块数的两倍,比引理里的和还大。∎

换句话说,整局下来,不守规矩的放法最多一百来次。剩下成千上万块,都只能竖着放进五条车道。

五条车道,总有一条吃亏

车道里竖放的方块有个脾气。竖放的 S 左列高、右列低,正好托住下一块 S,一块块叠上去严丝合缝。竖放的 Z 正相反。按最上面那块,把车道分成 S 道和 Z 道。

把 Z 放进 S 道,右边会留下一个宽 1 格、高 2 格的洞。洞的左边是满的,上面被盖住,车道里竖放的块再也够不着它,只能靠横放或跨车道的块去补,而这样的块整局只有一百来次机会。

S 落在 S 道严丝合缝Z 落在 S 道留下一个洞洞SSSZZS 道 3 条、Z 道 2 条放了 60 块以后长得快
图 5左:S 落在 S 道上,严丝合缝。中:Z 落在 S 道上,右边留下一个两格高的洞。右:三条 S 道、两条 Z 道,S 和 Z 一样多,Z 道长得更快。
定理 2交替的 S、Z(Burgiel,1997)

在 10 × 20 的井里,如果 S 和 Z 交替出现,无论怎么摆,不到 69,600 块游戏就会结束。更一般地,井宽为 、 为奇数时,交替的 S、Z 都会逼死玩家。

证明要点由引理 2,除了至多 120 块例外,其余的块都竖放在车道里。

五条车道是奇数,S 道和 Z 道不可能一样多,不妨设 S 道 3 条、Z 道 2 条。S 和 Z 交替来,数量相同。设连续 块都放进了同类的车道。两条 Z 道分 块,总有一条至少分到 块,每列至少长 格;三条 S 道分 块,总有一条至多分到 块,每列至多长 格。两列的累计差拉开了至少 。由引理 1,这个差在开头和结尾都不超过 20,前后最多变化 40,所以 。也就是说,每 240 块之内,必有一块放进“错”的车道,留下一个洞。

洞不补上,它占的两行就消不掉。Burgiel 算过,井里同时最多容得下 50 个这样的洞。补洞只能靠例外的块,每块最多补两个,例外的块不到 120 块。所以整局最多出现 个洞,游戏最多进行 块。∎

69,600 是一个很松的上界,论证里每一步都按最坏情况放大了。真实的极限是多少,没人知道。下一节用程序从下面逼它。

换个宽度,就能活

定理 2 里最要紧的一个字是“奇”:五条车道分不平。车道换成偶数条呢?

定理 3宽是 4 的倍数的井(本文构造)

井宽是 4 的倍数(4、8、12……)、高至少 4 行时,S 和 Z 交替出现,可以永远玩下去。

证明井宽 ,有 条车道。前 条做 S 道,后 条做 Z 道。S 来了就轮流竖放进各条 S 道,Z 来了就轮流竖放进各条 Z 道。第一轮过后,盘面只剩最底下两行,每行各空一半(图 6 最左)。之后每过 块,每条车道各收到一块、各长两格,中间两行同时填满消掉,盘面回到原样。高度从不超过 4 行。∎

开始+S+Z+S+Z两行填满消掉,回到开始
图 68 列的井,S、Z 交替,按车道摆。每 4 块消掉两行,回到原样,可以一直循环。由本文的模拟程序画出。

这条策略是本文构造的,手头的文献里没见到,不排除前人做过。程序按它跑了二十万块,一块没输。它说明定理 2 里“ 为奇数”不是技术性的条件,去掉就不成立。

再往前推一步。S 和 Z 不一定一比一交替,也可以是“S、S、Z”循环,或者“S、S、S、Z”循环。本文写了一个穷举程序:每块只许旋转、平移,然后直接落到底(Brzustowski 用的就是这个规则),把小井里所有可能的摆法都搜一遍,看有没有能无限循环的玩法。

井宽车道数426384105126S、ZS 占 1/2活1183/2活2705/2活3S、S、ZS 占 2/384/3活2488/39510/3活4S、S、S、ZS 占 3/4··活3·1029/2S、S、Z、ZS 占 1/2··活2··S、Z、ZS 占 1/3··404/3··S×4、ZS 占 4/5···活4·活:找到了能无限循环的摆法死:所有摆法都会输,数字是最多能撑的块数格子下方的数 = 车道数 × S 的占比:整数就活
图 7程序穷举的结果,井高 4 行(其中几种也试了 5、6 行,结论不变)。“活”是找到了能无限循环的摆法;红格是所有摆法都会输,数字是最多能撑的块数。

15 种组合,规律无一例外:车道数乘以 S 所占的比例,是整数就能活,不是整数就会死。直观上和定理 2 是同一个道理:能把车道按 S、Z 的比例分好,每条车道就长得一样快;分不平,总有车道被逼着放错。这条规律只在小井上验证过,还不是定理。

回到标准的 10 × 20。井太大,穷举不动,只好改用束搜索(beam search),每一步只保留最有希望的三万个盘面,交替的 S、Z 最多撑到了 781 块。小井可以算出精确值,见图 8。

101001,00010,000100,0006 × 4穷举186 × 5穷举256 × 6穷举496 × 7穷举6510 × 4穷举7010 × 20搜索下界78110 × 20Burgiel 上界69,600交替的 S、Z:最多能撑的块数
图 8交替的 S、Z 最多能撑多少块(横轴是对数刻度)。小井是穷举的精确值;10 × 20 一行是本文搜索找到的最好结果,只是下界;最后一行是 Burgiel 的上界。

10 × 20 的真实极限,就夹在 781 和 69,600 之间。Burgiel 在论文结尾也承认上界很松,她估计逼死玩家真正需要的交替 S、Z 只有一千多块,而不是十几万块。

随机发牌,迟早撞上

真实的游戏不会故意交替发 S 和 Z。Burgiel 那篇文章的后半段,针对的是随机发牌。

定理 4几乎每一局都会结束(Burgiel,1997)

在 10 × 20 的井里,如果每一块都独立地随机发,S 和 Z 出现的概率都大于 0,那么游戏以概率 1 结束。

证明先说一个事实:从任意盘面出发,一串足够长的交替 S、Z 都能逼死玩家(Burgiel 给出的长度约为 12.7 万块),把这个长度记作 。把发牌序列每 块切成一段。每一段恰好是“S、Z、S、Z……”的概率是同一个数 ,各段互相独立。前 段全都不是这串的概率是 , 时趋于 0。所以以概率 1,迟早有一段是这串,游戏最晚在这一段里结束。∎

这和“猴子打字”是同一个道理:每一下都随机,任何一段有限的字迟早会出现。只是这一次要等多久?七种方块均匀地发,某一段恰好是这串的概率约为 ,大约是 10 的负十万次方。按一秒一块算,平均要等的时间是宇宙年龄的很多倍,这个倍数本身就有十万多位。

所以这条定理在实战中毫无威胁。它的意义在别处:必死,可以是一个关于概率的定理,跟手速无关。

NES 版的发牌器并不独立。据玩家对程序的拆解,它先掷一个 0 到 7 的数,掷到 7 或者和上一块相同,就再掷一次 0 到 6,所以连着来同一块的概率只有约 1/28。但从 S 到 Z、从 Z 到 S 的概率都大于 0,同样的论证换成马尔可夫链的版本照样成立。Blue Scuti 那一局要是一直不死机,理论上也逃不掉。

设计师的解药:7 袋

今天的官方俄罗斯方块不再独立发牌。官方规范(Tetris Guideline)里的发牌器叫 Random Generator,玩家叫它“7 袋”:把七种方块装进一个袋子,打乱顺序依次发出,发完再装下一袋。

定理 57 袋的两条保证

7 袋发牌时,连在一起的 S、Z(不论顺序)最多 4 块;两块 I 之间最多隔 12 块。两个界都能取到。

证明一袋 7 块,连续 5 块最多跨两个袋子。两个袋子里一共只有 2 块 S、2 块 Z,所以连在一起的 S、Z 至多 4 块;前一袋以 S、Z 结尾,后一袋以 Z、S 开头,就是 4 块。一块 I 后面,它所在的袋子最多还剩 6 块,下一袋的 I 最晚排在第 7 位,中间最多 块。∎

独立随机IOOJTLIJOTITJLJSZSSZSTJSZLJIS、Z 连 6 块两块 I 之间隔了 16 块7 袋IOLJTSZSZLJOTITLSOIZJZLJOTISS、Z 连 4 块两块 I 之间隔了 12 块
图 9上:独立随机发的 28 块,S、Z 连成长串,I 很久不来。下:7 袋发的 28 块(4 袋),竖线是袋子的边界。两段都由程序随机生成(示意)。

最多 4 块连在一起的 S、Z,离逼死玩家需要的十几万块差得远。7 袋把定理 4 的前提整个拿掉了。玩家社区整理过一套循环打法(见 Tetris Wiki):有暂存(Hold)和至少 3 个预览时,可以一直玩下去。这是玩家的构造,没有经过同行评审,方向和上面的定理一致。

这是一种设计取舍。独立随机最“公平”,坏运气却没有上限;7 袋牺牲一点随机性,换来坏运气有上限。连成长串的 S、Z 不会来,I 也不会让你等到地老天荒。

知道全部方块,也难

前面问的是能不能永远玩下去。还有另一种问法:把开局盘面和接下来的全部方块事先都告诉你,你能不能找出最好的摆法?

定理 6离线版是 NP 完全的(Demaine 等,2003)

给定开局盘面和全部方块序列,判断能否消掉给定的行数、能否放完全部方块而不输,都是 NP 完全问题。

这是 Erik Demaine、Susan Hohenberger、David Liben-Nowell 2003 年的结果。证明是一个归约,从一个公认很难的问题出发:3-Partition。给你 个正整数和一个目标 ,问能不能把它们分成 组,每组三个数,每组的和都恰好是 。比如 6、6、8、7、7、6,目标 20,答案是 {6, 6, 8} 和 {7, 7, 6}。数一多,没人知道比挨个试快得多的办法。

他们构造的盘面里有 个一样深的“桶”,最右边是一把“锁”。每个数 被翻译成一串固定的方块,共 块,这串方块只有整串放进同一个桶,才不会留下补不上的空。放进去以后,桶里的方块升高 行左右。锁要到最后才打开:只有所有桶恰好一样高,最后来的一串方块(主要是竖着的 I)才能把整个盘面清空。所以,盘面能清空,当且仅当这些数能三个一组凑成 。

桶 1桶 2桶 3锁三个桶都填到同一高度,锁才打得开每个数 aᵢ → 一串 5aᵢ + 5 块,必须整串放进同一个桶灰格是开局就有的格子;空白处由方块串来填
图 10归约的盘面(示意,按论文的构造画,行数缩短了)。每个桶宽 6 列,第 4、5 列每隔六行留一个缺口;右边三列是锁。三个数一组放进同一个桶;所有桶一样高时,最后的竖条才能一路消到底。

这里的难,和前面的必死是两回事。前面是方块不由你挑,再聪明也躲不掉;这里是方块全摆在眼前,找正确的摆法却可能要试指数多种。2020 年,Sualeh Asif、Erik Demaine 等七位作者把结论推得更窄:井只有 8 列,或者只有 4 行,问题照样是 NP 完全的;只有 2 列时,才能在多项式时间里解决。

写在最后

回头看,俄罗斯方块的必死有三个层次。奇数宽的井,一次染色就判了死刑。10 列的井,要一本列账、五条车道,和一点耐心。8 列、12 列的井,交替的 S、Z 反而杀不死你。同一个游戏,生死取决于井宽除以 4 的余数。

必死定理离真实的游戏很远。要等的那串方块,宇宙里等不到;先到来的,是越来越快的下落速度,还有第 157 关的那次死机。定理和游戏设计碰到的是同一个问题:独立随机的坏运气没有上限。今天的官方发牌器,就是照着“坏运气要有上限”设计的。

俄罗斯方块问世四十多年,数学家早就算出来它赢不了。玩家照样一局接一局地玩。

生死不看手速,
看井宽除以 4 的余数。
留言区聊聊

你玩俄罗斯方块最多撑过多少行?你觉得 7 袋算不算一种“作弊”?

参考资料
  1. J. Brzustowski (1992), Can you win at Tetris? 硕士论文,University of British Columbia
  2. H. Burgiel (1997), How to lose at Tetris, The Mathematical Gazette 81(491): 194–200
  3. K. M. Tsuruda (2010), A closer look at Tetris: analysis of a variant game, Atlantic Electronic Journal of Mathematics 4(1): 23–34(含 Brzustowski 论文结果的转述)
  4. E. D. Demaine, S. Hohenberger, D. Liben-Nowell (2003), Tetris is hard, even to approximate, COCOON 2003: 351–363;arXiv: cs/0210020
  5. S. Asif, M. Coulombe, E. D. Demaine, M. L. Demaine, A. Hesterberg, J. Lynch, M. Singhal (2020), Tetris is NP-hard even with O(1) rows or columns, Journal of Information Processing 28: 942–958
  6. Tetris Wiki:Random Generator、Playing forever、Tetris (NES) 词条(2026-10-14 查阅)
  7. 美联社 2024 年 1 月关于 Willis Gibson 的报道(PBS NewsHour 等转载)
注:文中插图均为本文自制示意。图 1、6、7、8、9 的数据由本文自写的程序算出。
犹剑在心
北极甜虾(剑心犹在!)
— 全文完 —
Translated from the Chinese original, “俄罗斯方块,为什么注定会输”.
The Logic of Play · No. 1

Why You Always
Lose at Tetris

Two crooked pieces and the width of a well
At the end of 2023 a 13-year-old played NES Tetris until the game crashed, and the news said he had “beaten” it. In the 1990s mathematicians proved something more final: as long as the pieces come at random, even a perfect player will lose. This essay uses six theorems and a few small programs to explain why, then looks at how game designers later got around it.
SSSZZ×3×2A 10 × 20 wellS, Z alternate, vertical in lanesZ lanes get more piecesand reach the top firstS lanes get fewergrow slower, holding up clearsPiece 94, a Z, forced into S laneleaving a 2-high hole on the right
Figure 1S (red) and Z (gray) fall alternately into a 10-column well. The five lanes cannot be shared out evenly: the Z lanes reach the top first, so the next Z has to go into an S lane, leaving a hole that can never be filled (dashed box). Drawn by the simulation program written for this essay.

On December 21, 2023, Willis Gibson, a 13-year-old from Oklahoma who plays as Blue Scuti, reached level 157 of NES Tetris. The screen froze and the game crashed. The game has no ending, so crashing it counts as beating it. Before him, only AI had done it.

The crash is a bug in the program; on a machine without the bug it would never happen. Mathematics asks a cleaner question: suppose the pieces fall as slowly as you like, and the player never tires and never slips. Can the game go on forever?

In 1992 John Brzustowski made a systematic study of this question in his master's thesis at the University of British Columbia (UBC) in Canada. In 1997 Heidi Burgiel published a short paper in The Mathematical Gazette titled “How to Lose at Tetris.” Its conclusion: as long as the pieces are dealt at random, even a perfect player must lose. The culprits are two crooked pieces, S and Z.

This is the first installment of “The Logic of Play,” a series in which each essay takes apart one theorem behind one game. This one first writes Tetris down as mathematics, then proves six results, running programs on a few small wells along the way, and ends with how game designers got around “certain death.”

The game as mathematics

The Tetris playing field is a well columns wide and rows high; the standard size is 10 × 20. There are seven pieces, the tetrominoes, each built from four small squares and named for its shape: I, O, T, S, Z, J and L.

IOTSZJLS horizontalS verticalZ horizontalZ verticalDashed cell: the gap left underneath on flat ground
Figure 2Top: the seven pieces. Bottom: S and Z are mirror images, and each has two orientations, horizontal and vertical (a 180° turn gives the same shape back). Neither has a flat bottom, so on flat ground each always leaves an empty cell beneath it.

There are only three rules. Before a piece lands, the player may rotate it and shift it left or right; once it lands, it locks in place. When a row is completely filled, it is cleared, and everything above it drops down one row. When the cells pile up past the top of the well, the game is over.

Mathematicians want a clean version, so they idealize in two ways. First, ignore speed: you may think as long as you like about every piece. Second, ignore the score: ask only whether you can play forever. If you can, we say you have a winning strategy.

If only one kind of piece is ever dealt, the answer is always yes. Brzustowski found a repeating pattern for each of the seven pieces that lets you play forever in a 10-column well. The trouble comes with combinations, above all S and Z. Figure 2 shows why: their bottoms are staggered, so on flat ground there is always an empty cell beneath them, and it becomes a “hole.” Once the hole is covered by cells above, no later piece can drop into it, and that row can never be cleared.

Odd-width wells: one coloring

Start with a case simpler than the standard well: an odd width, say 9 columns. Here the pieces need not even alternate. As long as the randomizer deals only S and Z, in any order, the player must lose.

Theorem 1Odd-width wells (Brzustowski, 1992)

Let the well have odd width and height . If only S and Z pieces arrive (in any order), then however they are placed, at most lines are cleared and at most pieces are placed, so the game must end.

123456789Place an S or Z2 dark · 2 light: D sameClear a full row5 light · 4 dark: D + 1D = dark cells − light cells
Figure 3Number the columns from left to right and shade the even ones. However an S or Z is placed, two of its cells fall in dark columns and two in light ones. A full row, though, has 5 light cells and 4 dark ones.

ProofNumber the columns from left to right, 1 to . Let be the number of cells in even columns minus the number of cells in odd columns.

Placing an S or Z leaves unchanged. Placed vertically, the piece takes two cells in each of two adjacent columns; placed horizontally, it spans three columns, with one cell in each outer column and two in the middle one, and the two outer columns have the same parity. Either way, two cells land in odd columns and two in even columns.

Clearing a line increases by 1. Since is odd, a row has cells in odd columns and in even columns, so clearing it removes one more cell from the odd columns than from the even ones.

At the start , so after lines have been cleared, . On the other hand, is at most the number of cells in even columns, and the even columns hold at most cells, so . Every cell placed has either been cleared or is still in the well, so the number of pieces satisfies , and substituting gives the bound. ∎

In a well 9 columns wide and 20 rows high, that means at most 80 lines and 225 pieces. The argument looks only at the parity of the columns, so it makes no difference how the pieces slide or spin. It also generalizes: an O piece always splits two and two as well, so any mix of S, Z and O is fatal. T, I, J and L each have some placement that splits three and one, or four and zero, and then the coloring loses its grip.

Unfortunately the standard well is 10 columns wide. In an even-width well, a row lies exactly half in odd columns and half in even ones, so clearing it leaves unchanged and the trick fails. To handle the 10-column well, we need to keep a different kind of ledger.

The 10-column well: a column ledger

Burgiel's first step is bookkeeping. Write the total number of cells placed in column since the start of the game, including those later cleared, as .

Lemma 1The column ledger

At any moment, the running totals of any two columns differ by at most the height of the well: .

ProofEach line clear removes exactly one cell from every column. After lines have been cleared, the number of cells now in column is , which lies between and . Subtract one column from another and the cancels. ∎

The lemma looks bland, but it does a lot of work. However many lines have been cleared, the cells the columns have received over the whole game must keep pace with one another: no column can get ahead of another by more than the height of the well.

Next, pair up the 10 columns: columns 1 and 2 form the first lane, columns 3 and 4 the second, and so on up to columns 9 and 10, five lanes in all. An S or Z can be placed in three ways: vertically inside a lane; vertically but straddling two lanes (in columns 2 and 3, say); or horizontally.

12345678910+2+2In a lanethe regular way+2+2Straddlingexception+1+2+1HorizontalexceptionLemma 2's four quantitiesevery second column, in from the wallseach step adds at most 20≤20X2≤40X4≤40X6≤20X8X00X100Sum ≤ 120
Figure 4Top: how many cells each of the three placements adds to each column. Bottom: the bounds on the four quantities in the proof of Lemma 2. The walls pin down both ends, the middle two are at most 40, and the total is 120.
Lemma 2Exceptional placements are bounded (Burgiel, 1997)

In a 10 × 20 well with only S and Z pieces, the number of horizontal pieces plus the number of straddling vertical pieces, over the whole game, is at most 120.

ProofLet be the number of pieces placed vertically in columns and , and the number placed horizontally with their middle cell in column (such a piece occupies columns , , and ). A vertical piece adds 2 cells to each of its two columns, and a horizontal piece adds 1, 2 and 1 cells to its three columns, so

Set . Subtracting directly gives . No piece can sit outside the walls, so . By Lemma 1, adjacent columns differ by at most 20, so working in from the left we get and , and from the right and . Add the four inequalities. The left side is exactly the total number of horizontal pieces plus , which is twice the number of straddling vertical pieces, so it is even larger than the sum in the lemma. ∎

In other words, over a whole game there are at most a hundred or so placements that break the rules. All the other pieces, thousands upon thousands of them, have to go vertically into the five lanes.

Five lanes, and one always loses out

Vertical pieces in a lane have a quirk. A vertical S is high on the left and low on the right, exactly the shape to cradle the next S, so S pieces stack one on another without a gap. A vertical Z is the opposite. Call a lane an S lane or a Z lane according to the piece on top.

Put a Z into an S lane and it leaves a hole on the right, 1 cell wide and 2 cells high. The hole is boxed in on the left and covered from above, so vertical pieces in the lane can never reach it. Only a horizontal or straddling piece can fill it, and such pieces get only a hundred or so chances in the whole game.

S in S lanesnug fitZ in S laneleaves a holeholeSSSZZ3 S lanes, 2 Z lanesafter 60 piecesgrow faster
Figure 5Left: an S lands in an S lane and fits snugly. Middle: a Z lands in an S lane, leaving a hole two cells high on its right. Right: three S lanes and two Z lanes; with as many S pieces as Z pieces, the Z lanes grow faster.
Theorem 2Alternating S and Z (Burgiel, 1997)

In a 10 × 20 well, if S and Z pieces alternate, then however they are placed, the game ends within 69,600 pieces. More generally, in a well of width with odd, alternating S and Z will kill the player.

Proof sketchBy Lemma 2, apart from at most 120 exceptions, every piece goes vertically into a lane.

Five is odd, so there cannot be as many S lanes as Z lanes; say there are 3 S lanes and 2 Z lanes. Since S and Z alternate, they come in equal numbers. Suppose consecutive pieces all go into lanes of their own kind. The two Z lanes share pieces, so one of them gets at least , and each of its columns grows by at least cells; the three S lanes share pieces, so one of them gets at most , and each of its columns grows by at most cells. The gap between the running totals of these two columns widens by at least . By Lemma 1 this gap is at most 20 at both the start and the end, so it can change by at most 40, and therefore . In other words, within every 240 pieces some piece must go into the “wrong” lane and leave a hole.

A hole that is never filled keeps its two rows from ever clearing. Burgiel worked out that the well can hold at most 50 such holes at once. Holes can be filled only by exceptional pieces, each of which fills at most two, and there are no more than 120 of those. So at most holes can appear in the whole game, and the game lasts at most pieces. ∎

69,600 is a very loose upper bound: every step of the argument assumes the worst case and rounds up. Nobody knows the true limit. The next section uses programs to close in on it from below.

Change the width, and you survive

The word that matters most in Theorem 2 is “odd”: five lanes cannot be split evenly. What if the number of lanes is even?

Theorem 3Widths divisible by 4 (this essay's construction)

If the width of the well is a multiple of 4 (4, 8, 12, …) and its height is at least 4 rows, alternating S and Z can be played forever.

ProofLet the width be , so there are lanes. Make the first of them S lanes and the last Z lanes. Each S goes vertically into the S lanes in turn, and each Z into the Z lanes in turn. After the first round, only the bottom two rows are left on the board, each half empty (Figure 6, far left). From then on, in every pieces each lane receives one piece and grows two cells taller; the middle two rows fill up at the same moment and clear, and the board is back where it started. The stack never rises above 4 rows. ∎

Start+S+Z+S+Z2 rows full and cleared: back to start
Figure 6An 8-column well, S and Z alternating, placed lane by lane. Every 4 pieces clear two rows and the board returns to its starting state, so the cycle can go on forever. Drawn by the simulation program written for this essay.

I constructed this strategy for this essay and have not seen it in the literature I have at hand, though someone may well have found it before. Following it, the program ran through two hundred thousand pieces without losing once. It shows that the condition “ odd” in Theorem 2 is not a technicality: drop it and the theorem is false.

Let's push a step further. S and Z need not alternate one for one; the cycle could be “S, S, Z” or “S, S, S, Z.” I wrote an exhaustive-search program: each piece may only be rotated and shifted and then drops straight to the bottom (exactly the rule Brzustowski used), and the program searches every possible placement in a small well to see whether there is a way of playing that cycles forever.

Well widthLanes426384105126S, ZS share 1/2Alive1183/2Alive2705/2Alive3S, S, ZS share 2/384/3Alive2488/39510/3Alive4S, S, S, ZS share 3/4··Alive3·1029/2S, S, Z, ZS share 1/2··Alive2··S, Z, ZS share 1/3··404/3··S×4, ZS share 4/5···Alive4·Alive: found a placement that loops foreverDead: every placement loses; number = most pieces lastedSmall number = lanes × S share: integer means alive
Figure 7Results of the exhaustive search, in a well 4 rows high (some cases were also tried at 5 and 6 rows, with the same outcome). “Alive” means the program found a placement that loops forever; a red cell means every placement loses, and the number is the longest you can last, in pieces.

Across all 15 combinations, the pattern holds without exception: if the number of lanes times the share of S is a whole number, you survive; if not, you die. Intuitively, the reason is the same as in Theorem 2. If the lanes can be divided up in proportion to S and Z, every lane grows at the same rate; if they cannot, some lane is always forced to take the wrong piece. The rule has only been checked on small wells, and it is not yet a theorem.

Back to the standard 10 × 20. That well is too big for exhaustive search, so I switched to beam search, keeping only the 30,000 most promising boards at each step. The best it managed against alternating S and Z was 781 pieces. Small wells can be computed exactly; see Figure 8.

101001,00010,000100,0006 × 4exhaustive186 × 5exhaustive256 × 6exhaustive496 × 7exhaustive6510 × 4exhaustive7010 × 20search lower bound78110 × 20Burgiel bound69,600Alternating S and Z: most pieces lasted
Figure 8How many pieces you can last against alternating S and Z, at best (log scale on the horizontal axis). For small wells these are exact values from exhaustive search; the 10 × 20 row is the best my search found, and is only a lower bound; the last row is Burgiel's upper bound.

So the true limit for 10 × 20 lies somewhere between 781 and 69,600. At the end of her paper Burgiel admits that her upper bound is loose, and she estimates that it really takes only a little over a thousand alternating S and Z pieces to kill a player, not a hundred thousand or more.

Random pieces: sooner or later, the bad run comes

A real game does not deliberately alternate S and Z. The second half of Burgiel's paper takes on random pieces.

Theorem 4Almost every game ends (Burgiel, 1997)

In a 10 × 20 well, if each piece is drawn independently at random, and S and Z each have positive probability, then the game ends with probability 1.

ProofFirst, a fact: from any board, a long enough run of alternating S and Z will kill the player (the length Burgiel gives is about 127,000 pieces). Call this length . Cut the sequence of pieces into segments of pieces each. Each segment is exactly “S, Z, S, Z, …” with the same probability , and different segments are independent. The probability that none of the first segments is this run is , which tends to 0 as . So with probability 1 some segment is eventually this run, and the game ends within that segment at the latest. ∎

This is the same idea as the monkey at the typewriter: if every keystroke is random, any finite piece of text will turn up sooner or later. But how long do we have to wait this time? With the seven pieces dealt uniformly, the chance that a given segment is exactly this run is about , roughly 10 to the power −100,000. At one piece per second, the expected wait is many times the age of the universe, and that multiple itself has more than 100,000 digits.

So in practice the theorem poses no threat at all. Its point lies elsewhere: certain death can be a theorem about probability, with nothing to do with how fast your fingers are.

The NES randomizer is not independent. According to players who have taken its code apart, it first rolls a number from 0 to 7; if it rolls 7, or the same piece as last time, it rolls once more from 0 to 6. So the chance of getting the same piece twice in a row is only about 1/28. But the chances of going from S to Z and from Z to S are both positive, so the same argument goes through in its Markov-chain version. Had Blue Scuti's game never crashed, in theory he could not have escaped either.

The designers' cure: the 7-bag

Official Tetris today no longer deals pieces independently. The randomizer in the official rules (the Tetris Guideline) is called the Random Generator, and players call it the “7-bag”: put the seven pieces in a bag, deal them out in shuffled order, and when the bag is empty, fill the next one.

Theorem 5Two guarantees of the 7-bag

Under the 7-bag, a run of consecutive S and Z pieces (in any order) is at most 4 long, and at most 12 pieces come between two I pieces. Both bounds can be reached.

ProofA bag holds 7 pieces, so any 5 consecutive pieces span at most two bags. Two bags hold only 2 S and 2 Z between them, so a run of S and Z is at most 4 long; a bag ending in S, Z followed by a bag starting with Z, S gives exactly 4. After an I, at most 6 pieces remain in its bag, and the I in the next bag comes 7th at the latest, so at most pieces lie between them. ∎

Independent randomIOOJTLIJOTITJLJSZSSZSTJSZLJI6 S/Z in a row16 pieces between two I's7-bagIOLJTSZSZLJOTITLSOIZJZLJOTIS4 S/Z in a row12 pieces between two I's
Figure 9Top: 28 pieces dealt independently at random; S and Z form a long run, and I is a long time coming. Bottom: 28 pieces from the 7-bag (4 bags), with vertical lines marking the bag boundaries. Both sequences were generated at random by a program (for illustration).

A run of at most 4 S and Z pieces is nowhere near the hundred thousand or more it takes to kill a player. The 7-bag removes the premise of Theorem 4 entirely. The player community has worked out a looping strategy (see Tetris Wiki): with Hold and at least 3 pieces of preview, you can play forever. It is a players' construction and has not been peer reviewed, but it points the same way as the theorems above.

This is a design trade-off. Independent randomness is the most “fair,” but bad luck has no ceiling; the 7-bag gives up a little randomness in exchange for a ceiling on bad luck. Long runs of S and Z never come, and you will never wait until the end of time for an I.

Hard even when you know every piece

So far the question has been whether you can play forever. There is another way to ask it: if you are told the starting board and every piece to come in advance, can you find the best way to place them?

Theorem 6The offline version is NP-complete (Demaine et al., 2003)

Given the starting board and the whole sequence of pieces, deciding whether a given number of lines can be cleared, and deciding whether all the pieces can be placed without losing, are both NP-complete problems.

This is a 2003 result of Erik Demaine, Susan Hohenberger and David Liben-Nowell. The proof is a reduction from a problem known to be hard: 3-Partition. You are given positive integers and a target , and asked whether they can be split into groups of three, with every group summing to exactly . For example, given 6, 6, 8, 7, 7, 6 and the target 20, the answer is {6, 6, 8} and {7, 7, 6}. Once there are many numbers, nobody knows a method much faster than trying the possibilities one by one.

The board they build has “buckets” of equal depth, with a “lock” at the far right. Each number is translated into a fixed string of pieces, and the string leaves no unfillable gap only if the whole of it goes into a single bucket. Once it is in, that bucket's contents rise by about rows. The lock opens only at the very end: only if all the buckets are exactly the same height can the final string of pieces (mostly vertical I's) clear the entire board. So the board can be cleared if and only if the numbers can be grouped in threes, each group adding up to .

Bucket 1Bucket 2Bucket 3LockLock opens only if all 3 are levelEach aᵢ → 5aᵢ + 5 pieces, all in one bucketGray cells are there at the start; pieces fill the rest
Figure 10The board in the reduction (schematic, drawn after the paper's construction, with fewer rows). Each bucket is 6 columns wide, with a notch every six rows in columns 4 and 5; the three columns on the right are the lock. Three numbers go into each bucket, and only when all the buckets are the same height can the final vertical bars clear all the way to the bottom.

The hardness here is a different thing from the certain death earlier. There, you don't choose the pieces, and no amount of cleverness saves you; here, every piece is laid out in front of you, yet finding the right placement may mean trying exponentially many possibilities. In 2020, Sualeh Asif, Erik Demaine and five coauthors narrowed the result further: with a well only 8 columns wide, or only 4 rows high, the problem is still NP-complete; only with 2 columns can it be solved in polynomial time.

In closing

Looking back, certain death in Tetris comes in three levels. In an odd-width well, a single coloring seals your fate. In the 10-column well, it takes a column ledger, five lanes and a little patience. In wells 8 or 12 columns wide, alternating S and Z cannot kill you at all. It is the same game, and whether you live or die depends on the remainder when the width of the well is divided by 4.

The certain-death theorems are a long way from the real game. The run of pieces you would have to wait for will not arrive in the lifetime of the universe; what comes first is the ever-faster fall of the pieces, and that crash at level 157. The theorems and game design ran into the same problem: the bad luck of independent randomness has no ceiling. Today's official randomizer was designed precisely so that bad luck has one.

Tetris has been around for more than forty years, and mathematicians long ago worked out that it cannot be won. Players keep playing, one game after another.

Whether you live has nothing to do with speed,
and everything to do with the well's width mod 4.
Let's talk in the comments

How many lines have you lasted in your best game of Tetris? And do you think the 7-bag counts as a kind of “cheating”?

References
  1. J. Brzustowski (1992), Can you win at Tetris? Master's thesis, University of British Columbia
  2. H. Burgiel (1997), How to lose at Tetris, The Mathematical Gazette 81(491): 194–200
  3. K. M. Tsuruda (2010), A closer look at Tetris: analysis of a variant game, Atlantic Electronic Journal of Mathematics 4(1): 23–34 (includes an account of the results of Brzustowski's thesis)
  4. E. D. Demaine, S. Hohenberger, D. Liben-Nowell (2003), Tetris is hard, even to approximate, COCOON 2003: 351–363; arXiv: cs/0210020
  5. S. Asif, M. Coulombe, E. D. Demaine, M. L. Demaine, A. Hesterberg, J. Lynch, M. Singhal (2020), Tetris is NP-hard even with O(1) rows or columns, Journal of Information Processing 28: 942–958
  6. Tetris Wiki, the entries Random Generator, Playing forever and Tetris (NES) (accessed October 14, 2026)
  7. Associated Press report on Willis Gibson, January 2024 (republished by PBS NewsHour and others)
Note: all illustrations are schematics made for this essay. The data in Figures 1, 6, 7, 8 and 9 come from programs I wrote for it.
犹剑在心
北极甜虾(剑心犹在!)
— The End —

← All essays