1. Home
  2. Explore
  3. Business
  4. Slot Machine Gambling Investigation

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Slot Machine Gambling Investigation

Randomness, Pseudorandom Generators, and Quantum Unpredictability

What “random” means

A process is often called random when its outcomes are difficult to predict. However, unpredictability is not the same as apparent disorder: a sequence can look irregular while still being generated by a rule that makes its future outputs predictable.

Computers commonly use pseudorandom numbers. These numbers are produced by a deterministic algorithm, usually from an initial value called a seed. If the same algorithm starts with the same seed, it generates the same sequence. Pseudorandom numbers can be useful for simulations and games, but their deterministic structure can create problems when the numbers must be unpredictable to an attacker.

The practical importance of randomness ranges widely:

  • Scientific simulations use random sampling to estimate outcomes that would be too difficult to calculate directly.

  • Games use random numbers to place objects or choose events.

  • Digital security relies on unpredictable numbers for tasks such as protecting messages and accounts.

  • Quantum experiments can produce outcomes whose unpredictability can be tested under specific physical assumptions.


Monte Carlo simulation and the nuclear chain-reaction problem

Why neutron behavior was difficult to calculate

In a uranium-235 nuclear chain reaction, a neutron can collide with a uranium-235 nucleus and cause it to split. This releases energy and typically two or three more neutrons. If each split causes, on average, more than one further split, the number of reactions can grow into a runaway chain reaction.

What happens depends on the paths of individual neutrons. A neutron might travel different distances, bounce off a nucleus, be absorbed, or trigger a split. The probability of each event depends on conditions such as the neutron’s speed and the material it passes through. Even if the probabilities of individual events are known, calculating every possible path across trillions of neutrons is impractical.

Ulam’s statistical insight

Mathematician Stanislaw Ulam considered how to estimate the odds of winning a game of solitaire. A 52-card deck has 52!52!52! possible arrangements—about 8×10678 \times 10^{67}8×1067—so calculating the outcome of every shuffle would be unmanageable.

Ulam realized that an estimate could instead come from repeated trials:

  1. Play a sample of games.

  2. Count how many are won.

  3. Use the observed proportion to estimate the overall chance of winning.

For example, if 8 out of 100 trials are wins, the estimated win rate is about 8%. The estimate is not an exact calculation over every possibility, but it can be useful if the sample is sufficiently representative.

Ulam applied the same idea to neutrons. Rather than calculate every possible path, researchers could simulate a sample of neutron histories. At each interaction, a random number would select an outcome according to the measured probabilities. For example, a simplified model might assign some random-number results to bouncing, some to causing a split, and others to absorption. In realistic simulations, the probabilities would be based on measurements and would change as a neutron’s speed and direction changed.

The simulation then follows both the original neutron and any new neutrons it produces. If the number of neutrons tends to grow, the chain reaction takes off; if more neutrons are lost than produced, it dies out. Monte Carlo simulation uses random sampling to estimate the behavior of a complicated system without exhaustively calculating every possible outcome.

The ENIAC and early random-number generation

Carrying out these simulations by hand would have been too slow. John von Neumann worked out how the ENIAC, one of the early electronic computers, could follow neutron histories through many collisions. The computer needed a large supply of random numbers, but it could not roll dice, and it lacked enough memory to store all the required random digits from a book.

Von Neumann therefore devised an arithmetic procedure for generating numbers inside the computer. This led to a crucial distinction:

Pseudorandom numbers are generated by a deterministic process. They may be useful for simulation, but they are not inherently unpredictable.

The neutron simulations helped establish the Monte Carlo method as an important tool in statistics and scientific computing. Their usefulness did not require perfectly random numbers; it required sequences that were suitable for the calculation.


The middle-square method: an early pseudorandom generator

Von Neumann’s simple method for generating numbers illustrates both the appeal and the weaknesses of pseudorandom generation.

To generate four-digit values:

  1. Choose a four-digit seed, such as 2,137.

  2. Square it: 2,1372=4,566,7692{,}137^2 = 4{,}566{,}7692,1372=4,566,769.

  3. Take the four middle digits, inserting leading zeroes if necessary to make the number the expected length. The next value is 5,667.

  4. Square that value and again keep the middle four digits.

  5. Repeat the process.

The method is called the middle-square method because each new value is taken from the middle of the previous value’s square. The middle digits can depend on several digits of the seed, which may make the results seem less obviously patterned than simply reusing the seed’s last digits.

However, the method has severe weaknesses:

  • Some starting values lead to short repeating cycles. For example, one sequence eventually repeats four values: 4,100, 8,100, 6,100, and 2,100.

  • Some seeds eventually reach zero. Once the output is zero, every later output is also zero.

  • For the four-digit version described, every possible starting value eventually falls into one of only eight traps.

