Risk Board Game Battle Automation

The ultimate Risk board game program to help streamline long battles, record dice rolls, analyze trends and view regression statistics

Andrew Hershy
Jun 7 · 3 min read
Photo by Matthew Guay on Unsplash

There are many Risk fans, like myself, out there. We have fond memories of conspiring with friends, building alliances, crushing enemies, and, of course, rolling the dice.

We also have memories, particularly towards the second half of the game, where we have to tediously roll for 15 minutes as the game-changing Brazil/North Africa battle unfolds. Game pieces get knocked over, dice fall on the floor, some people may try and cheat their rolls… At the end of the battle, everyone is jaded and bewildered. Someone usually is skeptical that the fight was even fair with Johnny rolling three sixes in a row.

When I was in this situation, I always wished there was a way to guarantee the battles were 100% fair and simple. I wanted data as to how the battle went to use as a reference for the next one. That’s what inspired me to make this tool.

Features:

After inputting the starting attack and defend armies, this tool:

  • Outputs a data-frame with the dice groupings and respective army totals, per roll, that can be exported to Excel
  • Plots visually what the losses look like for attacker and defender
  • Plots the normalized trend of losses
  • Plots the percentage changed for each army per roll
  • Outputs the regression line for the army losses, so you can obtain an average slope (armies lost per turn) for the attacker and defender.

Program and data-frame output:

Input the starting armies on lines 10 and 11. From there, the program has a while-statement, which runs the armies through an if-statement filter. It gradually runs them down to either 0 for defenders or 1 for the attackers.

During the if-statements, I appended each dice roll and army totals, per roll, to the list variables in lines 13–16.

Below is the output of total_log on line 174:

The defenders had a few lucky rolls at the end, but this victory goes to the attackers…


Plots:

Total army losses:

Normalized army losses:

This graph is useful when the attacking and defending armies don’t start at the same values.

Percent change per roll:

Regressions:

The attackers lost an average of 0.896 troops per roll. The defenders lost an average of 1.053 troops per roll.


Better Programming

Advice for programmers.

Andrew Hershy

Written by

University of Alabama at Birmingham. BS. MBA with concentration in data analytics. https://www.linkedin.com/in/andrew-hershy-a7779199/

Better Programming

Advice for programmers.