Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
1  
If you're making a gambling game (as in, real money), keep in mind that rigging the game may be illegal. –  Anko Apr 17 '13 at 12:08
    
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?) –  Anko Apr 17 '13 at 12:13
    
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. –  Byte56 Apr 17 '13 at 14:32
    
This would probably be better suited for a statistician to answer. They're good at this kind of stuff. –  UnderscoreZero Apr 17 '13 at 15:52
    
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) –  MSalters Apr 19 '13 at 11:14
add comment

3 Answers

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); 
     winnings.add(win);
     total+=win;
}

Then just iterate through winnings when selecting a win amount.

share|improve this answer
    
Do I need to keep track of ALL possible winning combinations ? –  user1437328 Apr 23 '13 at 13:15
    
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. –  Byte56 Apr 23 '13 at 13:43
    
I believe it'll hit millions of combinations (objects/arrays in a master array). –  user1437328 Apr 23 '13 at 15:10
add comment

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.

share|improve this answer
2  
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. –  Benjamin Danger Johnson Apr 17 '13 at 18:35
    
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. –  user1437328 Apr 22 '13 at 7:13
    
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.) –  Benjamin Danger Johnson Apr 22 '13 at 20:37
    
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 –  user1437328 Apr 23 '13 at 12:02
add comment

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.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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