Using longer numbers can delay repetition, but it does not remove the underlying problem. A generator that appears irregular for a while may still eventually repeat, often in a short or otherwise undesirable cycle.

Von Neumann’s early simulations used eight-digit numbers and statistically checked the first 2,000 values. To reduce the risk of encountering an unexpected cycle, the ENIAC was programmed to restart from the original seed after using that checked sequence. The method demonstrated that simulated random sampling could work, while also showing why the quality of a number generator matters.


Linear congruential generators

How modular arithmetic produces a sequence

A linear congruential generator, or LCG, uses a simple rule to calculate each new value from the current one:

xn+1=(axn+c) mod mx_{n+1} = (a x_n + c) \bmod mxn+1​=(axn​+c)modm

Here:

  • xnx_nxn​ is the current value.

  • xn+1x_{n+1}xn+1​ is the next value.

  • aaa is a multiplier.

  • ccc is an added constant.

  • mmm is the modulus.

The operation “mod mmm” keeps the remainder after division by mmm, making the values wrap around within a fixed range. For instance, repeatedly multiplying by 3 modulo 7 gives the cycle:

1→3→2→6→4→5→11 \rightarrow 3 \rightarrow 2 \rightarrow 6 \rightarrow 4 \rightarrow 5 \rightarrow 11→3→2→6→4→5→1

The sequence visits every nonzero value before repeating. With much larger parameters, an LCG can generate a very long sequence before it repeats. But a long period does not guarantee good randomness.

Hidden patterns in RANDU

IBM’s RANDU generator was used in scientific applications, including simulations related to radioactive decay and equipment aboard NASA’s Skylab space station. It could produce more than half a billion values before repeating, but its outputs had a serious structural defect.

Consider groups of three consecutive outputs as coordinates in three-dimensional space. If the values were independent and well distributed, the resulting points would be expected to fill the cube in a roughly cloud-like pattern. RANDU’s points instead lie on just 15 parallel planes, leaving large gaps where points never appear.

This happens because the numbers are linked by the same linear rule: the second depends linearly on the first, and the third depends linearly on the second. The three values therefore satisfy a linear relationship. In three-dimensional space, a linear relationship describes a plane; the modular operation produces a set of parallel planes. RANDU’s particular parameter choices made this weakness especially visible.

Other LCGs can have much better distributions. For example, Java adopted an LCG with a better multiplier, an added constant, and a much larger modulus. Its sequence takes more than 281 trillion steps to repeat. Its points look much more like a random cloud because the planes are packed very closely together. Nevertheless, the underlying linear structure remains.

A sequence can have a long period and look random from many viewpoints while still containing mathematical relationships that make it unsuitable for some purposes.


Exploiting related random values in Minecraft

Chunks and resource placement

Minecraft worlds are divided into chunks, each measuring 16×1616 \times 1616×16 blocks horizontally in the XXX and ZZZ directions. In the game version described, a chunk can contain at most one vein of diamond ore, placed underground by the game’s pseudorandom-generation system.

The game also uses pseudorandom values to place other resources, including clay and gravel. In some versions, resource placement relied on Java’s LCG. The game did not start each resource’s placement from a completely independent seed. Instead, it used the world’s underlying seed and added a different fixed value for each resource.

The starting values for diamonds and river clay differed by only a small amount. Java modified those values before using them, so the difference was not always exactly the same, but it often fell into a limited set of predictable possibilities. Because both resources were then processed by the same LCG, their outputs were related.

Why a clay patch could reveal diamonds

If two resource-placement sequences share the same underlying unknown seed, comparing their results can cause the shared unknown part to cancel. As a result, learning the position of a clay patch could provide enough information to infer where the diamond vein was likely to be.

The method used in the game version described was therefore not a matter of spotting diamonds directly; it exploited correlations between outputs that were supposed to look unrelated. The random-number generator’s structure made information about one resource useful for predicting another.

This is an example of how a generator can be adequate for ordinary game play yet vulnerable when someone studies the implementation closely. The exploit was patched out: in version 1.18, Minecraft changed the random-number generator used for ore generation, removing the particular weakness that the method relied on.


Why LCGs are predictable

Java’s LCG maintained an internal state consisting of 48 binary digits. When it generated an integer output, the output revealed 32 of those digits, leaving only 16 hidden. There are 216=65,5362^{16} = 65{,}536216=65,536 possible values for those hidden digits. A computer can test these candidates against the next observed output; only one candidate matches, revealing the internal state.

Once the internal state is known, the deterministic algorithm can calculate the future sequence. The central weakness is not necessarily that the sequence repeats quickly or looks patterned; it is that observed outputs can reveal enough of the generator’s hidden state to predict what comes next.

