Apr 092011

Let’s start this blog with a post on a fun topic: the board-game RISK: have a look at wikipedia if you would like to know more about the game, rules etc. — it is a classic.

The attached workbook contains VBA code that calculates probabilities for battle outcomes of the risk board game.

Included are the following routines:

  • calc_basic_probabilities: this routines calculates the odds for battle outcomes after one roll of dice: these probabilities of course depend on how many attacking and defending armies are involved. They are fundamental for all other calculations.
  • probab4: this routine calculates the probability for the transition of one battle situation (say 10 attacking and 8 defending armies) to another battle situation (say 5 attacking and 0 defending armies). The code is optimised for speed and hence can also handle battle situation with large numbers of armies.
  • probab_ad4: this routine calculates the probability that, given a certain battle situation, the defending armies are wiped out and the territory is conquered by the attacking armies. Again, the code is optimised for speed and hence can handle large numbers of armies (1000 is not a problem on a normal PC)
  • el_a: this routine calculates the expected loss of units for the attacker if the fight is continued until wipeout of either attacker or defender. el_d is the equivalent for the defender.
  • probab_path: this function calculates the probability with which an attacker conquers several territories occupied with defending armies. It also calculates the expected attacking armies in the last territory.
  • probab_path_full: same as probab_path, but also outputs probability of wipe-out and expected attacking armies for each territory on the way.
  • probab_optimal: This function optimizes function probab_path with respect to the distribution of defending armies.

The analysis possible with these VBA routines allows to answer many tactical questions a RISK player may have, for instance

  • Whenever the attacker has more armies than the defender, his expected losses are lower than the expected losses of the defender — therefore it seems advisable to be quite aggressive when attacking, unless other strategic considerations come into play.
  • If there are no other strategic considerations, then it makes sense for the defender to leave countries that an attacker will most likely conquer with two defending armies each. While a large attacking force will still lose less armies on average than the defender with two armies in the attacked countries, the increase in expected losses for the attacking force is slightly bigger than 1 for each added “second” defense army.
  • In order to optimally defend two territories (which is very common when protecting a continent) it is best to put two defending armies into the territory facing the attacker and all other available defending armies into the other territory — at least the defense is most solid that way, other more strategic considerations might ask for a different distribution.
  • A reasonable rule of thumb to determine how many attacking armies are required to conquer a series of territories is the following:  Armies required= 1+ #territories + 1/2* #defending armies standing alone + 3/4* #defending armies not standing alone. This formula gives the attacker approximately a 50% chance to successfully complete the conquest. In order to get more than a 90% chance, one should add twice the square root of the number of all defending armies.

While I found these insights interesting — it is good to have some definite answers — I wrote the VBA code presented here more as a kind of algorithmic puzzle: it is fairly straightforward to write slow code, but try then to optimise it: every time you are proud of your latest improvement, the next efficiency gain by a factor 2 is already waiting. So here is the challenge: whoever shows me a significantly more efficient algorithm in VBA for the function probab_ad4 will receive a honorable mention in a follow-up post and a link to where ever you want me to link to (embarrassing is fine, illegal, X-rated or virus infected not).

Attached below is a workbook with all the described macros. No warranty whatsoever is accepted, you are using this entirely at your own risk.

Risk_game_probabilities_v1.xls

3 Responses to “Battle outcome probabilities for the Risk board game”

Comments (3)
  1. We play the game with one additional twist, which is helping the defender (and I think fairly common). That is that the defender only needs to decide whether he will defend with one or two dice AFTER he sees the attacker’s dice. Then in 8 out the 36 cases is it more attractive for the defender to throw just the one dice. (when the highest two dice of the attacker are 4 and 5 or higher).
    I guess that will quite complicate your analysis.

    • Interesting!

      Yes, I think, that would complicate the analysis quite considerably.

      I could imagine that the ideal choice whether to roll the second defence die does in fact not only depend on the dice of the attacker, but also potentially on the number of attacking and defending armies left, in which case an entirely new dimension is introduced to the analysis.

    • Your comment has inspired me, to look at this more closely. The calculations do in fact get more complicated. Have a look at this post.

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2014 Spreadsheet Advice Suffusion theme by Sayontan Sinha