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

#### Update:

Attached below is a new version of the spreadsheet, which now allows one to modify the individual roll probabilities such as to accommodate a rule variation described in a comment below: the highest die roll of either party is increased by one, if the party has a “general”. If the disputed territory is a “stronghold”, the highest rolling die of the defender also gets increased by one, which might add to the effect of a defending general.

As one might expect, these additional effects change the game fundamentally and most of the observations described above lose their validity once a general is in play. For instance:

- If the defender has a general or stronghold, then the attacker will — on average — always loose more armies than the defender, even if he attacks one army with three armies of his own.
- When the defender has a stronghold or general and is trying to defend a series of territories, it will make most sense to accumulate all or almost all his defending armies in the territory with the advantage, irrespective of the order by which the territories are to be attacked.

More detailed analyses are possible with the attached tool, but as this rule variation is not very common, I will leave these to the interested reader.

Attached below is the updated workbook. No warranty whatsoever is accepted, you are using this entirely at your own risk.

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.

I know this is an older post, but I’ve been working on solving these problems for the general case for classic Risk and using the results as a guide to solve other versions of Risk: specifically where generals and strongholds are used. A general in the attacking army adds +1 to the highest die roll of the attacker and a general in the defending army adds a +1 to the highest die roll of the defender. Also, any territory marked as a stronghold gives the defender a +1 to the highest die roll when that territory is being attacked. It is possible to have a general in a stronghold territory to give +2 to the highest die roll when defending that territory. All of the possible combinations can be combined into 4 different cases:

1. Neither player has an advantage (classic Risk or when both players have +1)

2. Attacker has +1 advantage

3. Defender has +1 advantage (when defender has +1 or when attacker has +1 and defender has +2)

4. Defender has +2 advantage

But what this does is create different sets of individual roll probabilities which affect wipe out calculations and battle chain calculations. I have not looked at optimal defense calculations for these yet, but those could potentially be affected Would there be any way I could request these options to be added into the workbook? If that’s too much to ask, could you please point me in the right direction of how to edit your workbook myself to include them? Any help would be greatly appreciated.

Hello Wags,

Interesting question. I will have a look at it one day, but I cannot promise anything. I believe, however, that the workbook will be quite easily adjusted as the VBA code takes the individual roll probabilities as input for everything.

I have just updated the post and included a new version of the workbook that should allow you to do the analyses you describe.

Note that the path optimisation code leaves possible generals/strongholds in their place without varying their position. I have made this joice a) because it saved me some work and b) I don’t know whether a player has at all the right to move generals and/or strongholds freely, as I didn’t find any rules about generals/strongholds in the internet. Needless to say, I would be grateful for a link.

Thank you very much for your time and effort. The specific version of Risk that uses both generals and strongholds that I have is “Risk: The Lord of the Rings Trilogy Edition”. Here is the address to a scanned copy of the official rules:

http://www.hasbro.com/common/instruct/Risk_The_Lord_of_the_Rings.pdf

(I’m sorry, I don’t know how to make a link)

But to answer your question, the general must move with the attacking army if the +1 bonus is used. If the +1 bonus is not used, then the general does not have to move with the attacking army. Also, you can move the general to adjacent territories when you are finished attacking just as you can armies to fortify weaker positions. Since you can withdraw the general from the front line if you wish, it’s generally better to use the general for every possible battle.

A stronghold cannot move: it is a defensive bonus only.

Thank you very much again, I greatly appreciate your time and effort.

Sorry for the double post, but I also wanted to mention that I would be happy to make a donation to compensate you for your time. Just let me know where you would like to have the money sent.

Oh, that is very kind of you. I am grateful for the appreciation.

However, this site is my hobby and entirely non-commercial (I have even taken the google-ads out), and I would like to redirect you to some charities that in my view have a worthy cause: I would be delighted if you could donate to one of them (or any other worthy cause you like) on my behalf.

Chelsea Manning support network

UN refugee agency

Médecins sans frontières