# How do I ensure an appropriate payout ratio for a slot machine?

I have done a lot of research into random number generators for slot machines, reel stop calculations and how to physically give the user a good chance on winning.

What I can't figure out is how to properly insure that the machine is going to have a payout rating of (lets say) 95%.

So, I have a reel set up wit 22 spaces on it. Filled with 16 different symbols.

When I get my random number, mod divide it by 64 and get the remainder, I hop over to a loop up table to see how the virtual stop relates to the reel position.

Now that I have how the reels are going to stop, do I make sure the payout ratio is correct? For every dollar they put in, how to I make sure the machine will pay out .95 cents?

Thanks for the ideas.

I am working in actionscript, if that helps with the language issues, but in general I am just looking for theory.

Edit: There is real money involved only in the fact that they can buy more tokens to play more. There is not going to be real money paid out to the person, if they were to actually hit the any of the paylines.

• Is this business critical code?, do your users win real money? Feb 20 '11 at 14:16

What you're asking is related to probability theory. It's easiest to work with one reel, and then extend it to multiple reels once you understand how it works.

Consider if you had a reel you have some symbols which you want to assign to the stops. More symbols on a reel will lead to greater control over the final results, but will feel more random to the player. The goal is to balance the number of symbols and stops so the machine feels less random to the player, and like they have more of a chance.

If you had 10 symbols and 10 stops, each symbol would have a 1 in 10 chance of appearing. It doesn't matter what order the symbols are in (in theory, in practice the randomness of the game is only as good as your random number generator). In other words, you might expect to see 10 different symbols in 10 spins, or a different symbol on every spin. The chance of getting one particular symbol is 1 in 10. So for every 10 spins, you can expect to see each individual symbol once. If you picked 1 symbol to be the "winning" symbol, the player would have to play 10 times before they won. With this information it's quite straight-forward to work out the payout. If you charge them $1 for each spin, they will have to spend$10 before they land on a win. If your expected rating is 95%, the calculation is $10 x 95% =$9.50. In other words, the prize for landing on the "winning" symbol must be $9.50 to have an expected payout of 95%. Now remember that this is all based on average. There's no guarantee that the symbol will appear in exactly 10 spins, it may take 100 or 1000 spins, or even just 1 spin to appear. Taken over a long enough time the machine will pay the correct amount on on average. To getting this to work on multiple reels you need to multiply the winning probability of each reel. Consider an example of 3 reels with 10 symbols on each reel, and 1 winning symbol on each reel as in the previous example. Lets say you wanted the player to win only when all three reels show the winning symbol at the same time. To do this, you need to work out the probability for each reel, and then multiply the probabilities together. We know from the previous example that the probability is 1 in 10. This can also be written as 1/10, or 0.1. The probability of all three reels landing on the winning symbol at the same time is 1/10 x 1/10 x 1/10, or 0.1 x 0.1 x 0.1, or 0.001, or 1 in 1000. We see that there is a much lower probability of the winning symbol appearing on all three reels at the same time. The player would need to spin 1000 times on average before they win. If each spin was$1 they would need to spend $1000 to win. The calculation for the winning percentage then is:$1000 x 95%** = $950.00. That's the theory in a nutshell. The rest is balancing balancing the different probabilities to make the game appear more interesting. In your case, if you have 22 stops and 16 symbols. This means you will have 6 symbols which are the same as at least one other symbol. The exact probability of any particular symbol appearing depends on the total number of occurrences of that symbol on the reel. How many of each symbol is on each reel is really up to you. As an example lets say you have 15 unique symbols, and 7 which are all duplicates. The chance of any one of the duplicates appearing is 7 in 22, or 7/22, or 32%. If you had 1 reel, at$1 a spin, the player would land on one of the duplicates 32 times in 100 spins. The payout is calculated as (1 / (32/100)) x 95% x $cost. So if it cost$1 per spin, you would pay the player $2.97 every time one of the duplicates appeared. As another example, if you had 3 reels and it cost$2 per spin, you would work out the pay out as follows: (1 / (32/100 x 32/100 x 32/100)) x 0.95 x $cost = 30.5 x 95% x$2 = $57.95 payout. You can calculate the probabilities of the other non-duplicates as follows: (1 / (1/22 x 1/22 x 1/22)) x 0.95 x$cost = 10648 x 0.95 x $2 =$20231.20. That's quite a large number, but then the probability of any of the winning sequences appearing is quite low (it's roughly 9x10^-5).

In the last examples the differences are quite extreme, the player either wins $58 very often, or$20231 almost never, with no variation in between. The art of making the game engaging is in creating more opportunities to win with varying amounts. This is often accomplished by mixing reels with different probabilities. So instead of each reel having
the same number of each symbol, one reel might have more symbols, or more of one type of symbol, and so on. The formula for calculating the probability is the same as before, just remember to use the correct ratios for each reel. For example, if you have reel A with 22 stops and 3 occurrences of a symbol, reel B with 26 stops and 2 occurrences of the symbol, and reel C with 20 stops and 5 occurrences of the symbol, the formula would look like this: (1 / (3/22 x 2/26 x 5/20)) x 95% x $cost. And that's all there is to it. Hopefully I didn't make too many mistakes in the examples so you'll still be able to find it useful :P ** A note on notation, 95% is identical to 0.95. 32/100 is identical to 0.32, 7/22 is identical to 0.31818.. etc. • Amazing. You just saved me a lot of work. I've read a lot of docs about how slots should work, but this answer really sold it to me in layman's terms. Thanks! Sep 13 '11 at 5:03 You want the expected value to be .95. In simple terms, this is the sum of probability * payout for each state. A brute force method would be to iterate over all 22^3 states (assuming you have 3 reels), add up the payout, and divide the sum by 22^3. However, since most states probably don't pay out anything, it might be easier to work out all the states that do pay out instead. For example if you had 1 Bell sybols per reel, then the probability of [Bell] [Bell] [Bell]  would be 1/22^3. And if you had 2 Cherries per reel, then the probability of [Cherry] [Cherry] [any]  would be 1/11^2. EDIT: The above only tells you how to check that the payouts give the desired return rate. As a simple example, lets consider a game where you pay$1 to flip 2 coins. Here are three payout schemes that all give a return rate of .95:

