• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Probability as it applies to slot machines...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

16 replies to this topic

### #1HL706  Members

Posted 08 July 2010 - 10:50 PM

Hi,

I'm currently working on a slot machine designer tool that will allow the user to see, at a glance, the payout percentages and probabilities of each win coming onto the winline. So far it's been going really well and I have a partial implementation in C#.

However, I'm having a problem with scattered wins.

Currently, the probabilitys for a win on the winline (from left to right are)

(Num Symbols) / (Total Symbols on Reel) = Probability

1 / (Probability) = Hit Rate

(Number of Combinations*) / (Hit Rate) = Odds.

(Win Value) / (Hit Rate) * 100 = Payout Percentage.

This works fine when calculating the odds of winning from left to right, and from right to left. However, when you're looking for symbols anywhere on a winline it doesn't translate so well;

Anyone got any ideas how I could adapt this, or even better, have a formula for calculating this?

Sorry for rambling, but I've been scratching my head with this for a few days now and cohesive thought has abandoned me! ;)

Thanks,
Michael.

### #2Álvaro  Members

Posted 09 July 2010 - 02:17 AM

Do you have a more specific question? What probability are you trying to compute exactly?

### #3HL706  Members

Posted 09 July 2010 - 02:29 AM

Sorry, it was a bit of a ramble;

I'm currently trying to work out the probabilities for any combination of symbols along the reel strips.

For example, in a 5 reel slot game - what would the probability of 5 BAR symbols appearing anywhere on a winline, 4 BARS, 3 BARS etc...

They don't have to be in sequence, just on the winline itself - so you could have this;

 X    X    X    X    X BAR  X    BAR  BAR  BAR  X    X    X    X    X

That would be 4 x BARS anywhere on the win line. I just can't seem to work out the probability of this happening correctly...

### #4BattleMetalChris  Members

Posted 09 July 2010 - 03:02 AM

As long as the probability of getting a bar is the same for each reel, then the probability is

<number states in which the win can be acheived> * <probability of a single state occurring>

Say there are 4 reels, with the chance of getting a bar on one reel 1/5

For the chance of getting 2 bars:

You can get 2 bars on 4 reels in 6 different ways. This can be calculated using the nCr calculation, (see http://www.calculatorsoup.com/calculators/discretemathematics/combinations.php for an explanation)

Of all the possible states the reels can be in, we are interested in (in this case) 6 of them, the chances of getting any one of these 6 states is 6 times the chance of any one state, so 6 * ((1/5)^4) or 6/625

(Quick edit as I messed up the last bit - should be ok now)

### #5Hodgman  Moderators

Posted 09 July 2010 - 03:06 AM

Find the probability of a BAR coming up on each single reel (Num BAR / Total Symbols on Reel) so you've got P1..Pn (where n is number of reels).

Then you've got to go through all the permutations (the different ways you can get N BARs) and add them together.
e.g. for a 5 reel game
5 BAR has only 1 permutation = P1*P2*P3*P4*P54 BAR has 5 permutations = P1*P2*P3*P4 + P1*P2*P3*P5 + P1*P2*P4*P5 + P1*P3*P4*P5 + P2*P3*P4*P53 BAR has 10 permutations = P3*P4*P5 + P2*P4*P5 + P2*P3*P5 + P2*P3*P4 + P1*P4*P5 + P1*P3*P5 + P1*P3*P4 + P1*P2*P5 + P1*P2*P4 + P1*P2*P3
When I worked in 'gaming', we'd check these percentages by doing the math (like this), and double-check by writing a simulation of the game in C and seeing if it produced the same result (withing a statistically relevant error margin) after millions of random tests.

BTW We had some fancy custom built software for helping do this kind of math, but Excel was actually easier to use and more flexible in most cases ;)

### #6HL706  Members

Posted 09 July 2010 - 03:09 AM

Ok, I think I understand what you're saying - but if we had multiple weightings for each reel, how would I proceed with that?

Currently i'm checking for any two symbols (s1) on a three reel game, the chances of s1 appearing on each reel are; 2/7, 3/7 and 1/4 (i'm trying to make this as basic as possible for myself ;)).

