Wednesday, January 03, 2018

What's the probability xD6 beats yD6?

What's the probability a roll of xD6 beats yD6? In other words, roll x number of D6's, add them all up, and compare to the sum of rolling a number of y D6's. I got this exact question from a long-time gaming friend some time ago.

My first question was "How large are x and y?" With small numbers, one could do the calculation by hand, but with larger numbers, finding a closed-form formula might be more difficult. "Anything from 1 to 12", was the answer.

What's the distribution of xD6?

The first thing to consider is the probability distribution of the sum of rolling x number of D6's. Most gamers know that the distribution of outcomes for a single D6 equals {1, 2, 3, 4,5 ,6}, with all outcomes having a 1/6 probability of occuring. But what is the distribution of adding multiple D6's together?

In mathematics, this is known as a convolution operator. Simply stated, a convolution adds distributions together, arriving at a final distribution that reflects the sum of various independent variables. We will not go into the mathematics of computing such convolutions for die rolls, but most wargamers are familiar with the notion that the more dice you roll and add together, the more the final result behaves like a "bell curve" (although I always like to point out that a bell curve has a precise mathematical definition, being the Gaussian normal distribution, but let's not start that discussion here :-)).

The plot below shows the resulting probability distributions for rolling 2D6, 4D6, ... , 12D6 (using the excellent tool anydice.com). As you can see, the more dice you roll, the more spread out the results become (varying between rolling all 1's or all 6's), but there's a clear "bulge" in the middle of the distribution that indicates a higher probability for those particular results. Also note that these are discrete distributions, i.e. only the dots are possible outcomes. The lines between the dots are only drawn for a nicer visualization.


Comparing xD6 to yD6

When we want to compute the probability that xD6 beats yD6, we need to consider all possible results of xD6, and compare to them all possible lower results of yD6. All combined probabilities of such combinations need to be added to arrive at the final probability.

We can illustrate this process on the graph below. The distributions for 6D6 and 10D6 are shown. Let's single out the probability that 6D6 gives 28 as a result. We now need to multiply this probability (2.5%) with all probabilities that 10D6 gives a lower result, and add them all up. Then we need to repeat the process for all other outcomes of the 6D6 roll as well.


 Especially for high numbers of x and y, this can result in quite some tedious calculations, so perhaps there is an easier way?

What's the distribution of xD6 -yD6?

What we really want to compute when comparing xD6 to yD6 is the probability that xD6 - yD6 gives us a number greater than 0. This means subtracting two distributions, which is itself a convolution operator.

But we can do something clever here. The distribution of a single D6 is exactly the same as the distribution of 7-D6 (see also "D20 = 21 - D20?").

Thus, yD6 has an identical distribution of 7y-yD6, and so we can say that:

probability xD6 - yD6 > 0
equals
probability xD6 + yD6 -7y > 0
equals
probability (x+y)D6 > 7y

Let's illustrate this using x = 6 and y = 8. The graph below shows that 6D6-8D6 has exactly the same distribution as 14D6, except it is shifted by a distance of 7*8 = 56.  The probability that 6D6 - 8D6 is greater than 0, is the same probability that 14D6 is greater than 56.


What's the probability that zD6 > some number?

So, we need to compute the probability that any distribution zD6 is larger than some number (which itself is a multiple of 7). Can we do that?

It is difficult to find a closed-form solution for this probability. It can be done, but the mathematics involved would fall outside the scope of this article. An alternative could be to approximate zD6 with a Gaussian distribution with the proper mean and deviation, and compute the integral under part of the Gaussian curve ... which involves the so-called erf or error function and is a built-in function in many numerical mathematical packages. But again, this would fall outside the scope of some simple game design calculations. And moreover, such approximation would only hold for large numbers of z.

So, what do we do?

In the end, I fear there's not much we can do than to simulate a large number of die rolls, and compute the probabilities as an average of all these simulations. You can quickly program something like that, using a proper programming language, or even something like MS Excel.

I have done exactly that, and the table below gives the final results ...


The color codings indicate the percentages: 10% and 40% intervals on both sides, and anything below 1% in grey. Draws are not included in the percentages, so that's why 2D6 only has a 44.5% probability of beating another 2D6.

But what about using this as a gaming mechanic?

The mathematics above say nothing about the elegance or usefulness of comparing xD6 to yD6 as a gaming mechanic. I fear this is where everything falls apart. It seems to me that comparing die rolls like this is quite some hassle. You need to roll multiple dice, compute the sum, and compare it to another sum. That's a lot of work for a binary decision. On the positive side, modifiers can easily be included by increasing or decreasing the number of dice.

Moreover, from the table above one can see that the "workable" range of probabilities (yellow and orange areas) is quite limited. So, although x and y vary from 1 to 12, they better do not deviate too much in order not to have a foregone conclusion.

My conclusion?

I would not recommend comparing xD6 to yD6 as a gaming mechanic ... I still prefer using single polyhedral dice for opposed die rolling.

2 comments:

  1. I just found your blog, and I'm glad I did. As an aspiring game designer, this is exactly what I've been looking for: not just explaining the math but connecting to game considerations, too.

    Between this post, your other post on opposed rolls, and your post on buckets, I've learned a lot about my own game. I'd love to hear your thoughts on it. In a nutshell, it uses opposed rolls of variable-quantity buckets, with the winner determined by the highest single untied die result. Tied high dice effectively cancel out and are ignored; duplicate high dice on the winning side count as multiple successes. I love polyhedral dice, but for simplicity's sake I'm sticking with d6s on this one.

    The bucket quantity is variable primarily because I want players to choose how many dice to invest in a particular action attempt; circumstances also modify attempt rolls by adding dice to one side or the other. The goal is to motivate players to think about how they invest their available efforts, which must be divided among their own action attempts, opposing attempts against them, and maneuvering for advantageous circumstances.

    Anyway, thank you for sharing your work on this blog. I hope you're able to keep it up!

    ReplyDelete
    Replies
    1. The way you can also look at your mechanic is as follows:
      - I roll a number of dice (my bucket)
      - For each die rolled (whatever the number), there's a certain chance the die will get nullified by the opposing dice. If you roll only 1 opposing die, there's a 1/6 chance any of my dice gets nullified. But only one die will get nullified. If you start rolling more dice, the probabilites are becoming correlated and not easy to compute, but in essence, there's some probability any of my dice will become void.

      So I guess you might reach the same effect by simply reducing the bucket size to begin with, without the opposed mechanism. Whether that makes sense in the game, or is as much fun, is a different question, of course.

      IIRC the game Horizon Wars (published by Osprey) uses a similar mechanic.

      Thanks for the nice comments! It's been a while since I posted something, but I have a few posts lined up!

      Delete