“The Risk” is a strategic board game where players fight with each other to conquare the world. In the simpliest version of the game, players place armies on different countries and attack each other using dices.

In a given round, only two players play at once (Player 1 Attack, Player 2 Defense). Attacker can throws maximum three dices, while Defender maximum two (for simplicity let’s assume that both Players play always with maximum number of dices). Later, dices are being compared. If, the two biggest Attacker’s dices are bigger than Player’s who defense itself, Attacker wins and beat two soldiers. When Player 2 has higher dices, it wins and beat two opponents’ soldiers. In situation when one dice of Player 1 is bigger and another is smaller than Player’s 2, each player lose 1 soldier. Moreover, ties are always won by the defensive player.

In the example below Player 1 (Attacker, red) wins and beats two soldiers, becasue the two biggest dices (4,3) are bigger than two dices of Player 2 (Defense, white) (3,2).

If still don’t get it, check this out.


Now let’s simulate a confrontation 100,000 times and count the results.

library(dplyr)
set.seed(1234)

# number of simulation
n <- 100000

# Initialize a data.frame for results
Results <- as.data.frame(matrix(nrow = n, ncol = 1))

for (i in 1:n){
  # Player1: Simulate Attack dices
  A <- sample(1:6, 1)
  B <- sample(1:6, 1)
  C <- sample(1:6, 1)
  attack <- as.vector(c(A,B,C)) %>% sort(., decreasing = TRUE)
  
  # Player2: Simulate Defense dices
  D <- sample(1:6, 1)
  E <- sample(1:6, 1)
  defense <- as.vector(c(D,E)) %>% sort(., decreasing = TRUE)
  
  #Compare
  # Player1 beats 2 soldiers of Player2
  ifelse(((attack[1] > defense[1]) & (attack[2] > defense[2])),
         Results[i,1] <- "Attacker beats 2 soldiers",
         
         # Player2 beats 2 soldiers of Player1
         ifelse(((attack[1] <= defense[1]) & (attack[2] <= defense[2])),
                Results[i,1] <- "Defender beats 2 soldiers",
                
                # Player1 & Player2 beats 1 soldeirs each
                ifelse(((attack[1] > defense[1]) & (attack[2] <= defense[2])) | 
                         ((attack[1] <= defense[1]) & (attack[2] > defense[2])),
                       Results[i,1] <- "Attacker & Defender beats 1 soldeirs each",
                       Results[i,1] <- "ERROR")))
}

# Print final results in [%]
final_results <- as.data.frame(prop.table(table(Results))*100) %>% 
  .[order(-.$Freq),]

Results:

final_results
##                                     Results   Freq
## 2                 Attacker beats 2 soldiers 37.003
## 1 Attacker & Defender beats 1 soldeirs each 33.531
## 3                 Defender beats 2 soldiers 29.466

In 37% of cases Attacker won a confrontation, while Defender won it in 29% of cases. Situation when both players lost 1 soldier occured in 33% of cases. That sounds like a saying: “The best defense is a good offense” works pretty well here!