Showing posts with label OpposedDice. Show all posts
Showing posts with label OpposedDice. Show all posts

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.

Wednesday, February 08, 2017

Opposed Die Rolls

Wargaming rulesets and rule mechanics come in many different variations, but one of the mechanics that is almost universally accepted is the rolling of dice to resolve actions. Throwing a handful of dice across the table can provide a nice tactile component to the game. Moreover, rolling dice could create tension and help shape the narrative of a game. I guess most wargamers can recollect games in which the fate of the entire battle - at least in their perception - depended on the outcome of a single die roll.

Dice mechanics come in many different variations and flavours: single die rolls, buckets of dice, rolls to beat a target number, the resulting die roll as an index in a chart, the use of polyhedral dice, etc. One of my favourite mechanics is the opposed die roll. This article will delve a bit deeper into the mathematics of opposed die rolls, as well as some good practices on how to use it as a mechanic in your rules of play.

 

D4 versus D12

Opposed die rolls are in essence very simple. Whenever an action between two figures or two units needs to be resolved, both players roll a die. The numerical results are compared and the highest roll is declared the “winner”, with an appropriate result defined within the framework of the rules. Such a mechanism can be used on shooting, melee, morale, …: the usual actions one wants to resolve on the battlefield. Opposed die rolling is obviously not new and has been applied in many different rule sets over the years, if not decades.

The system is most flexible when we allow different types of dice (D4, D6, D8, D10, D12) to be rolled against each other. I realize that there is a cult of wargamers that consider a D6 to be the only proper die type permitted on the gaming table, but the generation of gamers that grew up with Dungeons & Dragons and other roleplaying systems think nothing of using the full array of polyhedral dice. Once you accept that idea, the die type itself can be used to represent a quality metric for a specific characteristic of the unit or figure. E.g. a figure can have a D8 for shooting, a D6 for melee, and a D12 for morale, with the higher die type representing a better ability in that specific characteristic.

The beauty in using a range of different die types is that die modifiers can be implemented not as numbers to be subtracted or added to the rolled result, but as changes of die type. E.g. an action that requires rolling a D8, but has a positive modifier, is upgraded to rolling a D10. As such, you apply the modifier before the die roll, rather than applying a bonus or penalty to the outcome of the roll. That might seem like a gimmick, but is actually very useful and creates a better flow of the game. Indeed, once die types are determined, both players roll their die, compare each other’s results, and can see in the blink of an eye who “wins” the action. There is no need to modify the results after the dice has been rolled. The naked die roll is what you get, with a certain level of excitement and an adrenaline rush when you see the rolled numbers pop up and you immediately know what the outcome of the action is.

Mathematics

Let us first look at some of the mathematics of opposed die rolling. Obviously, you have a higher chance of beating your opponent’s D8 when you roll a D10 instead of a D6, but what exactly are the probabilities?

For anyone who is a bit versed in probability theory, the probabilities are fairly easy to compute with a closed mathematical formula. For those who are not familiar with it, the best thing to do is to count all possible winning outcomes and compare them to the total number of outcomes. Let’s work through an example to show how it can be done. Suppose I roll a D8 versus your D6. I can roll 8 different numbers (each with equal probability), and you can roll 6 different numbers (also with equal probability), for a total of 48 possible outcomes. The table below summarizes all possible combinations that can be rolled. A “W” indicates a win for me, a “L” indicates a loss (or a win for you), and a “D” indicates a draw:

D8 vs D6
1
2
3
4
5
6
1
D
L
L
L
L
L
2
W
D
L
L
L
L
3
W
W
D
L
L
L
4
W
W
W
D
L
L
5
W
W
W
W
D
L
6
W
W
W
W
W
D
7
W
W
W
W
W
W
8
W
W
W
W
W
W

To compute the probability that a D8 wins vs a D6, we count the number of 'W's, giving us 27. Dividing by 48, this gives a 56% for a win. Similarly, we have 15/48 = 31% chance for a loss, and a 6/48 = 13% chance for a draw.

The same exercise can be repeated for other combinations of dice, of which the rounded results are tabulated below. Each entry gives the rounded percentages for a win, a draw and a loss result. E.g. when rolling a D8 vs. a D10, there is a 35% chance of a win, 10% chance of rolling an equal number, and 55% chance of losing. Of course, these numbers are reversed when rolling a D10 vs. a D8 (55% win, 10% draw, 35% loss), as you can see in the table.

(down) vs (across)
D4
D6
D8
D10
D12
D4
38 / 25 / 38
25 / 17 / 58
19 / 17 / 69
15 / 10 / 75
13 / 8 / 79
D6
58 / 17 / 25
42 / 17 / 42
31 / 17 / 56
25 / 10 / 65
21 / 8 / 71
D8
69 / 13 / 19
56 / 13 / 31
44 / 13 / 44
35 / 10 / 55
30 / 8 / 63
D10
75 / 10 / 15
65 / 10 / 25
55 / 10 / 35
45 / 10 / 45
38 / 8 / 54
D12
79 / 8 / 13
71 / 8 / 21
63 / 8 / 30
54 / 8 / 38
46 / 8 / 46

 There are some interesting observations to be made:
  • First of all, as can be expected, the win percentage increases if the attacker’s die is of a better type. However, the exact increments can vary depending on the situation and what dice are involved. 
  • Even when rolling a D4 against a D12, there is still a 13% (1 in 8) chance of winning the die roll. If the draws were counted as favourable for the player rolling the D4, chances of winning would be 21% (1 in 5). Even in this extreme situation, these are fair probabilities that cannot be simply ignored or dismissed as “impossible”. 
  • When rolling dice of equal types versus one another, the win/loss percentages are of course identical, although the chance of rolling a tie is higher with the lower dice types. Hence, the count of a tie towards a win or loss affects low dice types more than it affects higher dice types.

 

Good practices

The above analysis provides us with the raw numbers. It depends on the nature of a specific rules framework how you want to implement opposed die rolling, but a few good practices make this system even more elegant than it already is.

A first recommendation is to use same-coloured dice for each type. All my D8 are yellow, all my D10 are red, etc. This allows for a quick grab of the right die from a pool of dice at hand. Although many gamers can blindly pick a D10 from a heap of dice, there are still many who have trouble doing so and will pick a D8 or D12 instead. However, colours are immediately recognizable and provide an additional visual cue. Many online shops selling dice allow you to specify the colours for individual dice and, in my experience, it’s worth the investment. Five or six dice of each type are enough to have a game running smoothly, without having to waste time looking for that single D8 you happen to own.

A second recommendation is that all bonuses and penalties that depend on the status of your own figure or unit, are applied to your own die roll. Suppose you take a shot at an enemy in cover. As cover affects the status of the defending figure, the defending die roll of the target is promoted by one die type. Technically, we could also apply a penalty on the die type of the shooter. But then, the player controlling the shooter has to ask the player controlling the target whether cover applies or not, whether he has moved or not, and so on. By designing the rules in such a way that each player needs to know just the status of his own figures without having to make detailed inquiries about others’ figures, the game speeds up significantly. Each player rolls his own die and can immediately shout out his result. The winner of the action can be determined quite quickly. Of course, it requires a gentleman’s attitude towards the game to trust one’s opponent in determining and rolling the right die type for his own figure (rather than the need to double-check everything).

But what about the resulting percentages? Looking at the table, we see that either increasing the defender’s die or reducing the attacker’s die does not make much of a difference. As an example, consider a base situation D8 versus D8 and let’s assume the defender is in an advantageous position. Either we increase the defender’s die to a D10, or we decrease the attacker’s die to a D6. The first situation would yield a 35% win for the attacker, while the second situation yields a 31% win. The difference between these percentages is too low to be meaningful in an actual game.


