I was bored in class today and finally got around to simulating Risk dice rolling. Just a quick and dirty Java code, but in short Dennis was right: rolling three dice against two 100000 times, the attacker lost 92351 troops; but the defender lost 107649. Code below.

import java.lang.Math;
import java.util.Arrays;
public class Test {

public static void main (String [] args){
	int attLoss = 0;
	int defLoss = 0;
	for (int i = 0; i < 100000; i++){
		int a1 = (int)(Math.random()*6)+1;
		int a2 = (int)(Math.random()*6)+1;
		int a3 = (int)(Math.random()*6)+1;
		int d1 = (int)(Math.random()*6)+1;
		int d2 = (int)(Math.random()*6)+1;
		int [] a = {a1, a2, a3};
		int [] d = {d1, d2};
		if (a[2] > d[1]) defLoss++;
		else attLoss++;
		if (a[1] > d[0]) defLoss++;
		else attLoss++;
	System.out.println("Attacker:" + attLoss + " and defender:"+defLoss);


But what if Luce is rolling?

In that case it was attacker: 127651 and defender:72349

I think you have it the opposite.

Luce is a master defender.

Who wants to start a 5-person, 100,000 troop game?



For your reading pleasure (should open if you’re inside McGill network)

I didn’t check this myself, but does (int)(Math.random()*6)+1 reliably give you a flat distribution from 1 to six (i.e. does it represent a fair die)? You could make a quick histogram to verify.

Haha I wish I could like these posts

Yep, it is reliably flat, here are 4 tests of a single die rolled 300000 times:
49766, 50055, 50010, 50251, 50098, 49820
49845, 49758, 50159, 50036, 50037, 50165
49790, 49746, 49991, 50185, 50255, 50033
50508, 50111, 49916, 50111, 49699, 49655

Totally thought this topic was on stupidity while cycling lol

This is fantastic! Thank you for that article.

Also I just spent 2 hours having fun with this
Here’s some Matlab code that will generate the probability of the attacker of defender winning after X amount of trials:

its = 1000; % iterations
attWin = 0;
defWin = 0;

attackSoldiers = 120;
defenceSoldiers = 100;

str = sprintf('Attacker attacks with %d soldiers and defender defends with %d soldiers, %d times',attackSoldiers,defenceSoldiers,its);

for i = 1:its
a = [0,0,0];
d = [0,0];
att = attackSoldiers;
def = defenceSoldiers;
while att > 0 && def > 0
    for j = 1:3
        a(j) = randi(6);
    if att < 3
        a(1) = 0;
        if att < 2
            a(2) = 0 ;
    for j = 1:2
        d(j) = randi(6);
    if def < 2
        d(1) = 0 ;
    if a(3) > d(2) 
        def = def - 1;
        att = att - 1;
    if d(1) > 0 && a(2) > 0 % If there is only more than one defender or attacker left 
        if (a(2) > d(1)) 
            def = def - 1;
            att = att - 1;
%   str = sprintf('Attacker: %d and defender: %d',att,def);
%   disp(str);    

    if att > def
%        disp('Attacker wins'); 
        attWin = attWin + 1;
%       disp('Defender wins');  
        defWin = defWin + 1;
    attWinP = attWin / its * 100;
    defWinP = defWin / its * 100;
    str = sprintf('Attacker won %2g percent of the time and defender %2g percent',attWinP,defWinP);

Here’s an example:

Attacker attacks with 10 soldiers and defender defends with 8 soldiers, 10000 times
Attacker won 41.68 percent of the time and defender 58.32 percent

Now guys, you realize that this is a simple exercise in probability with exact results do you not? So this is more of a mathematica or maple problem then a matlab one.

And since there seem to be a bunch of people who are doing some programming on this, facebook likes, +1, shares, and so on aren’t that hard. If anyone’s interested in doing web work, I’m pretty busy these days, and if anyone else wants to pick up on some of those tasks, that would be great.

Yeah, I would be more impressed if someone could give me a written mathmatical proof of these probabilities rather than programs, but thanks for prooving me right everybody!

Challenge accepted.

Using my grad student powers of literature review, this is indeed a solved problem that can be analytically proven using combinatorics.

First off, the probability of an attacker or defender losing an army can be calculated for each combination of dice rolls, shown below [taken from http://www.plainsboro.com/~lemke/risk/]:

Attacker: one die; Defender: one die:

Attacker wins 15 out of 36 (41.67 %)
Defender wins 21 out of 36 (58.33 %)

Attacker: two dice; Defender: one die:

Attacker wins 125 out of 216 (57.87 %)
Defender wins 91 out of 216 (42.13 %)

Attacker: three dice; Defender: one die:

Attacker wins 855 out of 1296 (65.97 %)
Defender wins 441 out of 1296 (34.03 %)

Attacker: one die; Defender: two dice:

Attacker wins 55 out of 216 (25.46 %)
Defender wins 161 out of 216 (74.54 %)

Attacker: two dice; Defender: two dice:

Attacker wins both: 295 out of 1296 (22.76 %)
Defender wins both: 581 out of 1296 (44.83 %)
Both win one: 420 out of 1296 (32.41 %)

Attacker: three dice; Defender: two dice:

Attacker wins both: 2890 out of 7776 (37.17 %)
Defender wins both: 2275 out of 7776 (29.26 %)
Both win one: 2611 out of 7776 (33.58 %)

So the attacker has the advantage in the 2 vs 1, 3 vs 1, and 3 vs 2 scenarios.

To calculate the outcome of an entire battle is more complicated because the outcome of each battle will determine how many die (i.e. the probability function) for the ensuing battle. The paper John Turtle posted suggests one such way of calculating this using Markov chains. Another approach, suggested by Taflin, models the battle sequences as a discrete diffusion problem, with a “free-space” solution where the attacker’s armies are greater than 3 and the defender’s greater than 2 (always using 3 vs 2 dice), and “boundary” regions where the number of dice thrown is dependent on the number of attacking/defending armies. A Javascript implementation of his method is available online here:


All that to say, Risk is shit. Play a real wargame =P

Any suggestions, Jason ?

What level? Abstract (Chess, Go)? Nation level (Diplomacy)? Strategic/operational? Tactical?

The popularity of games like Risk and Monopoly genuinely boggle me. Monopoly was originally designed as a protest against tax monopolies and is actually meant to be un-fun. I think it basically just exists to create family feuds, ruin friendships and break up relationships.

Risk is like the wargaming version of Monopoly but without the socialist message. The card bonus army mechanism is fundamentally broken and the game serves no other purpose than to make friends fight. It’s not like its ever fun unless you turn it into a drinking game.

If you want a good high level game that is vaguely Risk-like but doesn’t suck, get Diplomacy. If you want a Gronard operational wargame the golden age (ie 1970ies) stuff from Avalon Hill or SPI is a good bet. If you want the longest ever wargame possible, get Longest Day: 8hr+ setup, game can last oh, months. I prefer Avalon Hill’s tactical stuff (Advanced Squad Leader and its expansions) though.

Risk and Monopoly are popular most likely due to their sheer simplicity. You can set up the game, play, and finish in an evening. And if relationships are being broken because of a board game, perhaps you’re being a bit too competitive :P.
In high school, my mates and I had a game of Axis and Allies going for a few months. We’d play every sunday afternoon until dinner. It was a good time, and I haven’t played the game since.

This thread is a remarkably large geekploision.