# How to Win at Slots

In 2014 casinos across the United States discovered that a number of patrons were *winning* at slots. For anyone who has a passing interest in maths, or has played a slot machine, would know: this should be impossible! “The house always wins“, is a saying that’s actually mandated by law for slot machines in many countries.

**How do slot machines work?**

Simplifying things a bit, a slot machine is a random number generator which picks a number between 0 and 100 randomly when the punter puts in a coin and presses a button. If the number is above 55, the punter “wins” and there is some payout — otherwise the house “wins” and keeps the coin. The house should always win in the long run: they have the mathematical edge.

But what if the punter knows what number the machine is going to pick? If you could know that, you would be able to press the button when you *know* you’re going win. How could a punter ever know what random number the machine is picking? The trick is that slot machines don’t (usually) pick random numbers! This is because computers are very much not-random: they can only follow instructions. A computer which doesn’t follow its instructions to the letter is not a good computer. Sadly, “roll a die” is not an instruction that any computer can understand.

**Pseudo-random numbers**

Instead, machines use a *pseudo*-random number generator. As the name suggests, this technique generates numbers that *appear* random: each number generated seems to be unrelated to the ones that came before, and has an equal probability of coming up. To make a pseudo-random number generator all you need is a bit of maths, and a complicated enough formula. A common formula to get random numbers is called the Mersenne Twister, which takes a “seed” number to start, then does a whole heap of maths on it to spit out a series of pseudo-random numbers. They are not truly random as if you put in the same seed, it will spit out the same numbers.

Now, the slot machine’s pseudo-random number generator doesn’t just use a single seed, and some of its seeds may even depend on time or other hard-to-know-precisely variables. However, with a long enough observation time, and some really smart reverse-engineering, it is possible to recreate the entire formula: you’ve know cracked that slot machine, and know when to press the button such that you beat the house odds.

**Really truly random**

If you wanted to create a *truly* random number generator you need an input to your complicated formula that is truly random: just picking your seed isn’t an option. Some common ways to get this random number is to use something like the timing of keystrokes or mouse movements as in the Fortuna method, or atmospheric noise (like the noise picked up by a radio antenna) as used by RANDOM.ORG. However perhaps the most robust way is to use radioactive decay, like the Hotbits service.

Using radioactive decay relies on the fundamental laws of quantum mechanics to ensure that the numbers are actually, truly, irreproducibly random. The chance that a single element will decay and create a “blip” at your detector is just that: a pure chance. There is no way to know, regardless of how good your measuring equipment just when a radioactive source will decay. This makes it an ideal place to find truly random numbers.

In the end, this technique doesn’t save the casinos. They are unwilling to replace or upgrade all of their slot machines, so there will always be a chance that another enterprising hacker will work out how to reproduce their “random” numbers, and start beating the house again!

What a cool post! Ive never honestly thought about how those games work. haha.

I wonder how many people invest the time and effort into trying this? You think after the stats rolled out they put more of an effort in to having security keep an eye out for people who may be watching the machines for this reason?

Great article Julian! I’m not a gambler but I found the mechanics behind slot machines fascinating. I also had no idea you could use quantum mechanics to produce truly random numbers.