D6
D8
D10




D6
42 / 17 / 42
31 / 17 / 56
25 / 10 / 65
D8
56 / 13 / 31
44 / 13 / 44
35 / 10 / 55
D10
65 / 10 / 25
55 / 10 / 35
45 / 10 / 45





Similarly, if we were to apply a bonus to the attacker or a penalty to the defender, we would end up with either a D10 vs. a D8 (55% win for the attacker), or a D8 vs. a D6 (56% win for the attacker). Again, the differences are negligible.



D6
D8
D10




D6
42 / 17 / 42
31 / 17 / 56
25 / 10 / 65
D8
56 / 13 / 31
44 / 13 / 44
35 / 10 / 55
D10
65 / 10 / 25
55 / 10 / 35
45 / 10 / 45




 

Variations


You can build and expand upon this basic system rather easily:
  • You could expand the dice range even further and include really exotic dice such as a D14, D16, … up to the familiar icosahedral D20. Some specialized dice shops sell these types, although there are not easy to find. On the other hand, such dice are far from familiar and they tend to get confused with each other as they do not have standardized shapes. Moreover, the differences in probabilities between the higher die types tend to get smaller in such a way that the practical influence of these different die types is less outspoken.
  • One could also vary the number of dice. E.g. a positive modifier could imply rolling two dice and take the highest result, or even rolling different types together. However, this would add an additional step when the result of the roll needs to be read out and makes the entire system less elegant, in my opinion. 
  • The same argument can be made for adding numerical modifiers after the dice have been rolled. Although it is a common mechanic in many wargames, I would not combine it with varying die types. Otherwise, you could create confusion in that one type of bonus implies a change of die type, while another type of bonus indicates a change to the rolled number. A good rule set must use elegant game mechanics without adding too many different procedures.

Conclusion 

I fully realize that a mechanic such as an opposed dice roll does not in itself define a set of wargaming rules. You still need to give meaning to the actions that are resolved by rolling the dice. However, I do think it is important that you refine your mechanics in such a way that they become intuitive and easy to use. Moreover, there has to be a full understanding of the underlying mathematical probabilities to prevent the risk that your rules and the plausibility of events happening on your gaming table are not fully comprehended by all players.

Game mechanics also are a matter of taste. If after reading this article you still prefer the buckets of dice method, or swear by using D6s only, please do so by all means. But it can only enrich your understanding of game design when you have at least this knowledge of other methods, along with their good practices. After all, if you only know how to use a hammer, every problem looks like a nail.
 

Addendum (January 2021)

 
I sometimes have received questions about the exact formula for computing the odds of Dx vs Dy. I always answered these in private, also because they seem a bit trivial to me given the method (tabulating all results) described above. But let's give the formula here as well.
 
Suppose x >= y. From the table shown above (D8 vs D6), it's obvious that we have a total of x*y outcomes. These can be divided in 3 groups: a win for Dx, a win for Dy, or a draw.
  • The draw is the easiest: it's the diagonal of the table, and equals y (the size of the smallest die) possible outcomes. Hence the probability is y/x*y = 1/x
  • A win for y (the smallest number) is computed next. Again, when looking at the  table, you can see the number of outcomes equals 1 + 2 + 3 + ... + (y-1). That can be written in a closed formula as y*(y-1)/2. Thus, the probability of this happening equals y*(y-1) / 2*x*y = (y-1) / 2*x
  • A win for x can be computed in a similar way: 1 + 2 + ... + (y-1), but we also have to add the block of outcomes for which Dx rolls guaranteed higher than Dy. That's a number of outcomes equal to (x-y)*y. The total number of outcomes for a win for Dx is thus: y*(y-1)/2 + (x-y)*y = (2*x*y - y - y*y)/2; end hence the probability equals 1 - (y+1) / 2*x

Sanity check: adding all probabilities should result in 1:

1/x + (y-1) / 2*x +  1  - (y+1) / 2*x  = 1.