Skip to content
Timothy Boose edited this page Feb 21, 2024 · 4 revisions

RiskOddsCalc wiki

Welcome to the riskoddscalc wiki! It's not great, sorry.

This is a quick overview of what everything here does. If you'd just like to use the final product, visit it here.

It's pretty simple to use, just enter the number of attackers and the number of defenders. Do note that you need to use the number of attackers who can actually attack, not the total number in the attacking space. Don't count the one that you leave behind, only count the number who can actually fight in the battle.

As for the code behind this, it's pretty terrible, but it works. There's a massive JSON file containing the probabilities of the attacker winning any battle from a 1v1 to a 1000v1000. I created this JSON file by modifying a (kinda terrible) python script I made a year ago to output a massive lookup table. The script is included here; if you want a bigger table go ahead and make it, the script is pretty fast. I didn't bother properly coding something in JS since I'm lazy and this worked.

Pardon the no-frills approach here, I just wanted some sort of online odds calculator that gave exact results. Everything else that I could find used some form of Monte Carlo simulation, which wouldn't do. This little app should give you the exact probabilities. Now, for what each file does:


index.html : The webpage, thrown together in HTML and a bit of JS.

battleodds.json : A massive lookup table containing the odds of winning every battle from 1v1 to 1000v1000

riskarraymaker.py : A python script that creates the lookup table.

Risk Battle Calculator source.f90 : A new Fortran script that calculates both the probability of winning a battle as well as the expected value, using a new algorithm I recently created. You'll need to compile it yourself, I haven't implemented this feature in the webpage yet.

montecarlocheck.py : A Monte Carlo simulation of a Risk Battle, created to ensure that I haven't made errors elsewhere.

Clone this wiki locally