How The Generate Pseudo Random Numbers Works In Slot Machine
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.
- Random Numbers
- How The Generate Pseudo Random Numbers Works In Slot Machine Free Play
- How The Generate Pseudo Random Numbers Works In Slot Machines
- Pseudo Random Numbers Algorithm
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.
Slot machines installed with non-complex RNGs can be beaten by high-tech devices and prediction algorithms. Pseudo Random Number Generators (PRNGs) are a computer program that attempts to randomize numbers so they are unpredictable. But because they are based on a set of rules, they are still predictable in some ways. Instead of using “random radiation”, PRNGs use the internal clock of computers, in combination with an algorithm. Pseudo random number generators are used in online slot machines to simulate the spinning of the reels and to give fair winning chances. Random Number Generators Random number generators generate thousand numbers per second or minute and the most recent number determines the next number as soon as the play button is pressed. I am implementing a game( a bit like slot machine) where I need to generate three random numbers at the same time using an 8085 and display them on a 7 segmented display 2. The exact implementation of the random nos need not be known to the user, just that the numbers are fairly random. Slot machines work the same way, but with much longer odds. The games are dressed up with music and symbols and multiple lines and reels, but when you crunch the numbers, random spins cause the 90% (or whatever) payback. Write a program to generate a million random numbers.
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!
Modern slot machines are powered by software called “random number generator” software — RNG, for short. If you can beat the RNG software, you can beat the slots.
That means winning money.
At one time, slot machines were powered by physical reels and springs, but no modern casino uses such gadgets. Even the machines that LOOK mechanical are powered by RNG software.
Can having an understanding of how that RNG software works enable you to change the return to player (RTP) percentage in your favor?
These are the questions this post tries to answer.
Some Definitions
Understanding what’s happening on a slot machine and with the RNG and RTP is easier when you understand some of the following expressions:
- Hit Frequency: How often you can expect to see some kind of winning result on a slot machine
- House Edge: A statistical prediction of how much of each bet the casino will win in the long run. It’s expressed as a percentage, and if you add the house edge to the return to player percentage, you’ll always get 100%
- Independent Trials: Events that don’t affect subsequent events and which aren’t influenced by prior events. In the case of slot machines, every spin of the reel is an independent trial
- Jackpot: The amount of the biggest win available on a slot machine game
- Long Run: A large number of trials. The actual long run is infinity. Every spin of a slot machine’s reels takes you nearer the long run
- Odds: One way of expressing probability (see below). Also a measure of how much a bet pays off compared to the amount bet. With slot machines, winnings are expressed as “X for Y” rather than “X to Y.” I’ll explain that further in this post
- Payback Percentage: The same thing as the return to player percentage. A predicted estimate of how much of each bet you’ll get back as winnings. This is always a number under 100% so that the casino can make a profit
- Payout: The amount you win from a specific combination of symbols
- Probability: How we measure the likelihood of an event happening. A probability is always a ratio or a fraction and can be expressed in multiple ways — as a fraction, as a decimal, or as a percentage
- Random Number Generator (RNG): A computer program that cycles through thousands of numbers per second. When a slot machine player hits the spin button, the number that is being “thought of” at that instant determines the results on the spinning reels
- Reels: The reels are the things that spin on a slot machine. They have multiple symbols on each of them
- Return To Player (RTP): This is a percentage that predicts, in the long run, how much money a slot machine will pay back to a player in winnings. This is always under 100%, because otherwise, the casino wouldn’t make any money
- Short Run: What happens on a small number of trials. The fewer trials, the closer you are to the short run. The ultimate example of the short run is a single spin of the reels on a slot machine
- Slot Machines: Any gambling machine with spinning reels with symbols on them
- Symbols: The pictures on the front of the slot machine reels. If these pictures match, you get winnings
- Weighting: How the random number generator assigns a probability to a specific symbol coming up. Some symbols are weighted to come up more often than others, and vice versa
How Does a Slot Machine Work?
Early slot machines had three reels with multiple symbols on each, and they paid out when you got a winning combination. The reels were housed inside the machine and were activated by pulling a lever on the side of that machine. Springs set the reels into motion.
Calculating the probability of getting various results on a mechanical slot machine was easy. You just took the number of symbols on each reel and divided to get the probability on one reel. Then you multiply by the other reels.
On a slot machine with eight symbols on each reel, the probability of getting a specific symbol on a reel is 1/8.
The probability of getting that symbol lined up on all three reels is 1/8 x 1/8 x 1/8, or 1/512. That can also be expressed as odds of 511 to 1, or 0.2%.
These slot machines generated returns for the casino by paying out less in winnings than the odds of winnings. Since you have 512 possible outcomes with this machine, as long as the total payouts for all those outcomes total less than 512, the casino makes a profit.
You divide those payouts by those outcomes to get the predicted payback percentage or return to player.
Let’s say you have a total of 450 coins you could win after adding all the winning combinations together.
The payback percentage for the game would be 450/512, or 87.9%.
In the long run, you’ll win 87.9 cents for every dollar you put through the machine. The casino will keep the rest.
That’s a long-term average based on the probability and the payouts. The game doesn’t know where it’s at in terms of that expectation, and it doesn’t change its randomness based on how much you’ve won or lost before now.
In other words, the probability of getting three cherries on the next spin is always 1/512, regardless of what happened on the previous spin, the previous 10 spins, or the previous 100 spins.
Some people might think that if you just got three cherries, the probability of getting that result again on the next spin drops.
It doesn’t.
It’s still 1/512, just like it was before.
How Random Number Generators Changed How Slot Machines Work
With a random number generator creating these results, slot machine designers can change the weightings for the symbols. You can still have eight symbols per reel, but the probability for the cherries might be set at 1/16 instead of at 1/8, while the probability of bars might be set at 1/4 instead of 1/8.
This enables the slot machine to offer bigger prizes while maintaining a profitable return to player percentage.
Each of the numbers that the random number generator program cycles through corresponds to a combination of reel symbols on the payline. Those weightings are accounted for in the assignment of the numbers.
All of this takes place “under the hood,” too, so you have no way of knowing what any of the probabilities are.
In fact, you can have two identical slot machines sitting right next to each other programmed for different payback percentages. Slot machine A might have a payback percentage of 88%, and slot machine B might have a payback percentage of 92%.
They might both be Wheel of Fortune slots games, too. The only difference is the probability with which the symbols come up.
The Difference Between the Short Run and the Long Run
The rule of thumb when dealing with random events is that anything can happen in the short run — anything at all.
But the closer you get to the long term, the more likely you are to see results that mirror the predicted expectation.
- You’re playing a slot machine game with an 88% payback percentage. You make one spin, and you bet $1 on that spin.
- Practically any result is possible at this point. Some results are more likely than others, but your return on that single bet absolutely will not match the statistical expectation of 88 cents.
- There’s a good chance — maybe 50% to 75% — that you’ll lose your dollar altogether.
- The rest of the time, you might win a dollar, $10, or even $1,000 on that single spin.
Those are all possibilities.
In fact, even if you make 10 spins or 100 spins, you probably won’t see results that line up with the mathematical expectation. Your sample size is too small.
As the number of bets you make approaches infinity, though, the more likely it is that your results will start looking like the results you’d expect. Remember, these expectations are averages over the course of those bets.
Let’s say you make 1,000 bets at $1 each, and when you finish, you have $880 left. You’ve lost $120 over 1,000 spins, so that’s a $0.12 loss per spin on average.
That also represents an 88% return to player percentage.
That’s exactly what probability would have predicted.
But even in that situation, it wouldn’t be unusual to have results that are skewed by variance in the short run. Win the 1,000-coin jackpot twice in those 1,000 spins, and it would be almost impossible for you to achieve results that resemble the mathematical expectation.
What About Hit Frequency? How Does the Slot Machine Know How Often to Pay Me?
The slot machine doesn’t “know” anything. In fact, it has no memory of what happened on your previous spin. The hit frequency is established by the programming of the random number generator.
Most of the time, the hit frequency for a slot machine will be at least 25%. Usually, it’s more than that. 33% to 45% isn’t uncommon.
But that’s strictly a function of probability. In the short run, you might win far more often than that — or far less often.
These are independent trials. Those predictions are just predictions based on probability.
So How Do You Beat the Random Number Generator?
I have a good friend who claims that his aunt used to pay her rent and bills by playing the slot machines. He said that she would watch the machines and get an idea of how often they paid out. When the right amount of time had passed between payouts, she would bet on that machine and win.
He claims that he went to the casino with her on multiple occasions, and she would point out a machine to him, and he’d play on it and win.
He’s convinced that they were able to beat the random number generator by paying attention to the cycles that the computer program was going through. That way, when the right number was about to come up, they could be there and bet on that number.
Do you see the trouble with their logic?
Yes, a random number generator program cycles through numbers.
But the program cycles through thousands of numbers PER SECOND. This isn’t a case of the computer program cycling through 120 numbers per hour or something like that. If it were, then sure, you could easily figure out when a machine was “due” for a payout. Slot machine gaming machine home use.
The cycles happen so fast that they might as well be random.
How did he and his aunt win?
A combination of factors is in play here. One of these is confirmation bias. They expected to see certain results, so those are the results they’re most likely to remember. This is a common psychological foible with anyone.
The other factor is that they might have gotten lucky a few times. Everyone wins occasionally if they play long enough. If they didn’t, the casinos wouldn’t make any money because they wouldn’t have any customers.
How Do You Win Against an Electronic Slot Machine, Then?
Your only hope of winning against the random number generator is to get lucky in the short run and quit immediately.
The longer you play, the more likely you are to see results which resemble the predicted results.
There’s no way of guaranteeing you’ll beat the computer program other than by cheating or re-programming the machine. That’s beyond the scope of this post, and it’s a major crime, anyway. (In Nevada, cheating at gambling is a felony.)
What’s your best strategy then?
Since most slot machines played for a higher denomination have a higher payback percentage, it’s probably a good idea to play as few spins as possible for as much money as possible.
The penny slots players are the ones least likely to win big because the house edge grinds away at your money over time like compound interest.
If you have $100, you’re better off betting all of it on a single spin of the reels than you are making 100 spins on a $1 machine or 2,000 spins on a nickel machine.
You’ll spend less time playing, but you’ll have a better probability of going home with some big winnings in your pocket.
The trick is to walk away once you’ve won and never go back.
I have a buddy who hits the Winstar Casino at least once a week. He wins occasionally — maybe once every four or five trips. Sometimes he even wins big money, which he puts in the bank.
But he keeps going back.
Random Numbers
Since those games are negative expectation bets, he’ll inevitably lose his money if he keeps playing.
Even though he sometimes wins, he keeps exposing his bankroll to the house edge.
And that’s a sure way to lose.
The only way to beat the random number generator is to get lucky in the short run and walk away forever once you’ve won.
Dev.111.45214.92%19.329.66318.56%25.378.46421.66%31.087.77524.70%36.027.20625.62%39.796.63726.55%43.816.26829.36%48.436.05931.81%53.265.921032.52%57.425.741133.20%61.095.551233.87%65.785.481334.63%69.885.381435.26%75.005.361535.86%79.105.271635.86%84.375.271735.87%89.565.271835.84%93.165.181935.85%98.595.192035.88%103.515.18Internal Links. for the reel strips as well as the data for calculating the standard deviation and hit frequency. analysis of the video slot machine. /cleopatra-slot-machine-rules.html. (PDF).Acknowledgements.
That’s probably not the way most people are going to play, so here’s a compromise for someone who wants to get some more gambling under her belt while still having a chance to beat the random number generator.
Set a win goal. I like to find a flat-top slot machine with a 1,000-coin jackpot. Hitting that jackpot is my goal.
I set aside 600 times the size of the bet on that game. If I’m playing a game with a $1 cost per spin, I’ll set aside $600.
How The Generate Pseudo Random Numbers Works In Slot Machine Free Play
I’ll then play the game until I’ve hit the jackpot or lost my entire $600, whichever comes first.
This doesn’t give me any kind of mathematical advantage over the casino, by the way.
It just gives me a fighting chance of winning some money and going home with it.
Conclusion
Do you want to know how to beat RNG software?
Failing that, play with some kind of strategy that keeps you in the short run and out of the long term.
How The Generate Pseudo Random Numbers Works In Slot Machines
Besides cheating and hacking, there’s no other way to beat the random number generator.