Problem 1260. RISK board game battle simulation

Given two positive integer inputs, a (attacker army units) and d (defender army units) return the probablity of victory (from 0.000 to 1.000) to +- 0.02 accuracy. The rules are given below for those unfamiliar with the game.

In the board game RISK battles are determined by the conflict of armies, namely the attacking army and the defending army. The results is determined as follows: the attacker rolls 3 six-sided die and the defender rolls 2 die. The highest two numbers of each player are compared respectively, and the higher number wins (this means the opposing army loses one unit). In the case of a tie the defender wins. For example:

Attacker has 10 units Defender has 10 units

Attacker rolls [6 3 2] Defender rolls [4 3]

The first comparison is attacker - 6, defender - 4. Since the attacker is higher, the defender loses one unit. Hence Attacker has 10 units, Defender now has 9 units.

The first comparison is attacker - 3, defender - 3. Since the defender is higher, the attacker loses one unit. Hence Attacker has 9 units, Defender now has 9 units.

This is continued until either the attacker has only one unit left, in which case the defender wins the battle; or the defender has no units left, in which case the attacker wins the battle.

This is one further rule: the number of die any player may roll cannot be more than the their units in case of the defender, or their units + 1 in case of the attacker.

Example: Attacker has 3 units, Defender has 1 units.

Attacker rolls 2 die (3 - 1), Defender rolls 1 die.

Solution Stats

36.0% Correct | 64.0% Incorrect
Last Solution submitted on Aug 31, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers33

Suggested Problems

More from this Author7

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!