This illustrates three general problems with pseudorandom generators:

  1. Short cycles: a sequence may repeat much sooner than intended.

  2. Statistical patterns: outputs may look random in simple tests but contain hidden correlations.

  3. Predictability: outputs may reveal the seed or internal state, allowing future values to be calculated.

These risks matter especially when a generator is used for security or for outcomes that people might try to exploit.


Predicting slot-machine outcomes

The attack’s basic mechanism

The slot-machine attack described exploited the fact that a machine’s outcome was determined by a pseudorandom generator inside the machine. A Russian team obtained machines that had been sold after gambling was banned in Russia and reverse-engineered their software and hardware.

Many of the machines used the Mersenne Twister algorithm. Unlike the simpler LCGs, the Mersenne Twister maintains a table of 624 values. It applies a transformation called a twist to produce a new table, then processes the values to produce outputs. The process has an extremely long sequence before repetition, but it still follows fixed mathematical rules.

The attack did not require the gamblers to predict outcomes by sight. The reverse-engineered machines let the team compare observed play with the generator’s behavior and estimate when a winning outcome was likely. The machine continued generating values even when nobody was playing. The outcome depended on which value was selected at the instant the player pressed the spin button.

Timing and remote coordination

A human takes roughly a quarter of a second to react, which makes it difficult to press a button at the exact required moment after receiving an instruction. The team compensated for this delay with a phone app that vibrated shortly before the player needed to press.

Players recorded spins, and the video was transmitted to a server for analysis. The analysis helped determine when to return to a machine and when to press the button. The method did not guarantee a win on every spin, but the coordinated team could win substantial sums.

This case demonstrates that a generator’s complexity and long period do not make it secure if its rules can be reverse-engineered and its outputs or timing can be observed. A generator designed for ordinary game operation may not be appropriate for an adversarial environment.


Cryptographically secure pseudorandom generation

Digital security needs numbers that are much harder to predict than ordinary game or simulation outputs. Cryptographic systems address this by using a secret key with an encryption algorithm.

The role of the secret key

A cryptographic generator can begin with a sequence of inputs and transform them using an encryption algorithm and a secret key. The key acts somewhat like a seed: it determines the sequence that is produced.

The crucial difference is that a well-designed cryptographic algorithm scrambles its inputs so thoroughly that knowing the algorithm and observing many inputs and outputs does not provide a practical way to recover the key. With a 128-bit key, there are 21282^{128}2128 possible keys—over 300 trillion trillion trillion possibilities—so exhaustive guessing is not realistic with feasible resources.

This addresses the predictability problem that affected simpler generators. A cryptographically secure pseudorandom number generator is still deterministic, but it is designed so that predicting its outputs without the secret key is computationally infeasible.

Why cryptography still needs an unpredictable starting value

An algorithm cannot create genuine unpredictability from nothing. If its secret key is predictable or compromised, the resulting sequence may also be predictable. Cryptographic systems therefore need an unpredictable initial value, or entropy, to create or protect their secret state.

Computers may obtain this initial entropy from physical processes, such as tiny fluctuations in electrical signals measured by hardware random-number generators. Such measurements are used to seed cryptographic algorithms. The algorithm expands the seed into a longer sequence, but the security still depends on having a sufficiently unpredictable seed and protecting the secret state.


Classical randomness and predictability

A coin toss is commonly treated as random because its outcome is difficult to predict in ordinary circumstances. Yet a coin obeys classical mechanics. If its initial position, motion, and the details of its flip were controlled and measured precisely enough, its landing outcome could in principle be predicted.

This idea connects to the concept known as Laplace’s demon: an imagined intelligence that knows the position and motion of every particle in the universe. Under a strictly deterministic classical view, such an intelligence could calculate the future from the complete present state.

This suggests a demanding definition of randomness: an event is genuinely random if nothing in the universe could have predicted its outcome in advance. The challenge is not merely to produce numbers that seem irregular, but to establish that their outcomes were not determined by information available beforehand.


Quantum randomness and entangled photons

Producing entangled photon pairs

Some quantum measurement outcomes are fundamentally unpredictable according to quantum mechanics. A NIST experiment sought to use this property to create numbers whose unpredictability could be tested and certified.

The setup begins with a bright laser producing about 100 million light pulses per second. When a pulse interacts with a crystal, a photon can sometimes split into a pair of lower-energy photons, called daughter photons. The pair can be produced in a quantum superposition of two possibilities:

  • Both photons are horizontally polarized.

  • Both photons are vertically polarized.

