Question about probability in game

So I have game I'm designing where you get an item 1 in x times. But because of bad luck you may not get the item in x times and if you don't the next roll I automatically give it to you. This will throw off the probability as I still want it to be 1 in x but it will be slightly higher as I give it to you automatically if you don't get it. How would I calculate the probability to get a proper X?

For example lets say you get a gold coin 1 in 6 times. But after 6 rolls you haven't gotten a coin. So the next roll I automatically give you a coin. But I still want the probability to be 1 in 6. So in order for it to be 1 in 6 with "auto give" roll I would have to adjust the initial probability to be like 1 in 6.5.

Posted Jun 13, 2017, 1:54 PM UTC

1511
Statman12•

What you are describing is a process in which there could be an infinite number of rolls until you get a prize, but you want to enforce a maximum of x+1. If you keep a variable y which counts the number of rolls, then you'd just need to put in a condition: IF( y>x ) THEN( give prize and reset y to 0 ).

Now, from your description, it sounds like you want to consider each roll as an independent trial, but you've noted that doing so, it's possible that in x trials the player may not get the prize. So, you want to add a seventh roll that will guarantee success, and have a probability distribution. As other have at this point noted, this is not possible in our framework. However, if you change perspective slightly, the problem becomes easy.

Instead of looking at the rolls individually, consider generating the value y such that "the prize is obtained on roll y". This is just sampling from a uniform distribution P(G=y) = 1/x for y=1,...,x. Just as I mentioned in the first paragraph, you'd need a counter y, but in this case, you'd be sampling a value, say z=3, and then the player gets no prize until y=z.

If you really wanted to use the concept of getting a guarantee win on the x+1 roll, there are a variety of ways in which you could assign the probabilities, but in the end you would still need to use the approach I just described: sample the value z which defines the roll on which the player will get the prize. One way you could do this and incorporate the idea of independent rolls would be the following:

Calculate the probability of No Prize on the first x rolls, which is (1 - 1/x)^x. This is the probability of getting the prize on the x+1 roll (since it is a guarantee). Then subtract this from 1 to get the probability that the prize is somewhere among the first x rolls, and distribute evenly (divide by x). So the probability of a Prize on rolls 1,...,6 would be P(G=y) = [ 1 - (1 - 1/x)^x ] / x for y=1,...,x. In the example of x=6, this yields the following probabilities:

y1234567
P(y)0.110.110.110.110.110.110.34

Then, this is just a multinomial distribution, and you'd be sampling the roll at which the player gets the prize (the value z I mentioned earlier), but now there are unequal probabilities.

6
this-is-the-future•

The sum of all probability values for all discrete values in an actual pmf is 1. What you have written is not a pmf.

3
Statman12•

Care to explain?

Edit: Nevermind, I assume you were talking about the initial "PMF", and not the table. Edited the original.

1
AspiringInsomniac•

Note that in this case, the probability of success changes with each successive failed roll.

  • Roll 1: 0.110
  • Roll 2: 0.124 (from 0.11/0.89)
  • Roll 3: 0.141 (from 0.11/0.78)
  • Roll 4: 0.164 ...
  • Roll 5: 0.196
  • Roll 6: 0.244
  • Roll 7: 1.0 (guaranteed)

if you want the probability to stay the same between the rolls up until the guaranteed roll, you'll have to do the math a little differently.

1
steaknsteak•

In short, you can't. To make the "probability" 1/6 (and by that I mean the rate at which you get the coins), you would have them get the gold coin with probability 0 (they never get it) on the first 5 rolls and then automatically get it on the 6th. Guaranteeing it at any point removes the concept of a long run probability because the guaranteed coin is not a probabilistic event.

At a game design level you might want to question whether it would be so bad to just let people just get unlucky sometimes.

3
samclifford•

The statistician in me says there's a solution, the board gamer in me says if you're automatically granting it after a given number of fail rolls you might as well skip the rolling as luck determines only how soon you get it, not whether or not you do. Let people be unlucky.

2
Postscript624•

I don't think there is an X that will satisfy these conditions. Let P(x) be the probability that you roll/draw the winning number in x rolls/draws, then your auto-give occurs with probability 1-P(x). A player can either win the coin in x rolls, or they can trigger the auto-give, but these seem to be the only two outcomes so we have that the probability of winning is P(x) + 1 - P(x) = 1. You can adjust P(x) however you like and it will not change the fact that the player cannot lose.

In other words, since you always auto-give unless they have already won the coin, the player cannot lose.

2
this-is-the-future•

Just going back to the simplest example of a six sided die when this is plotted in a graph each of the point 1,2,3,4,5,6 have probabilities of 1/6. When you calculate the area of the pmf (probability mass function) you end up with 1. By definition. The event "always win" is P(X) = 1. This would be like having a one sided dice. No need to flip. Always win. What you are asking for is not how probability is fundamentally used so there is no calculation that can be made.

2
ATG77•

You could think of this as a combinatorial mathematics problem. If the probability was .75 that they would fail (or ~1 in 4 successes), failing all 6 times would be .75 * .75 * .75 * .75 * .75 * .75 or ~18%, which is close to 1 in 6. You can't have it so that they both maintain a 1 in 6 chance for each roll and a 1 in 6 chance across 6 rolls. You have to pick one.

2
scottzed•

In your case you want the Gambler's fallacy to be true, so just draw a random number from U{1,6} which will represent that the ith roll is successful. Your initial approach is to perform successive, independent draws from Binomial(1/6), but the constraint you're imposing (must be successful after a certain number of failures) violates this.

1
[deleted]•

[deleted]

1
redditsettings•

Nothing to change. Keep it 1/6 chance.

The "1 in 6" should intuitively tell you that, on average, you'll get 1 in 6.

Prove to yourself, program 6 rolls 1,000,000x times. You'll get 1,000,000ish wins, average of 1 per session, the desired behavior.

Proof: This is a Bernoulli distribution, average is np, n=6, p=1/6, average is 1 (E[X]=1).

0