# Calculating the Odds of Victory in Risk

I am trying to write an odds calculator for risk that calculates the percentage chance of winning a combat between a number of given Attackers and given Defenders.

The calculator will use basic risk rules, that is, the attacker roles dice equal to the number of attackers but no more than 3. The defender does the same but is limited to 2 dice. The resulting roles are sorted and then combat is determined by comparing the two top dice and removing them from the stack. The side with the lower die roll loses one troop. This process continues until one side wins.

What I want to know is if their is an equation that can be used to solve this without creating the normal statistics tree. Creating that tree, while it works, becomes unmanageable after either side goes above 10 or more troops.

My current solution is to simulate 100,000 combats and then take the number of times the Attacker wins/100,000 to get the percent chance of winning the combat. This solution also works, however, since it is based on random chance itself the results can be off by significant amounts. It also requires simulating a lot of combat.

Is there some function I could use to calculate this result without having to use one of the previously mentioned solutions?

-
have you made a graph of the basic risk map yet? If you are willing to share, I'd love to see it. – tacos_tacos_tacos Nov 29 '12 at 3:12
nevermind, someone else on the web has: en.wikipedia.org/wiki/File:Risk_Game_Graph.svg – tacos_tacos_tacos Nov 29 '12 at 3:14
– Mike Spivey Nov 29 '12 at 3:44

Let $F(m,n)$ be the probability of the attacker winning when the attacker starts with $m$ armies and the defender starts with $n$. Then for $m \ge 3$ and $n \ge 2$, $F(m,n) = a F(m-2,n) + b F(m-1,n-1) + c F(m,n-2)$ where $a$, $b$ and $c$ are the probabilities of the attacker losing 2, both losing 1, and defender losing 2 on a roll (you can compute these easily). For $m < 3$ or $n < 2$, the equation changes somewhat because only one army is lost on a roll. The boundary conditions are $F(m,0) = 1$ for $m \ge 2$, $F(1,n) = 0$ for $n \ge 1$. It's then straightforward to determine $F(m,n)$ in a double loop.