2
$\begingroup$

I am playing the popular online game World Wars 2. Where neighbouring nations can attack each other and the probability of an attack being successful depends on some dice mechanic.

Each nation is allocated a number of fair 6-sided dice to roll, equal to the number of solider units inside it. When you choose to attack, you roll $n$ dice, and the attack is successful if the sum of these $n$ dice is higher than the sum of $m$ dice rolled from the defending nation.

Each nation requires a minimum of two units to attack, and all units are used in the attack. However a defending nation may have just 1 unit inside, and all units are used in the defense, and the maximum number of units allocated to any nation is 8. So the question can be posed as What is the probability that $n$ fair 6-sided dice roll a sum higher than $m$ fair 6-sided dice, where $2 \leq n \leq 8, 1 \leq m \leq 8$?. The number of units in the attacking nation and the defending nation are known by both players prior to each attack.

Expressed mathematically: $$P(\sum_{i=1}^{n}d_{i} > \sum_{j=1}^{m}d_{j})$$

I have written code to simulate the probabilities for this problem, but I would like to answer this question so that it can be expressed in the general case. I have already looked at questions here, and here, however these questions weren't considering the sum of these rolls.

Each dice has 6 sides, and is fair so it follows a uniform distribution. I have tried to answer this by looking at possible combinations of $n$ and $m$ rolls, and assessing the distribution.

I started by working backwards from the extremes, i.e 8 dice will always roll a sum higher than 1 dice with probability 1, same goes for seven dice. $$P(\sum_{i=1}^{8}d_{i} > \sum_{j=1}^{1}d_{j}) = 1$$

As we work down to 6 dice, there is a non-zero probability that 6-dice will not roll a sum higher than one dice. i.e $$P(\{1,1,1,1,1,1\}) = \frac{1}{6^6}= \frac{1}{46656}$$ And the probability of the 1 die rolling a 6 is $$P(\{6\}) = \frac{1}{6}$$ I then calculated the probability of this even to be $$P(\{1,1,1,1,1,1\}) \times P(\{6\}) = \frac{1}{46656} \times \frac{1}{6} = \frac{1}{279936}$$

This analysis is easy to do in extreme cases however I was stuck on how to proceed from here.

$\endgroup$

3 Answers 3

2
$\begingroup$

Let $P(n,s)$ be the probability that you the sum of $n$ dice is exactly equal to $s$. It can be shown that $$ P(n,s)=\frac1{6^n}\sum_{i=0}^{\lfloor (s-n)/6\rfloor } (-1)^i\binom ni \binom{s-6i-1}{n-1} $$ Furthermore, let $L(n,s)$ be the probability that that the sum of $n$ dice is strictly less than $s$. We can also give a formula for this: $$ L(n,s)=\frac1{6^n}\sum_{i=0}^{\lfloor (s-1-n)/6\rfloor}(-1)^i\binom ni \binom{s-6i-1}n $$ With these auxiliary functions, we can easily compute the probability that sum of $n$ dice is greater than the sum of $m$ dice. The answer is $$ P(\text{sum of $n$ dice}>\text{sum of $m$ dice})=\sum_{s=n}^{6n}P(n,s)L(m,s) $$ We are just summing over all of the distinct ways the event can happen; the player with $n$ dice needs to roll some number, call it $s$, and then the player with $m$ needs to roll less than $s$.

Here's the table of values relevant to the dice game.

  \ m   1        2        3        4        5        6        7        8
  n ┌──────────────────────────────────────────────────────────────────────┐
  2 │ 0.838 │  0.444 │  0.152 │  0.036 │  0.006 │  0.001 │    0.0 │    0.0 │  
  3 │ 0.973 │  0.779 │  0.454 │  0.192 │  0.061 │  0.015 │  0.003 │    0.0 │  
  4 │ 0.997 │  0.939 │  0.743 │   0.46 │   0.22 │  0.083 │  0.025 │  0.006 │  
  5 │   1.0 │  0.988 │  0.909 │  0.718 │  0.464 │  0.242 │  0.104 │  0.037 │  
  6 │   1.0 │  0.998 │  0.975 │  0.884 │    0.7 │  0.467 │   0.26 │  0.122 │  
  7 │   1.0 │    1.0 │  0.995 │  0.962 │  0.862 │  0.685 │  0.469 │  0.274 │  
  8 │   1.0 │    1.0 │  0.999 │   0.99 │  0.948 │  0.844 │  0.673 │  0.471 │  
    └──────────────────────────────────────────────────────────────────────┘
$\endgroup$
1
  • $\begingroup$ The table would be clearer if you used more decimals or distinguished the 1.0 result of rounding from the full 1 probability. $\endgroup$
    – mmj
    Commented Aug 8, 2023 at 14:45
1
$\begingroup$

The most important theory simplification in this problem that you can make is to recognize that subtracting a dice roll is the same as adding a dice roll and subtracting 7. Thus you can go from, “what's the probability that $n$ dice roll greater than $m$ dice?” to “what's the probability that $m+n$ dice roll greater than $7 m$?”

