Tetris 7-bag: the piece queue that makes droughts impossible
A generator described as random contains one hard guarantee: you will never wait more than 12 pieces for an I. That guarantee falls out of how the bag is built, and a loop can falsify it. The artefact is a published probability. The tool is arithmetic.
Independent guide. We did not decompile a Tetris build. We read the documented algorithm, rebuilt it, and measured it. Piece distribution in any specific game may differ — the harness is how you check.
Findings
From TetrisWiki's Random Generator, revision oldid=26147, retrieved 18 Oct 2026. The hedge in the source is kept.
| Claim | Source wording | Confidence | What it does not prove |
|---|---|---|---|
| All seven pieces appear in every bag | a sequence of all seven tetrominoes (I, J, L, O, S, T, Z) "as if the pieces were drawn from a bag" | High | — |
| Bag is refilled after each seven | "The resulting sequence … is added to the queue, and another bag is then generated" | High | — |
| 5,040 possible orderings | "There are 7!, or 5,040, permutations of seven elements" | High | — |
| Each ordering near-equally likely | "it is believed that Tetris assigns a nearly equal probability" — the hedge is in the source | Medium | Not a measured property of any specific build |
| Max 12 pieces between one I and the next | "a run of no more than 12 tetrominoes in between one I tetromino and the next" | High | — |
| Snake runs capped at 4 | "S and Z tetrominoes can only occur in runs of no more than 4" | High | — |
| Four consecutive snakes must alternate | only SZSZ and ZSZS occur, out of sixteen combinations | High | — |
| P(next four are SZSZ or ZSZS) = 1/3087 | stated outright | High | That your game's generator is this one |
| P(any three consecutive are all snakes) = 1/257 | stated outright, and checked below | High | Same caveat |
| Origin: bag of 63, not 7 | developed for The New Tetris, with all nine of each type in one bag | High | — |
| It is a Guideline feature | used in Tetris-branded games that follow the Tetris Guideline | High | — |
| A known exception exists | the first tetromino of the first bag in Tetris: The Grand Master Ace is always one of I, J, L, T | High | Whether other games apply the same restriction |
Why 12
Worst case: an I is the first piece of one bag and the last piece of the next. After that first I come the other 6 pieces of its bag, then 6 pieces of the following bag before its I. Pieces between the two Is: 6 + 6 = 12. A uniform generator has no ceiling. The probability of a gap of length g is (6/7)^g, so a 12-piece drought is ordinary under flat random. The bag makes that tail impossible.
Both generators are written from the two descriptions. If the bag column exceeds 12, the reading of the source is wrong.
press Run bothPublished probability check. The source says 1/257 ≈ 0.389% for three consecutive snakes.
run above firstThe rule, in pseudocode
bag = []
function next_piece():
if bag is empty:
bag = shuffled([I, J, L, O, S, T, Z])
return pop_front(bag)
function next_piece_naive():
return uniform_choice([I, J, L, O, S, T, Z])Two properties a recording can check: the queue is self-limiting (a run of the same piece needs a new bag), and it is not memoryless. Knowing the last six pieces can name the seventh. A generator with that property is detectable from seven pieces, with no access to a binary.
Try it yourself
I have a recording of piece sequences from a game, one line per piece.
Do not guess which generator it uses. Determine from the data: whether
each window of seven contains all seven pieces, the longest gap between
any two I pieces, and the longest run of S/Z. Report the observed
numbers, then say which generator model they are consistent with and
which they rule out.What we could not confirm. Which games ship this generator, the shuffle implementation (Fisher–Yates or something weaker), and whether the queue's preview count is the 5 shown in most Guideline titles. The 1/257 check estimates over overlapping triples, which is not the only reading of the published wording. If your number lands near 1/257 on one reading and not the other, that discrepancy is the finding.
Next
2048: a 90/10 line
One ternary, and a merge guard most retellings get wrong.
Read it →MethodRead a distribution without a binary
Steps 1 and 3 of the loop, applied to a recording of seven pieces.
The 6-step loop →LayerLayer choice decides cost
This one was read from documentation and simulation. The dino was read from a file.
REA vs Ghidra →