Wow, it’s been a while since my last post. I wish I had time to do this more often, but such is life.

I’ve been thinking a lot about statistics lately, and how they can be used in game design. We’ve all seen this problem in any game, particularly indie games (including a lot of browser-based game) – a problem with randomness. Sometimes a game doesn’t appear to leave enough to chance, and it becomes predictable. Other times a game is too random, to the point of frustrating a player when despite skill or a “better hand”, fate can easily turn against them.

This article will be the first in a series of probably three articles on statistics and randomness. Today I’d like to talk about what it means to consider the odds that an event might happen, given multiple attempts at it. For example: if an event has a 25% chance of occurring, you might expect that given 4 attempts at it, you’re pretty much guaranteed success. Given a second thought, we know that not to be exactly true. So what are those odds, anyway? More after the jump.

Let’s start with a simpler example: the good ol’ coin flip. Flip a coin once – what are the odds of getting heads? 1 out of 2, or 50%. If you flip a coin 8 times and it came up heads every single time, what are the odds of one more flip being heads? This is, of course, a trick question. The odds are still 50/50 because each flip of the coin is unaffected by any other flip. The individual flips are independent events. How about the probability that by flipping a coin twice, both times it comes up heads? There are four possible outcomes of two flips of a coin (H=heads, T=tails): HH, HT, TH, TT. Right there we can see that two heads occurs once out of four possible outcomes, so the chances are 1 in 4, or 25%.

This example leads us to the Multiplication Rule for Independent Events. Independently, each flip has a 50% chance of coming up heads. When events are independent, to find their cumulative probability, you can multiply their individual probabilities. Probabilities are always calculated as a number from 0 to 1; the equivalent of 0% to 100%. So to get the chance of a getting two heads out of two flips of a coin, we multiply:

P(heads and heads) = P(heads) x P(heads) = 0.50×0.50 = 0.25

In other words, 25%.

How does this relate to a game? Knowing how to calculate the cumulative odds that an event will occur can help identify when an event has been set up to happen too rarely. Imagine a scenario where a player has to search three chests and each time there is a 20% chance that a chest will contain some amulet. In order to get to a secret room, the player needs to get all three amulets. You might think that sure, the odds of getting the amulets from all three chests are against the player, but there’s still a pretty good chance. Let’s find out.

P(amulet and amulet and amulet) = P(amulet)3 = (0.20)3 = 0.008

In other words, there’s a 0.8% of getting all three amulets. Less than 1% – that’s pretty close to impossible! Even if the player is allowed to attempt the task periodically, it’s likely they will never achieve the goal.

Let’s try a different angle. What if we know what the percent chance is of an event and we want to know what are the odds that it will happen at least once given a set number of trials? For example, taking the coin flip – if I flip a coin twice, what are the odds that I will get heads at least once?

If you recall, the four possible outcomes of two flips of a coin (H=heads, T=tails): HH, HT, TH, TT. In this case, we win if the outcome is HH, HT, or TH. That’s 3 out of 4, or 75%. Another way to make the calculation is say the probability of the first coin getting heads is 0.50 (HH or HT), and the probability that the first coin was not heads but the second coin was heads is 0.25 (TH). Since either of these combinations means success, we add them together:

P(heads on first flip OR heads only on second flip) = 0.50 + 0.25 = 0.75

Now of course, neither of those methods are very helpful when doing anything more complex than a couple coin flips. A third way we can look at the situation which lets us use the multiplication rule is to think of it in terms of what is the probability that the event does not occur. In other words, what are the chances that both coin flips will come up tails? If we can find that, we can take the inverse of it to find the probability of our desired event.

P(tails and tails) = (0.50)2 = 0.25
P(not both tails) = inverse of P(tails and tails) = 1 – 0.25 = 0.75

As you can see, the inverse of a probability is found by subtracting that probability from 1. All three methods have shown us that the chance of getting at least one head out of two coin flips is 75%.

Now let’s think of a more useful scenario. Let’s go back to our three chests story, but this time we’ll say the player only has to get one amulet. The chance to get an amulet from a chest was 20%, so the odds that they don’t get an amulet from a chest is 80%. They have three chances (because there are three chests), so let calculate the odds they don’t get a single amulet from any chest, then take the inverse again to find out if the player has a decent chance of getting at least one amulet:

P(no amulet and no amulet and no amulet) = (0.80)3 = 0.512
P(at least one amulet) = 1 – 0.512 = 0.488

In other words, they have a 48.8% chance of getting at least one amulet in three tries.

Let’s take this example a little further, because I really want to point out a common misconception about odds. The chance to get an amulet is 20%, or one out of five. Logically, you might think that if you give a player 5 chances, they will be guaranteed to get the amulet once. This faulty logic is often referred to as the Law of Averages (which is not actually a “law” of real mathematics at all). Given what we’ve learned, let’s see what the real odds are for a player finding at least one amulet in 5 tries:

P(no amulet and no amulet….etc) = (0.80)5 = 0.32768
P(at least one amulet) = 1 – 0.32768 = 0.67232

Given 5 tried, the chance of getting one amulet is actually only about 67%. It’s likely, but it’s far from a guaranteed success, isn’t it?

So how do you guarantee success based on probability? Well, you’re going to have to do it programmatically, because no combination of probabilities (other than all events getting a 100% chance) is ever going to combine to become 1.0. If you flip a coin 100 times, it’s extremely likely you’ll get at least one head, but technically there is one outcome that would result in 100 tails.

Let’s look at one last example so we can see how more chances increase the likelihood of a success. Let’s say a player is on a quest and has to get a special belt that some orcs wear. One out of ten orcs wear this belt, so we set up the game to give any slain orc a 10% chance to drop the belt. If the player kills just one orc, they’ve got a 10% chance to get their goal. Let’s look at the chances of getting a belt for 5, 10, and 20 slain orcs (notice that the chance of not getting a belt is 90%):

P(at least one belt in 5) = 1 – (0.90)5 = 1 – 0.59 = 0.41 (or 41%)
P(at least one belt in 10) = 1 – (0.90)10 = 1 – 0.35 = 0.65 (or 65%)
P(at least one belt in 20) = 1 – (0.90)20 = 1 – 0.12 = 0.88 (or 88%)

Even after killing 20 orcs, there’s still only an 88% chance of success. When we said 10%, we were thinking the player would have to kill about 10 orcs, but turns out even killing 20 orcs is not as close to 100% as we’d like! Now that we’ve done the calculations, we can see that we may be frustrating players with these odds. Let’s readjust and try a 15% chance for an orc to drop a belt (85% chance they don’t drop one):

P(at least one belt in 5) = 1 – (0.85)5 = 1 – 0.44 = 0.56 (or 56%)
P(at least one belt in 10) = 1 – (0.85)10 = 1 – 0.20 = 0.80 (or 80%)
P(at least one belt in 20) = 1 – (0.85)20 = 1 – 0.04 = 0.96 (or 96%)

Hey, that’s a little more reasonable. We might even want to tweak it a little farther; at least now we have a method to determine the real odds.

In summary, when it comes to probabilities, don’t rely on “instinct” or faulty logic like the “Law” of Averages. Some simple calculations can give you a much more concrete idea of what kind of chances you’re giving your players.

6 Responses to “Statistics: What are the real odds?”

  1. Vlad Says:

    Very good article

  2. Comrade Ravenhawk Says:

    Statistical probabilities are always rather interesting. I notice it the most with things like drop rates when I’m playing online games. In Ragnarok Online, it’s quite common for the “good” drops from any given monster to have a .01% chance of dropping. Therefore, you rain down genocide upon any particular monster type in order to get what you want. “Grinding” is a normal part of those games, but they’ve pushed it a bit far there. In Browser based games I see this problem a lot less frequently, as percentages tend to be more reasonable. This may be due to the fact that it is easier for your audience to become bored, lose interest, and quit playing.

  3. Wavesong Says:

    As a PBBG developer, explaining probabilities to gamers can be very frustrating. Often they expect to beat a weaker opponent every time and if they do lose to a weaker player/team/monster – they complain that the game requires no skill since it is just based on a random element.

    Explaining that this is how real-life works (that nothing is 100% certain, but to do well in life, you need to make decisions that maximise odds of success; that even the most skilled and able people suffer from “bad luck”) can often be difficult with non-mathematically minded players (and we haven’t even started on normal/lognormal distributions yet!)

  4. Ranger Sheck Says:

    (and we haven’t even started on normal/lognormal distributions yet!)

    That’s my next article :)

  5. appa Says:

    What are the odds of 2 Hs in 3 tries? If the coin is loaded and there is 60% probability for H, then what is the probability of 2 Hs in 3 tries?

    Liked your lucid argument and clear presentation. I wuld lke to hear from you.

    Regards, Appa

  6. overklokan Says:

    very nice article that will make me recalculate % in my game for sure … keep on going man!

Sorry, comments are closed for this article.