Tetris had to cheat to feel random
Tetris Had to Cheat to Feel Random The game of Tetris is more than just iconic falling blocks. It is a textbook example of how our perception of randomness...
Tetris Had to Cheat to Feel Random
The game of Tetris is more than just iconic falling blocks. It is a textbook example of how our perception of randomness diverges from mathematical reality. The developers of the original game faced a paradox: a truly random piece generator (Random Number Generator, RNG) created a gameplay experience that felt unfair and frustrating. Players complained about long series of identical pieces, even though, from a statistical standpoint, such sequences are inevitable in pure randomness. For the game to remain engaging and fair from a human perception standpoint, Tetris had to \\\"cheat.\\\"
Why Does Our Intuition Hate True Randomness?
The key problem, described in the UX Collective article, is formulated as follows: \\\"No one can see a probability distribution. You only see a sequence, and with sequences, human intuition fails.\\\"
The Developer\\\'s Dilemma
Imagine a fair seven-sided die (yes, for the seven types of tetrominoes). The probability of any specific piece appearing on each roll is constant and equals 1/7. This means sequences like I, I, I, I or S, S, Z, Z will periodically appear. For a computer, this is normal. For a player, it\\\'s a catastrophe.
Example of a truly random sequence (pseudocode):
import random
tetrominoes = [\\\\\\\'I\\\\\\\', \\\\\\\'O\\\\\\\', \\\\\\\'T\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'J\\\\\\\', \\\\\\\'L\\\\\\\']
sequence = [random.choice(tetrominoes) for _ in range(20)]
print(sequence)
# Possible, though unlikely, output:
# [\\\\\\\'Z\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'I\\\\\\\', \\\\\\\'O\\\\\\\', \\\\\\\'T\\\\\\\', \\\\\\\'L\\\\\\\', \\\\\\\'L\\\\\\\', \\\\\\\'L\\\\\\\', \\\\\\\'J\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'T\\\\\\\', \\\\\\\'T\\\\\\\']
Such \\\"clusters\\\" of pieces break the gameplay, depriving the player of the ability to build a long-term strategy and creating a feeling of uncontrollable fatalism.
The Psychology of Perception
The human brain evolved to find patterns. When we see four \\\'Z\\\' pieces in a row, we instinctively suspect a system error, a glitch, or unfairness, even though this is a valid outcome of a random process. We expect an even \\\"shuffling,\\\" which simply does not exist in true randomness. Therefore, in UX, especially in game design, it is often necessary to replace true randomness with controlled randomness—the kind that feels more random to a person.
The Mechanics of \\\"Cheating\\\": The Bag Randomizer
To solve this problem, most modern versions of Tetris use an algorithm known as the \\\"7-bag\\\" or \\\"bag randomizer.\\\" This is a prime example of procedural fairness in design.
How Does the Algorithm Work?
- All seven unique tetrominoes are placed into a \\\"bag.\\\"
- Pieces are randomly drawn from the bag without replacement, forming a sequence of seven elements.
- When the bag is empty, it is refilled with all seven pieces, and the process repeats.
This guarantees that:
- In any series of 7 pieces, each tetromino will appear exactly once.
- Two identical pieces ca
ot appear consecutively (within a single bag).
- Long series (more than 2) of the same piece are completely eliminated.
Python implementation example:
import random
class BagRandomizer:
def __init__(self):
self.bag = []
self.refill_bag()
def refill_bag(self):
self.bag = [\\\\\\\'I\\\\\\\', \\\\\\\'O\\\\\\\', \\\\\\\'T\\\\\\\', \\\\\\\'S\\\\\\\', \\\\\\\'Z\\\\\\\', \\\\\\\'J\\\\\\\', \\\\\\\'L\\\\\\\']
random.shuffle(self.bag)
def next_piece(self):
if not self.bag:
self.refill_bag()
return self.bag.pop()
# Usage
generator = BagRandomizer()
sequence = [generator.next_piece() for _ in range(14)]
print(\\\\\\\"First 14 pieces:\\\\\\\", sequence)
# Output guarantees balance: each of the first 7 and second 7 pieces contains all types.
Advantages of the Approach
- Short-term predictability: The player knows that if an \\\'I\\\' piece just appeared, the next \\\'I\\\' won\\\'t come for at least 6 moves.
- **Strategic pla
ing:** Understanding the mechanics allows experienced players to better predict and prepare.
- Elimination of frustration: Game-breaking sequences that cause a sense of unfairness disappear.
Other Methods for Controlling Randomness in Games
The bag randomizer is not the only method. Game designers have other techniques in their arsenal:
1. History or \\\"No-Repeat Rule\\\"
The algorithm remembers the last N spawned items and temporarily reduces the probability of their reappearance.
class HistoryRandomizer:
def __init__(self, pieces, history_depth=4):
self.pieces = pieces
self.history = []
self.depth = history_depth
def next_piece(self):
# Filter out those that recently appeared
available = [p for p in self.pieces if p not in self.history]
if not available:
available = self.pieces
choice = random.choice(available)
# Update history
self.history.append(choice)
if len(self.history) > self.depth:
self.history.pop(0)
return choice
2. Weighted Probabilities and Dynamic Adjustment
The probability of a piece appearing can change depending on the game situation, board state, or score to maintain tension.
3. Deterministic Pseudorandomness
Using predetermined sequences that are difficult for the player to calculate (e.g., based on a seed), ensuring repeatability and fairness in competitive modes.
Practical Tips for Designers and Developers
- First, understand user expectations. What does \\\"randomness\\\" mean for your product? Fast content rotation, fairness in gameplay, plot unpredictability?
- Test perception, not just statistics. Show sequences generated by different algorithms to focus groups and ask which one seems \\\"more random.\\\"
- Use controlled randomness to improve UX. As in Tetris, it can reduce frustration and increase engagement.
- Don\\\'t be afraid to \\\"cheat\\\" for the user\\\'s enjoyment. The goal is to create a positive experience, not to strictly follow mathematical laws.
- Be transparent if appropriate. In some competitive games, knowing the algorithm (like in Tetris) becomes part of the skill.
- Document your RNG system. This is important for balancing, testing, and future refinements.
- Consider hybrid approaches. For example, a \\\"bag\\\" with a small element of true randomness when refilling it.
Conclusion: Randomness as a Design Tool
The history of Tetris is a lesson in human-centered design. It shows that effective UX often requires not blind adherence to technical or mathematical ideals, but an understanding of user psychology. True randomness can be the enemy of a good user experience. Tetris\\\'s \\\"cheating\\\" is actually a fine-tuning that turns an abstract mathematical concept into a tangible, enjoyable, and fair gameplay sensation. Ultimately, the best randomness is the kind the user doesn\\\'t notice, but which makes interacting with the product comfortable and engaging.
The next time you design a recommendation system, a level generator, or any other system that requires an element of unpredictability, remember the seven-piece bag. Ask yourself: are you creating a perfect probability distribution or a perfect experience?