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?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityHow 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?
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.
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.
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.)