Polarization describes the direction in which a light wave’s electric field oscillates. Because the experiment cannot distinguish which of the two polarization possibilities applies before measurement, the pair shares a joint quantum state. The photons are entangled: their measurement results are correlated even when they are separated.

The experiment sends one photon to each of two measurement stations, 110 meters apart. The stations use very narrow optical fibers, with cores about 10 microns in diameter, to direct the photons to the detectors.

Measurement choices and Bell’s inequality

At each station, researchers can measure polarization using one of two angles. Each station chooses its measurement angle at random shortly before the photon arrives. A detector either registers a photon or does not, which can be recorded as a 1 or a 0.

If the photons had carried predetermined answers for every possible measurement, their correlations would be limited by a mathematical bound called Bell’s inequality. When the researchers compare their results, the observed correlations exceed that bound. This is called a violation of Bell’s inequality.

The violation rules out explanations based on locally predetermined answers, provided the experiment’s relevant assumptions hold. In particular:

  • The measurement choices must be independent of the devices and outcomes being tested.

  • The separated stations must not communicate during the measurements, including by signals traveling at or below the speed of light.

  • Timing and distance measurements must be reliable.

  • The results must be recorded faithfully and securely.

The experiment does not establish that no imaginable explanation is possible under any assumptions. Rather, the Bell violation places strong limits on local, pre-existing explanations and allows the researchers to certify unpredictability when the experiment’s assumptions are satisfied.

The freedom-of-choice loophole

A concern called the freedom-of-choice loophole is that the measurement settings might not be independent of the particles’ behavior. If a particle could somehow “know” the setting it would later encounter, its result might be coordinated with that setting rather than genuinely unpredictable.

To push this possibility further back in time, researchers have used light from distant quasars to choose measurement settings. The photons from those quasars had traveled for billions of years from regions that had not been able to communicate with each other since early in the universe’s history. Any hidden coordination between the quasar light and the experiment’s outcomes would therefore have to originate very far in the past.

This approach does not eliminate every possible loophole. It constrains when a hypothetical coordination could have occurred, but it still relies on assumptions about the light and the experimental setup.

Protecting the setting generators

A separate concern is practical interference. An attacker might try to shine controlled light into the telescopes used to select measurement settings, thereby influencing which measurements the experiment performs. For security applications, the setting generators must therefore be physically protected from outside interference.

The system also relies on other assumptions, such as accurate timing, secure recording, and the impossibility of faster-than-light communication. Quantum certification is powerful, but its conclusions depend on the experiment being implemented correctly and on its stated assumptions holding.


Extracting usable random bits

The raw outcomes of a quantum experiment may be biased: there may be more zeros than ones. A Bell test can certify how much unpredictability is present across many measurements, but that does not automatically produce a neat sequence of balanced, independent bits.

The experiment therefore uses randomness extraction, a mathematical process that concentrates certified unpredictability into a shorter, more usable output.

Von Neumann’s coin-extraction method

A simple illustration uses pairs of coin tosses:

  1. If the pair is heads–tails, record a 0.

  2. If the pair is tails–heads, record a 1.

  3. If the pair is heads–heads or tails–tails, discard the pair.

If the coin has a fixed bias but the tosses are independent, heads–tails and tails–heads are equally likely. The method can therefore produce fair output bits from a biased coin, though it discards some tosses and produces a shorter sequence.

NIST’s extraction technique is more powerful, but follows a related principle: use the measured uncertainty in the raw data to generate a shorter output with stronger randomness properties. In the described experiment, the Bell test certifies at least 820 bits’ worth of unpredictability in the raw measurements, and extraction concentrates that into 512 bits. Every measurement contributes to each extracted bit.

The resulting bits differ from the output of ordinary pseudorandom generators in an important way: their unpredictability is certified by the experiment’s physical test, rather than being inferred only from the apparent statistical quality or computational difficulty of predicting them.


Key distinctions and takeaways

  • Random-looking does not necessarily mean random. A sequence can pass simple visual inspection and still contain exploitable structure.

  • A long period only means the generator takes a long time to repeat; it does not guarantee independence, good statistical behavior, or security.

  • Pseudorandom generators are deterministic. Their quality depends on their design and intended use.

  • Cryptographic generators make prediction computationally infeasible when their secret keys are secure, but they still require a genuinely unpredictable seed.

  • Quantum experiments can certify unpredictability under assumptions such as independent measurement choices, secure apparatus, accurate timing, and no faster-than-light signaling.

  • Randomness extraction turns imperfect or biased raw outcomes into a shorter sequence of more uniformly usable bits.

Together, these ideas show why producing useful randomness is not simply a matter of writing a complicated algorithm: the required standard depends on whether randomness is being used for approximate simulation, game behavior, or the security of digital systems.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent