Dengixx & Dragons

A Probability Primer with Dungeons and Dragons
or How I Learned to Stop Worrying and Love the Dice

Dice are essential for many table top games, Dungeons and Dragons is no exception. From the very beginning of the game, that is the character creation, you roll dice. Some will even argue that players enjoy the game more as they roll more dice. Different shapes and colors of these math rocks are enticing to many players, somehow striking a chord in them.

This little post is an attempt to shed some light to the basic mathematical concepts behind these wonderous little things that we love so much. Nothing here should be scary to anyone who knows basic algebra, as I will try to keep things simple with diagrams.

Let's Create a Character

Character creation starts with choosing a race and a class, then you determine ability scores. For this you will need some 6-sided dice (or d6). First concept here likely comes natural to everyone: the idea of fair dice.

A die is said to be fair when there is an equally likely chance of landing on any face. Which means, when I roll a d6, the chances of getting any number is 1 in 6. Let's try it. On the left, you can set how many times you want to roll the 6-sided die per clicking Roll. On the right you will see how many times each face showed up (1 through 6). Anytime click Reset to reset the results.

Keep clicking Roll to roll more dice, histogram will just keep updating itself as more results come it. 10000 is quite large, feel free to lower the number if you are curious.

If you start small, you might see some skews in the distribution. It is obviously not guaranteed each number will show up once if you roll the die 6 times. However, as you roll more and more you can see they even out and form what is called a uniform distribution. A flat line, where all possible outcomes have happened approximately the same number of times.

Now, let's look at a more interesting scenario. Rolling ability scores. Ability scores are generated in numerous different ways. Historically speaking, you would roll a 6-sided die 3 times and add the results (3d6). Let's see what would be the expected distribution of results for that case.

This result hopefully is not surprising and should be well in-line with your experience creating characters. Most common are the average scores, 10 and 11 which have no bonuses or penalties in 5th Edition™, hence average. Deviating from the norm is less common. Getting a 3 and a 18 have the exact same probability, and equally rewarding bonuses or punishing penalties.

Why this happens is actually quite easy to understand and is the foundation for understanding everything about probability.

A Crucial Concept: Sample Space

Sample space is the set of all possible outcomes. In this case we are rolling 3 6-sided dice. What can happen? How many outcomes are there?

There are three 6-sided dice, independent from each other (meaning their results won't affect each other). They all can take the values 1 through 6. For the sake of simplicity let's assume we can distinguish the dice from each other: we have a red, a yellow and a green die.

A sample result is: 4 2 6.

If you count all of the possible list of outcomes there are 216 of them (6x6x6). Each of them have the exact same probability of happening, therefore each happen approximately once in 216 trials. So getting a 6 6 6 happens quite as frequently as getting any other outcome.

What determines the probability of getting an ability score is how many different ways that score can be obtained. Remember there are 216 possible outcomes, but only 16 ability scores (3 through 18). So clearly, many of the ability scores can be obtained in many different ways.

Let's see how it works. Here, on the left you can change the output ability score you want to see (from 3 to 18). On the right, you will get the dice combinations that gives you that ability score.

If you look at 3 and 18, there is obviously only 1 way to achieve both: 1 1 1 and 6 6 6. On the other hand for 10 and 11 you have 27 different solutions! This basically means for a single ability score roll, you are 27 times more likely to get a 10 or 11 than a 3 or 18.

Now let's go back to our 3d6 distribution and compare this with our experimental data. If 27 out of 216 outcomes will give you an ability score of 10, it means the probability of that getting a 10 is 27/216 which is 12.5%. On the other hand, getting an 18 is 1 out of 216, which is less that even 1 percent (0.46%). If you were to roll 3d6 for 10000 times approximately ~1250 of them will be 10s and only around ~46 of them will be 18s. Go ahead and give it a shot.

It is quite interesting that if you are able to calculate the total sample space, calculating probabilities are as simple as counting and dividing.

Let's Create a Character Again: The Modern Edition™

I don't recall rolling 3d6s for character generation for a long time. A more player character friendly way of rolling ability scores involves rolling 4d6 and then discarding the minimum of the 4 dice we just rolled.

For this case, it is intuitive that the distribution should be different and favor higher scores. However, it is not super straightforward to tell which score now has the highest probability. Let's look at it.

Here it is relatively straightforward to see that there are 6x6x6x6 = 1296 outcomes, since there are four 6-sided independent dice in play. However, how these map to the 16 ability scores (3 through 18) is now not that straightforward.

Intuitively, getting a 3 is now harder. You need to get all 1s, which can happen only in 1 out of 1296 outcomes. And now, you can get 18 in many different ways!

Let's take a look at how the outcomes have changed:

There is 1 way to get a 3 but 21 ways to get a 18. This means, 1.6% of the rolls will be a 18 (21/1296). On the other hand, the highest probability is now to get a 13 with 172 solutions out ouf 1296 mapping to it! It is quite remarkable how this trick just shifts the means a little bit in player's favor, but still not giving anyone an incredible advantage. Getting a 18 still feels like a huge win.

Can I roll with advantage?

5th Edition™ brought a very crucial yet dead simple mechanic to the game: rolling with advantage or disadvantage. You probably know what it is, but just in case you don't: Rolling with advantage means rolling the same die twice and taking the higher of the results. Disadvantage is the same but you take the lower of the results. And how this mechanic changes the probabilities is quite remarkable.

Now, a regular d20 does not do anything that interesting. But if you are interested in seeing another uniform distribution, click away!

Let's now look at what happens if you have advantage on a d20 roll. What outcome do you think has the highest probability on a d20 with advantage? Try to guess without clicking. I am waiting.

...

Ok, hope you have a guess. Let's see if you are right. Roll d20 with advantage!

Yes, this might be a bit counter-intuitive. But actually it makes a lot of sense. Let's go back to our sample space. This time, we only have two dice, so we will visualize it in a different way.

In the table below, header row shows outcomes for first d20 and header column shows outcomes for second d20. Each cell is the outcome, which is basically the larger of the column vs row numbers. If you hover over any of the cells, it will show you how many possible solutions are there to get that number.

Ok, now there is a lot to digest here. But it is actually really simple. First of all, there are 400 total outcomes you can get if you roll two 20-sided dice (20x20).

Go ahead and hover over 1. There is only a single 1 and the only way you can get a 1 is if you roll 1 on both of the 20-sided dice. It would be really unfortunate. But what it means is you had advantage, and you have definitely failed, it is a fumble, or a critical failure.

Now let's go to 2. There are 3 ways to get a 2. Let's go to 3. There are 5 ways to get a 3. 7 ways to get a 4. It keeps increasing in this way.

And 20 has the highest probability. There are 39 solutions that would result in a 20. Think about this: if you get a 20 in one of the rolls, it does not matter what the other die roll is if you have advantage, you definitely get a 20. Yes, that was the answer. If you are rolling a d20 with advantage, your dungeon master is basically telling you that you are most likely to roll a natural 20 out of all options.

Another interesting observation is, the probabilities change linearly. Probability of getting:

This one little neat trick makes a huge difference for the gameplay. It is dead simple to understand and it changes to outcome drastically. It does not make the critical success a guarantee or a critical failure an impossibility. It creates a very smooth distribution and is very easy to understand. Kudos to the designers behind the idea.

You have disadvantage on this roll

Disadvantage is the exact opposite. You probably can guess what is going to happen, but let's do it. What number do you think your DM has in mind, when they say: roll with disadvantage?

I am sure you guessed it right. But again, let's take a look at what the solutions table is.

Hover over the mighty 20. There is only one way to get a critical success, also known as natural 20 or crit, when you have disadvantage. You have to roll two 20s. That does not happen very often, but it does happen every once in a while.

On the other hand, there are a lot of ways to get a 1. Actually you will most likely get a 1! This is the exact opposite of the advantage. Very satisfyingly symmetrical.

Roll a death saving throw

Disclaimer. This section might seem a little intimidating to read at first, but if you take the time I am sure you will understand it.

Another interesting game mechanic in the 5th Edition™ is the Death Save. Let's look at the 5th Edition™ System Reference Document for definition of this really creative game mechanic.

Whenever you start your turn with 0 hit points, you must make a special saving throw, called a death saving throw, to determine whether you creep closer to death or hang onto life. Unlike other saving throws, this one isn't tied to any ability score. You are in the hands of fate now...

You are in the hands of fate now, indeed. But what is the probability of fate being in your favor? Let's continue reading.

Roll a d20. If the roll is 10 or higher, you succeed. Otherwise, you fail. On your third success, you become stable. On your third failure, you die. The successes and failures don't need to be consecutive; keep track of both until you collect three of a kind.

First thing that stands out to me immediately here is: failure is 1-9 and success is 10-20. It is not really an even distribution to begin with. Game designers want you to live, obviously, without players there is no game! But it is really not intuitive to me, how the probabilities of living or dying will look like in the end. And on top of this, there are a few more special cases. Let's keep reading.

Rolling 1 or 20. When you make a death saving throw and roll a 1 on the d20, it counts as two failures. If you roll a 20 on the d20, you regain 1 hit point.

Very interesting! If you roll a 20, you immediately gain consciousness. If you roll a 1, you don't immediately die, but suffer 2 failures. Game designers are punishing the critical failure and rewarding the critical success differently. Which again is another point in favor of the player.

Ok, we now know everything we need to know to start calculating our sample space. For the sake of simplicity, we are assuming there is no intervention from outside world, your character is just left alone on the floor to their fate.

Here is a simulator for you to see different outcomes. S stands for success, F stands for failure. 1 stands for 2 failures. 20 stands for immediate success.

Ok, let's save your fingers and think a bit more critically about the problem. At every step, we are rolling a d20 and based on the outcome we are increasing either the number of failures or successes we have. So we definitely need to keep track of how many failures or successes we have accumulated so far. The actual order does not matter because they don't need to be consecutive.

Let's define a term called the State to keep this information, which is the number of failures and successes we have. We start with 0 Failures, 0 Successes; which is also referred to as the Initial State. With every d20, we transition to a new state. For a given state, we know if the game has ended: if there are 3 Failures we have died and if there are 3 Successes we have lived! Until then we keep rolling and transitioning to new states.

Let's think about the first ever roll, there are four possible outcomes:

Ok, we are getting somewhere. Let's think about how we can visualize this. Since our State has 2 variables, it is intuitive to think about this as a table. Just as we did for the advantage vs disadvantage discussion since we had 2 dice! In the below table, you can see all of the possible States. Header row shows how many successes you have, Header column shows how many failures you have.

White cell is where you initially start with 0 Failures and 0 Succeses. Green cells are states where you end up living and red cells are states where you end up dead. Game continues until you reach a green or a red cell.

Now let's continue our visualization by showing how you move through these states. White cell shows you which state you are in and as you roll dice you will move through the states.

If you tinker with this a little bit, it will make more sense what it is. Now back to the original question. What is the probability of living vs dying? The answer is: it is only about how you get to the green vs red cells.

Now, let's talk numbers. We will play this game 8000 times. Below is our beloved state table again. This time it is larger and now you see how many times we are expected to land on each cell.

Rules of the game is very simple. You start at 0,0 and after each death save:

Ok, these numbers can be a lot to digest. But it will all make sense. When you hover over a cell it turns white and it also highlights two other types of cells. Brown colored cells are the cells that you go to from the one that you are hovering. Purple colored cells are the cells that you might be coming from. Let's go through an example to understand better.

Hover over the initial state cell at 0,0. It makes sense that this cell has the number 8000, which is the number of games. Every game starts at this cell, so we are guaranteed to be at this cell in every game. Now there are no purple cells for this cell, since there can't be a cell that comes before this. However there are 4 brown cells. Let's see each case:

Not so bad! Let's look at a bit more complex example. Hover over to 2 Successes, 2 Failures state which we encounter in 2220 games. Now when you hover over it there are 3 purple cells. These are the cells we can arrive to this cell from. Let's look at each possible case.

That's it, there are no other possible scenarios to arrive at this cell! Numbers coming from the purple cells, exactly add up to 2220 (100+960+1160). How about the 2 brown cells?

As you can see the split is not even, 9/20 of the time we are dead and 11/20 of the time we live to tell the tale. Again, numbers going to the brown cells exactly add up to 2220 (1221+999).

The Answer

Now let's proceed to the end of this chapter, finally answering the question: will the fate be in your favor? Death states are at the bottom row: in 916 + 1204 + 1119 = 3239 games we die, and the life states are at the rightmost column: in 1700 + 1640 + 1421 = 4761 games we live.

Here we have our answer finally: you live 59.5% of the time. Another very simple to understand game mechanic with very profound implications. It makes one appreciate the thought that goes into the game design.

Finally, Can we settle a debate?

1d12 vs 2d6 (and a much less popular 3d4), is an interesting debate. These are damage dice, 1d12 is greataxe damage whereas 2d6 is greatsword damage. 3d4 is not attributed to any weapon in 5th Edition™, but is here just to spice things up.

Which one is better? What is the difference? Let's take a look at our good and simple friend 1d12. By now I am sure you know what you will see when you click Roll.

Now, as you probably have imagined you see yet another uniform distribution. How about 2d6? What does that look like?

Few things to call out here. First of all, with 2d6 you can't get a 1 obviously and it is not a uniform distribution anymore. You will most likely get a 7. The interesting thing here is, your probability of getting something low (2, 3) or something high (11, 12) is lower compared to the 1d12. Before we ponder more on what this really means, let's checkout 3d4.

Similar to 2d6, 3d4 moves the highest probability to the right. You can no longer get 1 or 2. Getting a 3 or 12 with 3d4 is very low probability (actually less than getting a natural 20).

Now just to make a point, let's create another hypothetical damage dice: 6d2. d2 is a 2-sided die, which is basically a coin. There is obviously no weapon that does this damage in the 5th Edition™, maybe it could have been a gun shooting coins in a steampunk setting. Let's see what 6d2's damage distribution looks like.

Now if you compare 6d2 to 1d12, you can see it might be a bit more enticing to choose it. Getting a 12 is still very hard, but the highest probability outcome is now a staggering 9 damage.

Everytime we roll more dice that can sum up to the same maximum outcome, we are essentially reducing the probability of getting that maximum. However, we are now dealing more damage, more reliably.

Now to really understand what this actually means, let's think through an experiment.

The Drunken Giant

Let's assume our character is fighting against a drunken giant. We are hitting the giant with our weapon of choice that can deal either 1d12, 2d6, 3d4 or 6d2. Giant is so intoxicated that it can't defend itself. Every strike is a hit but we still want to kill the giant as quickly as possible. Which weapon would you choose?

Now we will do a simulation, but I suggest to stop, think and choose your weapon.

...

Ready? If you click Roll below, for each weapon we will simulate killing the drunken giant 10000 times and on the right we will report how many hits it took per attempt.

So, what is the moral of this story? You can clearly see as you roll more dice, you kill the giant faster. 1d12 has the largest spread. On the other hand, as you roll more dice the outcome is more and more deterministic. For example we are almost guaranteed to kill the giant in 16-18 hits with the 6d2 damage dice. You might say it is the best choice for this case.

But this is just one experiment and is a highly unlikely situation. How about when you are against the BBEG and you get only a single shot to kill them? Which weapon would you choose then?

This might feel non-satisfactory, but to me it is quite the opposite. This shows how simple nuances in the game mechanics can lead to different behaviors that might seem better or worse in different situations. It is up to you to choose and there is really no wrong answer.

Ok, what do I do with all this information?

I really don't know the answer to this question. Maybe you will convince your DM that rolling 1d20 for ability scores is a good idea, or maybe you will change your weapon of choice. Maybe you will stop thinking a 3rd level Fireball can really deal 48 damage (Probability of getting all 6s in 8d6 is 1 in ~1.6 million).

For some people, math is just a tool and is not really interesting by itself, it is only useful as long as it is relevant to what they are really interested in. For other people, math itself without any utility is interesting. I don't know which camp you feel you are closer to. But if you ended up reading this until the very end, you are very likely in one of them.

Lastly, checkout Dengixx & Dragons.