So how would I calculate the chance of any two bars appearing based on those weightings? Would an 'nCr' calculation still be useful in this instance?

### #7HL706  Members

Posted 09 July 2010 - 03:12 AM

Quote:
 Original post by HodgmanFind the probability of a BAR coming up on each single reel (Num BAR / Total Symbols on Reel) so you've got P1..Pn (where n is number of reels).Then you've got to go through all the permutations (the different ways you can get N BARs) and add them together.e.g. for a 5 reel game*** Source Snippet Removed ***When I worked in 'gaming', we'd check these percentages by doing the math (like this), and double-check by writing a simulation of the game in C and seeing if it produced the same result (withing a statistically relevant error margin) after millions of random tests.BTW We had some fancy custom built software for helping do this kind of math, but Excel was actually easier to use and more flexible in most cases ;)

Ahhhhhh, that's where I'm going wrong!

I've been doing;

4 BAR= P1*P2*P3*P4* P1*P2*P3*P5* P1*P2*P4*P5* P1*P3*P4*P5* P2*P3*P4*P5

So if I add the different outcomes together, rather than multiplying, the results should be statistically correct?

### #8Hodgman  Moderators

Posted 09 July 2010 - 03:16 AM

Quote:
 Original post by HL706So if I add the different outcomes together, rather than multiplying, the results should be statistically correct?
