Risk Analysis for Risk

Motivation

In 2011 I was on vacation with friends, we played a lot of Risk. Somehow we ended up having fights of hundreds of armies against each other. Since with every dice rolling you can only eliminate up to three armies, you need a lot of rounds until a battle is settled. While my friends were occupied in a battle of 200 against 150, I used my freshly acquired Python skills to write a program to do the dice rolling, risk-auto-dice.

The program does exactly what the players do until one player runs out of armies:

  • The attacker rolls up to three dice, the defender up to two. The number of dice cannot exceed the number of armies. In the game a player can choose to use less dice, the program uses the maximum amount.
  • The results are ordered descending and paired up. For every pair which is unequal, the person with the lower number loses one unit.

At first, the program would only output the end result. The result turned out to be extremely unstable, a 100 vs 100 fight could end with either side having 50 armies left. If one re-ran the program, the result was completely different. At the time, we just accepted this as an intrinsic quirk of the game that gave it its name.

Revisiting the Problem

Now, six years later, I learned more about statistics. So I looked at this again. For this article, I have implemented the dice rolling function in R because I currently learn that language. The fight function is not very complicated:

sorted_roll <- function (number) {
    sort(sample(1:6, number, replace = TRUE), decreasing = TRUE)
}

fight <- function (attacking, defending) {
    armies_att <- attacking
    armies_def <- defending

    # Risk has “last man standing” fights, therefore
    while (armies_att > 0 && armies_def > 0) {
        # The number of dice that can be used is capped to 3 and 2.
        dice_att <- min(armies_att, 3)
        dice_def <- min(armies_def, 2, dice_att)
        dice_both <- min(dice_att, dice_def)

        # Roll the dice.
        roll_att <- sorted_roll(dice_att)
        roll_def <- sorted_roll(dice_def)

        #cat(armies_att, ' ', armies_def, '\n')
        #print(roll_att)
        #print(roll_def)
        #cat('\n')

        for (i in 1:dice_both) {
            # The attacker has won a single battle, therefore the defender loses a die.
            if (roll_att[i] > roll_def[i]) {
                armies_def <- armies_def - 1
            }
            # The defender has scored.
            else if (roll_att[i] < roll_def[i]) {
                armies_att <- armies_att - 1
            }
        }
    }

    return (data.frame(attacker = armies_att,
                       defender = armies_def,
                       diff = armies_att - armies_def))
}

Analysis

I have run it 300 times for each configuration of up to 25 armies. The whole implementation is not really fast, therefore this already took several minutes to run through. For a more sophisticated analysis one should probably re-implement this in C++ and use OpenMP to get some more speed. The amount of data generated seems to sufficiently see the trend, there is no indication that beyond 25 armies something qualitatively different will happen.

First one has to note that the combat system is extremely unpredictable. There is a lot of spread in the result. Take for instance 10 attackers and 10 defenders. The resulting number of armies will be the following, where negative values mean surviving defenders.

../../_images/unnamed-chunk-4-12.svg

Even though 10 vs. 10 starts with the same amount of armies on both sides, we can clearly see that the attacker on average has better chances of winning the battle. In most cases the attacker even gets to keep most of the armies. Keeping in mind that there are huge fluctuations in the fights we will take a look at averages.

Winning Chance

The following shows the ratio of fights that the attacker wins given various number of attacking and defending armies.

../../_images/unnamed-chunk-6-12.svg

As we have seen before, it is heavily skewed towards the attacker. The slope of the white line, where the chances to win are equal for both sides, has a much higher slope than the black line which marks the same number of attackers and defenders. We see that defense is hard in this game and requires some 50% more armies in order to just give equal odds for both sides.

One can have a look at the surviving armies of the attacker normalized by armies put into the battle, this is a survival rate:

../../_images/unnamed-chunk-7-12.svg

Interestingly, the 50% line has almost unit slope, so when both players have the same amounts of armies, the survival rate of the attacker’s armies is still 50%. Of course to win one only needs to have a single unit left, therefore the ratio of won battles has a larger slope.

Fluctuations

But there were those great fluctuations. If we look at the standard deviation of armies left, we see the following:

../../_images/unnamed-chunk-8-11.svg

On the bottom and on the left, there are no fluctuations. This is no surprise because these situations correspond to a near-certain victory or defeat. The fluctuations look rather symmetric. But that does not really tell much about the risk that one is taking in each battle.

So let’s have a look at the 1% quantile of the armies that are left after the battle. I have chosen 1% instead of 0% because that should be somewhat stable against outliers whereas 0% will by definition be the most extreme outlier.

../../_images/unnamed-chunk-9-11.svg

Most of the chart corresponds to a defeat, zero armies left. For low numbers it is skewed towards the defender, it you want to be almost completely certain to win, you will need to have at least four armies to attack a single one. For large number of armies, it seems to become more even again. One could draw the line such that the chance of losing is very low. One would need more statistics here in order to get a better resolution because 300 samples are not going to give a very good 1% quantile.

In a game called “Risk”, one cannot be that conservative. Therefore let’s have a look at the 30% quantile:

../../_images/unnamed-chunk-10-11.svg

For very low numbers, the defender has the advantage. This changes at around 5–5, where the attacker has the advantage again.

The median (50% quantile) looks pretty good for the attacker:

../../_images/unnamed-chunk-11-11.svg

If you want to hedge your bets on something that will work out worse in 70% of the cases, you can have a look at the following chart:

../../_images/unnamed-chunk-12-11.svg

The best cases that could happen (only 1% even better) look like this:

../../_images/unnamed-chunk-13-11.svg

With three armies, one has a slim chance of winning against a defender with 17 armies. In the best case scenario, the number of defending armies only has weak impact on the result. This can be seen through the pretty vertical slope of the color boundaries in the plots. That should be compared to the worst case, where the slopes are only down to unity.

Fixed number of defending armies

Let us fix the number of defending armies to 10 and just vary the number of attackers. In the following plot the line denotes the median, the dark ribbon covers 30% to 70% and the gray ribbon from 1% to 99% of the cases. The red line marks 10 attackers, the case of equal power on each side. The blue line marks 0 surviving armies, wins for the attacker are below that line and wins for the defender below.

../../_images/unnamed-chunk-14-1.svg

We can nicely see that the attacker has the advantage in the median case until we get down to 6 attacking armies. But even if we aim to win 70% of our fights, we can just take around 7 or 8 armies against 10. And if we take 15 armies, the chances of losing are just around 1%, which is extremely slim.

Next we take a look at this from the other side, fixing 10 attackers and varying the number of defenders. The colors are all the same.

../../_images/unnamed-chunk-15-1.svg

We see that most of the chart is a win to the attacker. Even 25 defending armies are not enough to ensure a defend rate of 99%, we can only get to around 70%. With the median we see that it takes around 18 armies to defend more than 50% of the attacks.

Conclusion

It seems that the attacker usually has a great advantage in terms of numbers. The chance to win is higher. This probably means that an aggressive strategy will serve the player best.