1. Two heads pays $3.80, everything else pays nothing 2. Two heads or two tails pays$1.90, everything else pays nothing
3. Two heads pays nothing, everything else pays $1.26 Which one is more "fun"? You tell me... • That being said, no slot machine made within the past few decades spins reels like that. If three bells pays out jackpots, they're going to come up disproportionately less, no matter how many are on the physical reel. – user744 Feb 20 '11 at 18:51 • I just handle the math - making it fun is somebody else's job :) Feb 20 '11 at 21:11 • @joe - I agree, the bells will be on the reel a ton less that the rest of the symbols. @celion I don't understand fully yet. Let's say I have the reels (I have 5), and the user pushes the button to play the game. I grab the next 5 random numbers, make the calcs to find the stops and make the symbols show. How does the payout rate effect the random numbers and the stops? Do I set the payout by the symbols that are on the reel, and the amount high->low paying symbols contained on the reel? Feb 20 '11 at 23:00 • @Kris-Mitchell - Maybe I'm misunderstanding how slot machines work. I assumed that for each possible outcome, the payout is fixed. If the symbols on the reel change each round, the math gets a bit harder, but you should still be able to work out (offline, with a pencil and paper) the probability of a given state. This just gives you a way to make sure that a set of payouts will give the desired (average) return rate; there are an infinite number of ways to assign the payouts given that constraint, so it's up to you to pick a "fun" one. Feb 21 '11 at 0:20 • @celion - I did not mean to miss-lead you, and if anyone else is reading this correct me if I am wrong, but the payout is fixed. I don't believe that the reels change each round. I think that the reels for video slots are just way larger than a true mechanical slot machine. By the way, I believe I would enjoy option 2 or 3 the most. Two is risky enough to be a challenge, where you can make money, while still knowing you will loose. Three on the other hand seems to be better because it feels like you have more of a chance to win. Feb 21 '11 at 0:44 The easier and more reliable way to do this is not by simulating reels but rather have an internal die that chooses what the player wins and then just populate the reel procedurally(or have a large set of them saved somewhere but that will probably take longer to make). The others haven't touched this bit: ..how to properly insure that the machine is going to have a payout rating.. If you use completely random numbers, there's no way to be sure. However, you can keep statistics of the payouts and adjust the probability of a payout at runtime using a feedback loop. If there hasn't been a payout for some time, make it more probable to win, and vice versa. You can run simulations of the runs (a couple billion iterations should do) to make sure your feedback loop works as intended. • Your solution is unnecessary. A perfect random number generator (RNG) will approach the exact payout rating over time. While it is true that using your default built-in RNG function is not really acceptable (mainly due to predictability), the correct solution is to use a better RNG, eg: en.wikipedia.org/wiki/Random_number_generation#Physical_methods. Also, including game logic that is non-random, or "tweaks" the payout rating as you are suggesting is illegal in most places. It's fine for a gimmicky web site, but a total non-starter for a real world application. Nov 7 '11 at 14:34 • @lukevanin, it's legally required in other places, so it really is a case of understanding the context. Nov 7 '11 at 16:33 Note that all answers so far assume that you have a perfect RNG to work with. A pure software RNG is actually a pseudo-RNG, or PRNG for short, because the same input value (seed) will always generate the same sequence of random numbers, so a PRNG is inherently predictable. Of course, it is a hard problem to distinguish "true" from "pseudo" RNGs on the client side, especially with a small sample size, but there is a difference - in an application where money and legal liability is involved, I would not take chances. If you need an RNG, the only thing worse than having no RNG is having a broken RNG without knowing it, so this is one area where your company should never cut corners or learn on the fly. There are good PRNGs algorithms, but they will never match a physical source of entropy. So, for the maths to work in practice as well as in theory, make sure you use the best RNG possible - it's in your company's best interest, both legally and financially. A very simple approach could be just iterating over every possible spin outcomes and adding up the combined winnings, versus total monies collected. Start by creating the wheel layouts, allow duplicate symbols if desired. Determine the winning patterns and payouts you want. Run wheel pattern though an algorithm to determine total payout, divide by money collected, this is your payout ratio. If it is too high, add more blank spaces, or lesser paying symbols, OR lower the pattern payout (ie. three single bars can be$10, or $5). Rerun the algorithm until the desired payout ratio is determined. This allows you to keep even value payouts (not$4.58 for a winning pattern, you could use \$5). You may not be able to come up with an exact payout of say 95%, but with tweaking you can get close.

Here's an example algorithm to determine a wheel layout's pay ratio:

payout = 0.0
collected = 0.0
ratio = 0.0
bet = 1.0
FOREACH symbol1 IN wheel1
FOREACH symbol2 IN wheel2
FOREACH symbol3 IN wheel3
payout = payout + DetermineWinnings(symbol1, symbol2, symbol3, bet)
collected = collected + bet
NEXT
NEXT
NEXT
ratio = payout / collected