# Per-Attack Risk Dice Odds

##### 2014-07-23

In Risk-like games, players face off against each other on maps divided into territories. One player may conquer the territories of another by eliminating all of the other’s units from a said territory. Units can be eliminated with the throwing of the dice, and a unit is lost for every instance where the attacking player has a higher score on one cast die. The throwing of the die is governed by the following rules:

- The defender rolls a maximum of 2 dice (one per unit - contingent on the unit number on the attacked territory).
- The attacker rolls a maximum of 3 dice (one per unit - excluding the last unit and contingent on the unit number on the attacking territory).
- Only the top dice are considered if a player throws more dice than his opponent.
- Dice are paired with each other in an ordinal fashion.

There are already texts providing more wide-ranging whole-battle predictions (as for instance here), and closed-source (and in many cases, also inaccurate) battle simulators. Here we try to offer a transparent formulaic reference and odds table for all single-attack scenarios.

## Notation #

We use the following notation to represent the probability of the *attacker* obtaining a specific outcome given $a$ attacking units (ergo $\geq a+1$ troops on the attacking territory) and $d$ defending units:

- Victory: \(\Pr(V\vert(a,d)) \)
- Tie: \(\Pr(T\vert(a,d))\)
- Defeat: \(\Pr(D\vert(a,d))\)

## Scenarios #

Given a cap of 2 defenders and 3 attackers we can expect $2 \times 3$ attack scenarios, which we shall be listing according to the value of $(a,d)$:

### (1,1) #

Here calculations become easier since there is no possibility of a tie: $\Pr(T|(a,d)) = 0$. Further, we sum the probabilities of the attacker winning, contingent on the 6 possible and equally probable defender die outcomes:

$$ \Pr(V|(a,d)) = \frac{1}{6}\sum_{n=1}^6 \frac{6-n}{6} = 0.41(6) $$

Thus:

$$ \Pr(D|(a,d)) = 1 - \Pr(T|(a,d)) - \Pr(V|(a,d)) = 0.58(3) $$

### (2,1) #

As before, there is no possibility of a tie, and we account for the $ \left(1-\frac{6-n}{6}\right)\frac{6-n}{6} $ probability that one die loses but the second one wins.

$$ \Pr(V|(a,d)) = \frac{1}{6}\sum_{n=1}^6 \left( \frac{6-n}{6} + \frac{n}{6} \cdot \frac{6-n}{6} \right) = \frac{1}{6}\sum_{n=1}^{6} \frac{6^2-n^2}{6^2} = 0.578(703) $$

Thus:

$$ \Pr(D|(a,d)) = 1 - \Pr(T|(a,d)) - \Pr(V|(a,d)) = 0.421(296) $$

### (3,1) #

Similarly we solve for $(a,d)=(3,1)$, where a tie is again impossible and there is an added probability that two dice lose but the third one wins.

$$ \Pr(V|(a,d)) = \frac{1}{6}\sum_{n=1}^6 \left( \frac{6^2-n^2}{6^2} + \left(\frac{n}{6}\right)^2 \cdot \frac{6-n}{6} \right) = \frac{1}{6}\sum_{n=1}^{6} \frac{6^3-n^3}{6^3} = 0.6597(2) $$

Thus:

$$ \Pr(D|(a,d)) = 1 - \Pr(T|(a,d)) - \Pr(V|(a,d)) = 0.3402(7) $$

### (2,1) #

Here we take one die result of the defender (of value $n$) as the minimum requirement for attacker victory and adjust the probability for the cases where the second defender die (value $m$) scores higher. Again, there can be no tie.

$$ \Pr(V|(a,d)) = \frac{1}{6^2}\sum_{n=1}^6 \left( (n-1)\frac{6-n}{6} + \sum_{m=n}^6 \frac{6-m}{6} \right) = 0.25462(962) $$

Thus:

$$ \Pr(D|(a,d)) = 1 - \Pr(T|(a,d)) - \Pr(V|(a,d)) = 0.7453(703) $$

### (2,2); (2,3) #

For more complex cases determining the odds becomes a far more non-uniform probability problem. While we are still looking out for a formulaic solution, we currently solve these cases via a (significantly slower) exhaustive lookup of all possible combinations.

## Script #

Based on the above we have written a Python script (named **Risky**) that can be used to calculate the victory, tie, and defeat odds given $a$ attackers, $d$ defenders, and $s$ sides of the dice.
For a more exhaustive documentation of how to *use* the script from the command line please consult its README document.
The calculations are done preferentially based on the general formulae for the aforementioned cases:

### General Formulae #

For $ a \in \mathbb{N}$ and $d=1$:

$$ \Pr(V|(a,d)) = \sum_{n=1}^{s} \frac{s^a-n^a}{s^{(a+d)}} $$

For $a=1$ and $d=2$:

$$ \Pr(V|(a,d)) = \frac{1}{s^d}\sum_{n=1}^s \left( (n-1)\frac{s-n}{s} + \sum_{m=n}^s \frac{s-m}{s} \right) $$

### Exhaustive Lookup #

In case no formula is defined for the specified number of attackers and defenders, the script defaults to a subroutine which populates an array with all the possible dice outcome combinations and looks up all combinations meeting the respective (victory, defeat, and tie) criteria. One should note that this method can also be used as a validation tool for formulaic calculations, but is significantly slower.

## Odds Table #

For ease of overview we have compiled a table with all the odds (victory, tie, defeat) of a single attack in the common Risk set-up (6-sided dice and a cap of 3 attackers and 2 defenders).

a | 1 | 2 | 3 | |||
---|---|---|---|---|---|---|

d | 1 | 2 | 1 | 2 | 1 | 2 |

V | 41.67% | 25.46% | 57.87% | 22.76% | 65.97% | 37.17% |

T | 0% | 0% | 0% | 44.83% | 0% | 29.26% |

D | 58.33% | 74.54% | 42.13% | 32.41% | 34.03% | 33.58% |

A | 1.40 | 2.93 | 0.73 | 1.14 | 0.52 | 0.95 |

**V** stands for victory odds, **T** for tie odds, **D** for defeat odds, **a** for attacking units, and **d** for defending units.
**A** stands for attrition and represents the number of units you can expect to lose for one unit lost by the defender - this value is given by $\frac{D+T}{V+T}$.
We use **A** as an indicator of attack configuration desirability from the point of view of the attacker (though attack desirability is also contingent on strategical context, which is not accounted for here).
Undesirable attack configurations are highlighted in pink.