How do you generate combinations in slots to achieve a wanted probability of the user winning?

Say, you decide that he should win $200. How do you generate combinations that'll cause winnings approximately $200?

  • 1
    \$\begingroup\$ If you're making a gambling game (as in, real money), keep in mind that rigging the game may be illegal. \$\endgroup\$ – Anko Apr 17 '13 at 12:08
  • \$\begingroup\$ I edited to clarify, but the question is still too vague. (What are the properties of the slot machine? What combinations cause payouts? What have you tried and why is it not working?) \$\endgroup\$ – Anko Apr 17 '13 at 12:13
  • \$\begingroup\$ The probability of winning does is not directly related to the amount the player wins. You also need to consider the amount of money that's put in. \$\endgroup\$ – MichaelHouse Apr 17 '13 at 14:32
  • \$\begingroup\$ This would probably be better suited for a statistician to answer. They're good at this kind of stuff. \$\endgroup\$ – UnderscoreZero Apr 17 '13 at 15:52
  • \$\begingroup\$ Should win exactly $200, or should win an expected $200? The latter is in fact quite legal for real-money games (where the payout ratio must generally be stated) \$\endgroup\$ – MSalters Apr 19 '13 at 11:14

I'm going to assume this is for a game that doesn't cheat the player. Maybe for a tutorial where you want it to appear random, but need them to have a specific amount of money at the end.

The probability of winning a slot machine depends on the number of slots and the possible combinations. I think you'll be able to figure that out once you have those values.

For the second part of your question, to find some random values that add up to $200, you can add random numbers until you reach $200.

int total = 0;
list<int> winnings = new list<int>();
while(total < desiredTotal)
     //pick a random win bounded on what we still need to reach desiredTotal
     //inclusive random between 1 and what's left
     int win = random(1,desiredTotal-total); 

Then just iterate through winnings when selecting a win amount.

  • \$\begingroup\$ Do I need to keep track of ALL possible winning combinations ? \$\endgroup\$ – user1437328 Apr 23 '13 at 13:15
  • \$\begingroup\$ Yes. If you plan on storing the winning combinations in a list, you would want to store them ALL. It would be easy to use combinatorics to generate the combinations for your list. Look it up if you're not sure what that is. \$\endgroup\$ – MichaelHouse Apr 23 '13 at 13:43
  • \$\begingroup\$ I believe it'll hit millions of combinations (objects/arrays in a master array). \$\endgroup\$ – user1437328 Apr 23 '13 at 15:10

Normally what we do professionally (I work at a company that makes slot machines and their games) is we create something called a paytable which has a list of all the winning combinations we want to appear and how likely they are to appear that way you never have to dynamically decide where the reels stop, you just look it up in the table and spin to that location.

  • 2
    \$\begingroup\$ As a side note, all legal slot machines are not truly random in that they use these paytables, however there is still a random number generated for picking which combination should appear. Also bear in mind that all gaming jurisdictions have different regulations, so if you plan on using real money you are going to have to do a lot of legal research. \$\endgroup\$ – Benjamin Danger Johnson Apr 17 '13 at 18:35
  • \$\begingroup\$ I see, so a table with all possible combinations across all paylines and the worth of each combination - choose one of them to decide if you want the user to win more if he's low on cash or something. hm. \$\endgroup\$ – user1437328 Apr 22 '13 at 7:13
  • \$\begingroup\$ yep, and if you want the player to lose you can just pick random reel stop positions. This gives you pretty fine control over a games payout. The only real room for truly random wins is during a bonus (like if you have a minigame appear not if you just give the player x amount of free spins with extra bonus symbols.) \$\endgroup\$ – Benjamin Danger Johnson Apr 22 '13 at 20:37
  • \$\begingroup\$ Hm any hints on how to generate ALL possible combinations across ALL paylines so that I can have control over whether I can make user win a certain amount or just some amount or I can make him win nothing ? That'd actually create a HUGE table in memory with millions of rows/objects IMHO. I'm pretty much stuck on this :S \$\endgroup\$ – user1437328 Apr 23 '13 at 12:02

So you basically want to cheat the user. Slot games are inherently random. Yes, you set a possibility of winning, but that's it. You don't decide if the user wins or loses.

The best way is to generate a random combination, then calculate the winning on that (2 of a kind, 3, royal flush). If you want to let low-earning users win a bit more than usual, just lower the number of permutations.

An example:

User has 2000$ and rolls once: He is given 5 x 5 x 5 slots. However, if the user drops under 1000$, he's given 3 x 3 x 3 slots. (This dramatically increases the chances of winning, but the animation looks the same, so the user doesn't realize what's happening.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.