Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
40 lines (30 sloc) 1.61 KB


Python functions with a convenient command line interface ( to calculate the odds for single-attack battles in Risk-like games. The function lets you specify many variations including number of attacking units, defending units, and even dice sides. We use either formulaic odds calculation or explicit lookup from tables of all outcome possibilities (the latter being significantly slower for large dice side numbers).

A more in-depth explanation of the formulas, as well as reference odds tables for popular game configurations can be found in the script's tutorial page.


##Usage Run the script from the containing folder:

python [-h] [-f] [-d DICE_SIDES] attackers defenders

Example (7-sided dice, 4 attacking dice are rolled against 1 defending dice):

python -d 7 4 1


positional arguments:
  attackers             number of attacking units (integer 1 to 3)
  defenders             number of defending units (integer 1 to 2)

optional arguments:
  -h, --help            show this help message and exit
  -f, --force-lookup    force usage of the odds_lookup (non-formulaic, slow)
  -d DICE_SIDES, --dice-sides DICE_SIDES
                        specify the number of faces on the dice

Released under the GPLv3 license. Project led by Horea Christian (address all e-mail correspondence to: