Key Moments
The Nerds Who Beat Slot Machines With Math
Key Moments
A Russian hacker group exploited slot machine RNGs to win millions, proving that even complex pseudo-random number generators are predictable and exploitable, highlighting the need for truly random sources for digital security.
Key Insights
In the 1940s, Stanislaw Ulam developed the Monte Carlo method using random number simulations to estimate complex problems like nuclear chain reactions, replacing tedious analytical calculations.
John von Neumann's proposed method for generating pseudo-random numbers by squaring a seed and taking the middle digits led to predictable loops, with nearly two-thirds of four-digit seeds entering one of only eight traps.
Linear Congruential Generators (LCGs), used in early software like IBM's Randu and Java, produce sequences that appear random but exhibit patterns like parallel planes in 3D space, making them exploitable.
A Russian hacker group, led by 'Alex,' reverse-engineered the Mersenne Twister algorithm used in slot machines, predicting winning spins by analyzing video feeds and timing player inputs with a quarter-second delay app.
The NIST is developing true random number generators based on quantum mechanics, specifically exploiting the inherent unpredictability of entangled photon polarization measurements, to create certifiably random bits.
Even quantum experiments require pseudo-randomness (e.g., random number generators to select measurement angles) to 'purify' or 'certify' the ultimate randomness derived from quantum phenomena like Bell test violations.
Casino exploits reveal flaws in slot machine randomness
The video opens with a striking anecdote of gamblers exploiting slot machines for significant winnings. At multiple casinos, players would play for a short period, leave, and return later to win consistently. Security footage revealed they weren't playing randomly; instead, they would hover over the spin button and press at precise moments. This behavior suggested a predictability in the machines' outcomes, which are determined by computer algorithms. The seemingly simple question of whether these computer-generated numbers are truly random connects to fundamental concepts in physics, computing, and digital security, as casinos theoretically rely on random number generators (RNGs) for fair play.
The Monte Carlo method: Simulating randomness for complex problems
The pursuit of randomness has roots in complex scientific challenges. During the Manhattan Project in the 1940s, mathematicians like Stanislaw Ulam faced the immense difficulty of calculating the behavior of neutrons in nuclear chain reactions. Ulam, recovering from encephalitis, realized that instead of analytical calculations, he could simulate the process. By using random numbers to represent the probabilistic outcomes of neutron interactions (e.g., bouncing off, causing fission, or being absorbed), he could track millions of simulated neutrons. This approach, later named the Monte Carlo method, allowed scientists to estimate the overall behavior of the chain reaction, demonstrating the power of simulation when direct calculation is intractable. This method became a cornerstone of scientific computing.
Early pseudo-random number generators: Predictable loops and patterns
The need for random numbers quickly led to the development of computer algorithms. John von Neumann, working with the ENIAC computer, devised a method to generate pseudo-random numbers: take a 'seed' number, square it, and extract the middle digits. However, this 'middle-square' method proved problematic. Many sequences quickly fell into short, repeating loops. For instance, using four-digit seeds, nearly two-thirds eventually entered one of just eight repeating cycles. Even with larger numbers or different methods like Linear Congruential Generators (LCGs), which use modular arithmetic (e.g., `next = (multiplier * current + increment) mod modulus`), predictability remained a challenge. LCGs, while capable of producing long sequences (like Java's, which repeats after over 281 trillion steps), exhibit underlying linear relationships. When plotted in 3D, their outputs reveal patterns of parallel planes, indicating gaps where random points would never appear, and making them exploitable.
Exploiting Minecraft's LCG for predictable diamonds
The predictability of LCGs was demonstrated in a practical, albeit recreational, example: Minecraft. In many versions of the game, the placement of resources like diamonds is determined by an LCG. A mathematician named Matthew Bolan discovered that by knowing the location of a clay patch (which is generated using a related seed), he could predict the location of nearby diamond veins. This was because the game used the same underlying seed for different resource types but added small, fixed offsets. Since these seeds went through the same LCG, their outputs were correlated. Furthermore, Java's LCG implementation revealed 32 of its 48 internal bits with each output. This partial reveal allowed knowledgeable players to determine the full internal state and predict all subsequent numbers, making resource locations predictable and exploitable.
The Mersenne Twister and sophisticated casino hacks
The slot machine exploits described at the beginning of the video involved a more sophisticated RNG than simple LCGs: the Mersenne Twister. This algorithm uses a large internal state (624 numbers) and a complex 'twist' operation to generate sequences that can be astronomically long (repeating after over 10^6000 steps). Despite its complexity, it is still deterministic. A Russian hacker group, led by an individual known as 'Alex,' reverse-engineered the Mersenne Twister used in many slot machines. By analyzing video feeds of spins transmitted from casinos, they could correlate the outcomes with their own machines and predict future winning spins. To overcome the human reaction time delay (about 0.25 seconds), they developed an app that would vibrate the gambler's phone precisely a quarter-second before the optimal moment to press the spin button, enabling substantial winnings.
Towards cryptographic security: Predictable seeds vs. unpredictable keys
The vulnerability of pseudo-random number generators (PRNGs) to predictability is a critical issue for digital security, affecting everything from online banking to encrypted communications. Cryptographers address this by using encryption algorithms themselves to generate random numbers. Instead of a predictable seed, these methods use a secret, large random number called a 'key.' The encryption process scrambles the input numbers, making the output appear random. Even if an attacker knows the algorithm and has seen many inputs and outputs, they cannot practically recover the secret key without brute-forcing it, which is computationally infeasible for keys like 128-bit ones (over 300 trillion possibilities). This solves the predictability problem, but it raises the question: where does the initial random 'seed' or 'key' come from?
True randomness from quantum mechanics: The NIST experiment
The ultimate source of randomness, according to modern physics, lies in quantum mechanics. The National Institute of Standards and Technology (NIST) is developing true random number generators (TRNGs) based on quantum phenomena. One experiment uses entangled photons – pairs of light particles whose states are linked, regardless of distance. When these photons interact with a crystal, they can be produced in a superposition of horizontal and vertical polarization. Researchers use a quantum entanglement experiment (a Bell test) to measure these photons. The outcomes of these quantum measurements are fundamentally unpredictable. While the choice of measurement angles still requires good pseudo-randomness, the measured results (detection or no detection, translating to 1s and 0s) violate Bell's inequality, proving they are not predetermined by any local hidden variables. This demonstrates genuine unpredictability at a fundamental level.
Certifying unpredictability: Extracting randomness from quantum events
While quantum experiments like Bell tests demonstrate true unpredictability, the raw outcomes aren't always a perfect, balanced stream of random bits. For example, there might be more 'zeros' than 'ones'. To address this, techniques like 'randomness extraction' are employed. Similar to a method proposed by von Neumann using coin flips (e.g., 'Heads-Tails' becomes '0', 'Tails-Heads' becomes '1', matching results are discarded), these methods distill genuine unpredictability from noisy, quantum-derived data. NIST's process can certify at least 820 bits of unpredictability from raw measurements and concentrate it into 512 certified random bits. This certified randomness, unlike pseudo-random numbers, is provably unpredictable, offering the highest level of security for critical applications like encryption and securing the internet itself. It fundamentally challenges the deterministic worldview of classical physics, confirming that 'God does play dice with the universe'.
Mentioned in This Episode
●Supplements
●Software & Apps
●Companies
●Organizations
●Concepts
●People Referenced
Pseudo-Random Number Generator Challenges
Data extracted from this episode
| Challenge | Description | Generator Type Affected |
|---|---|---|
| Short Loops | Sequences can get stuck in repeating cycles. | LCGs (e.g., Von Neumann's method) |
| Hidden Patterns | Sequences may appear random but contain underlying patterns. | LCGs, Mersenne Twister |
| Predictability | Knowing the seed or internal state allows prediction of future numbers. | LCGs, Mersenne Twister |
Common Questions
Hackers in Russia reverse-engineered the Mersenne Twister algorithm used in slot machines. They developed an app that transmitted spin outcomes and predicted winning times, guiding gamblers to press the spin button at precise moments.
Topics
Mentioned in this video
A casino in St. Louis where a man used a phone to record slot machine spins and later returned to win significantly.
A sponsor of the video, offering an all-in-one platform for building websites and web applications, with AI-powered tools and Black Friday offers.
A company that uses a wall of lava lamps to generate random seeds for its algorithms.
A type of pseudo-random number generator that uses a simple linear relationship with modular arithmetic. Examples include Randu and Java's LCG used in Minecraft.
The programming language whose LCG was historically used in Minecraft for resource generation, leading to predictability exploits.
A more complex pseudo-random number generator used in many slot machines, which was reverse-engineered by hackers to predict outcomes.
An early LCG developed by IBM, known for its predictable patterns when plotting outputs in 3D space.
A website published by NIST and the University of Colorado Boulder that provides access to verifiable random numbers generated from quantum experiments.
A collaborator who proposed using distant quasars to choose measurement angles in quantum randomness experiments, pushing back the 'freedom of choice' loophole.
A mathematician and advisor at Los Alamos who collaborated with Ulam and utilized early computers like ENIAC to implement the Monte Carlo method for nuclear simulations.
A Minecraft expert and PhD student who explained how LCGs were used in the game to determine diamond placement and how this exploit could be discovered.
A card game Ulam played extensively in the hospital, which sparked his idea of simulating outcomes to understand probabilities.
A video game used as an example to illustrate the predictability of Linear Congruential Generators (LCGs) in determining resource placement, which was later patched.
A science and technology trivia game launched by Veritassium, featuring a confidence mechanic.
A computational technique developed by Ulam and von Neumann that uses random sampling to obtain numerical results, particularly useful for simulating complex systems like nuclear chain reactions.
A mathematical inequality that sets a limit on the correlations between measurements in local realistic theories. Violations of this inequality in quantum experiments suggest genuine unpredictability.
A thought experiment used to illustrate quantum superposition, comparing it to the quantum state of entangled photons.
More from Veritasium
View all 109 summaries
66 minThe Closest Thing We Have to Alien Matter
35 minNo device could prove our theory of gravity wrong... until now
35 minHow We Trapped Light and Built the Internet
48 minThe Most Important Decryption Machine Ever Built
Ask anything from this episode.
Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.
Get Started Free