Yep - this is also what BattleMetalChris did when he assumed that each reel had the same weightings and then multiplied by the number of permutations (i.e. that's equivalent to adding the permutations together).

### #9HL706  Members

Posted 09 July 2010 - 03:17 AM

Ah fantastic! Cheers for that guys, I really appreciate it.

### #10Denzin  Members

Posted 09 July 2010 - 08:33 PM

slot machines arent random... at all.

### #11Katie  Members

Posted 09 July 2010 - 09:37 PM

They're pseudo-random.

They know how much money's been fed in, they know how much they've paid out. Their goal is to hit a (say) 70% ratio between these (Or whatever ratio is demanded by the local legislation).

So all they do is pick a random wheel position, work out the payout, work out if it helps them get to the target percentage (eventually) and if not pick again.

Testing certainly used to be simply running them for millions of games (without the actual hardware connected) and making sure they're hitting the percentage.

Given that you're after designing the reels, and actually really want to know what the payout is of a machine built with *TRUE* wheels (ie; properly random ones), the answer is reasonably simply albeit a little inelegant. It's not a vast calculation to compute the outcome of all wheel positions given a one position change... it's only 20^5 which sounds big, but isn't much given modern machines. Amortise it across frames or run it in a background thread or something. You only need to run it when someone changes the symbol contents of the wheels (reordering the symbols on a wheel will make NO difference).

If you want, you could hack that space down by runlength encoding the wheels (because the actual order of the symbols doesn't matter to the probabiliy). Ie, if wheel one has 4 BARs on it, you only need to compute a bar vs all other outcomes and multiply the answer by 4 (the repeat count) / 20 (total symbols). You can then do this on each subsequent wheel. You probably only have 5 or 6 symbols on a wheel, so your problem immediately reduces to 6^5 which is titchy.

This also conveniently handles having wheels which are different (the last wheel might have 8 BAR symbols on it), wheels of different sizes (some machines have extra "bonus" wheels) and symbols which (for instance) only exist on some of the wheels all without needing to write special code.

### #12Álvaro  Members

Posted 10 July 2010 - 12:44 AM

Quote:
 Original post by KatieThey're pseudo-random.They know how much money's been fed in, they know how much they've paid out. Their goal is to hit a (say) 70% ratio between these (Or whatever ratio is demanded by the local legislation).So all they do is pick a random wheel position, work out the payout, work out if it helps them get to the target percentage (eventually) and if not pick again.

That kind of severe bias is unreasonable, and I would be surprised if it were allowed. It would mean that after a big prize, a machine would be a lot less likely to give out another one (the probability would be epsilon^2 instead of just epsilon).

You can get the payout ratio you want simply by picking the probabilities right, and keeping each play independent (in the statistical sense) of previous results.

### #13Katie  Members

Posted 10 July 2010 - 02:22 AM

It's not only "allowed", in the UK it's **required**.

Fruit machines ("AWP" - "amusement with prizes") must have a label on them describing their payout odds, which must be at least 69%[2]. So one aims for 70% rather than get nailed by the gaming people.

One doesn't do it on a purely spin by spin basis, but over reasonably short amounts of time (of the order of hundreds or thousands of spins), it will end up on target.

Yes, it does lead to prize biasing. Hence sharking, winning-loop strategies and so on.

"You can get the payout ratio you want simply by picking the probabilities right, and keeping each play independent (in the statistical sense) of previous results."

You CAN, but that's not what's ACTUALLY done[1]. One of the problems with this, certainly from the perspective of UK AWP is that the games above the reels are more skilled and choice based AND have a payout. It's difficult to put those into the statistical model.

What actually tends to happen is that the machines are designed to slightly underpay, and then the "nudge" system gives the player the option to nudge wins in in order to hit the payout percentage. At the limit, the machine will just roll large wins in on the reels if the players turn out to be incapable of nudging properly.

[1] One of the people in this conversation has worked in the fruit machine industry in the past.

[2] For non-casino locations.

### #14Álvaro  Members

Posted 10 July 2010 - 06:17 AM

I don't know why I am surprised. I work for the financial industry and some of our regulations don't make any sense either. When you point the lawyers to the undesirable consequences of the regulation, they look at you like you are from another planet: The rules are what the rules say, whether the consequences make sense or not.

### #15Hodgman  Moderators

Posted 11 July 2010 - 03:06 PM

Quote:
 Original post by Denzinslot machines arent random... at all.
Actually, they are. They're not even "pseudo random" - they have real physical RNG hardware inside them (not just pseudo-RNG software), which makes them far more random than anything you can create on a desktop PC.
Quote:
 Original post by KatieThey're pseudo-random.They know how much money's been fed in, they know how much they've paid out. Their goal is to hit a (say) 70% ratio between these (Or whatever ratio is demanded by the local legislation).So all they do is pick a random wheel position, work out the payout, work out if it helps them get to the target percentage (eventually) and if not pick again
I've not worked in AWP, but this doesn't happen at all in actual slot machines. The amount that's gone in and the amount that comes out has absolutely no influence at all on the results (and if it does, your organization would lose their license).

Legislation demands a minimum payout ratio, and the operators demand a maximum ratio, which gives you a narrow band of target payout percentages to aim for, yes. However, in no way are you allowed to 'cheat' the RNG to get to that percentage - it's got to be up to the math of the game (the arrangement of symbols on the reels).

When submitting a game to government regulators, you have to present your mathematical proof of what the payout will be, and the deviation from that payout.

Some territories also have legislation restricting the 'volatility' of payouts (how much the machine can deviate from the target percentage over time). It's very common for a machine to be running at half or double it's target for the first weeks/months of operation, but over time they'll average out to the target on their own.

Also, if there's any skill-based element involved in the game, it can only affect the RTP% by a certain (small) amount, and the optimal strategy to winning the mini-game must be explained to the player.

### #16Álvaro  Members

Posted 11 July 2010 - 04:05 PM

Hodgman's post makes everything OK with the world again.

Well, except for the fact that slot machines are designed to take advantage of people's ignorance and greed to extract their money. :)

### #17Katie  Members

Posted 11 July 2010 - 08:44 PM

"I've not worked in AWP, but this doesn't happen at all in actual slot machines."

Well, I don't know the situation in America. But this was certainly how machines worked in the UK about ten years ago.

Wait... no... things are blurring... oh yes. You've talked me into it. You're absolutely right, there was no frigging of the random chances. The trace memories of actually writing those algorithms in actual C code are just caffeine induced hallucinations.

Righty-ho.

Good luck on the whole designing bandits thing. I'll be somewhere else.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.