For $m+n=3, 4, 5$ we can get this table, for example the coefficients for 3d6 probabilities are [0, 0,1,3,6,10,15,21,25,27,27,25...] and taking the numbers <= 7 are:

m+n  m       (1-p)              p
 3   1   (1+3+6+10+15)/216   181/216  (83.8%)
 4   1   (1+4+10+20)/1296   1261/1296 (97.3%)
 4   2      721/1296         575/1296 (44.4%)
 5   1       21/7776        2585/2592 (99.7%)
 5   2     1722/7776        1009/1296 (77.9%)
 5   3     6594/7776         197/1296 (15.2%)

You can make this table of coefficients in Google Sheets, for instance, by filling cells A7, A8,... with counting numbers 1,2,3,... off as high as you will need, then filling B7-B12 with "1" each, six ones, this column is the weights for one die, and then filling cell C7 with the formula =sum(b1:b6) and autocompleting down to get the weights for two dice, then autocomplete right to get the weights for 3,4,5... dice. The sum will always be $6^n$ as your normalizing factor.

So if you want the exact answers, build these probability tables in a spreadsheet, to get them exact just don't bother dividing by 6 ever, normalize by the sum at the very end instead. Etc.

Asymptotics

We can do a little bit better if you only care about approximate answers and asymptotic behavior. For four or more dice the central limit theorem is going to hold with pretty good accuracy, so that sum of $m+n$ dice is approximately a normal random variable. More precisely we should say that we want to consider the area $5.5 < x < 6.5$ as area which belongs to the sum 6, for instance.

This then reduces the entire problem to thinking about “Z-scores”, the number of standard deviations the result is above the mean.

For one die the mean is $\frac72$ and the variance is $\frac{35}{12}$, these are both additive for independent random variables like dice. So for $m+n$ dice the mean is $\frac72(m+n)$ and the variance $\frac{35}{12}(m+n),$ and we are trying to evaluate the probability that a standard normal random variable $Z$ satisfies $$ \frac72(m+n) + Z~\sqrt{\frac{35}{12}(m+n)} > 7m + \frac12 $$ which rearranges to $$ Z > \frac{7}{2}\sqrt{\frac{12}{35}}~\frac{m-n+\frac17}{\sqrt{m + n}}\\ Z > -\sqrt{4.2}~\frac{A-\frac17}{\sqrt{2m + A}}, $$ where I have defined attacker's dice advantage $A = n - m$, as I figure the idea is "when do I really need 1 extra die, when do I need 2 extra dice," and so on. The thing on the right is the "Z-score" and you can just evaluate this. So the parallel version of the above table is:

 m   A      Z      p
 1   1   -1.014   84.5%
 1   2   -1.903   97.1%
 2   0    0.146   44.2%
 1   3   -2.619   99.6%
 2   1   -0.786   78.4%
 3  -1    1.047   14.7%

Just comparing the calculated percentages the result is not that bad! (Spreadsheet formulas here are pretty straightforward, =-sqrt(4.2)*(M7-1/7)/sqrt(2*L7+M7) and =1-NORMDIST(N7,0,1,1) in Google Sheets.)

The other thing we can do with this formula is convert probability buckets to some notion of "how decisive is your advantage/disadvantage" and then ask where the thresholds are. In practice this is probably what I would do, just define some buckets like "slight advantage: 50% < p < 75%, solid advantage: 75% < p < 90%, nearly-sure-thing: 90% < p." Then you can use normsinv to convert these thresholds to Z-scores: 0, 0.6745, 1.282.

And then I could say something like,

  • When I attack with advantage -1, that is, $n = m - 1$, it's a nearly sure loss when $m=2$, a solid disadvantage when $m < 7$, and a slight disadvantage for $m \ge 7$.
  • When I attack with $n=m$, that is always a slight disadvantage.
  • When I have one extra die of advantage, that is never nearly-sure, but it is a solid advantage when there are 1-2 defenders, a slight advantage for 3+.
  • When I have two extra dice, that is nearly-sure when $m < 4$, and remains a solid advantage until like $m=15$ where it becomes and remains a slight advantage.
  • With $n$ extra dice the win is nearly-sure until there are something like $n^2$ defenders or so, given the scalings involved.
$\endgroup$
0
$\begingroup$

Let $Q(s,n)$ be the probability that $n$ dice roll a sum of $s$. Then we are looking for the probability

$$P(m,n)=\sum_{s=n}^{6n}\sum_{t=m}^{s-1} Q(s,n)Q(t,m)$$

$Q(s,n)$ has the generating function

$$\sum_{s=n}^{6n} Q(s,n)x^s=\left(\sum_{i=1}^6\frac{1}{6} x^i\right)^n$$ $$=6^{-n}\left(\frac{x^7-x}{x-1}\right)^n$$

So

$$Q(s,n)=\frac{1}{6^ns!}\left(\frac{d}{dx}\right)^s\left(\frac{x^7-x}{x-1}\right)^n|^{x=0}$$

I haven't yet managed to make this into a nice formula for $P(m,n)$ though.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .