Monte Carlo vs. DPR
Let's start by looking at the difference between a stochastic analysis and a DPR analysis. For this one, we'll start very simply. The question we're analyzing: How many rounds does it take for a PC to kill a monster?
The PC: a level 1 dwarf great-weapon fighter, using Character Builder's recommended stats, wielding a maul. No feats or powers yet--just basic attacks.
PC Attack bonus: 7 (4 stat + 2 maul + 1 greatweapon)
PC Dmg dice: 2d6 (maul) + 4 (stat)
[sblock=Character Builder summary]
====== Created Using Wizards of the Coast D&D Character Builder ======
Dwarf-Fighter, level 1
Dwarf, Fighter
FINAL ABILITY SCORES
Str 18, Con 12, Dex 14, Int 10, Wis 13, Cha 8.
STARTING ABILITY SCORES
Str 18, Con 10, Dex 14, Int 10, Wis 11, Cha 8.
AC: 17 Fort: 16 Reflex: 12 Will: 11
HP: 27 Surges: 10 Surge Value: 6
TRAINED SKILLS
UNTRAINED SKILLS
Acrobatics +2, Arcana, Bluff -1, Diplomacy -1, Dungeoneering +3, Endurance +3, Heal +1, History, Insight +1, Intimidate -1, Nature +1, Perception +1, Religion, Stealth +2, Streetwise -1, Thievery +2, Athletics +4
FEATS
POWERS
ITEMS
Scale Armor, Adventurer's Kit, Maul
====== Copy to Clipboard and Press the Import Button on the Summary Tab ======
[/sblock]
The Monster: a generic level 1 soldier, created using p184 of the DMG.
Monster AC: 17 (1 level + 16 soldier)
Monster HP: 29 (8 soldier + 13 con + (1 level * 8 soldier)
A DPR analysis of this fight says the monster lasts
4.6 rounds on average.
[sblock=DPR breakdown]
Avergae damage for maul: 2d6+4 = ((2 + 12) / 2) + 4 = 11
Crit damage for maul: 2d6+4 = 12 + 4 = 16
Roll to hit = 17 AC - 7 att bonus = 10
Chance to roll miss = (roll to hit - 1) / 20 = 45%
Chance to roll crit hit = 1 / 20 = 5%
Chance to roll normal hit = 1 - miss chance - crit chance = 1 - 45% - 5% = 50%
Average crit damage = crit chance * crit dmg = 5% * 16 = 0.8
Average hit damage = normal hit chance * normal dmg = 50% * 11 = 5.5
DPR = 0.8 + 4.95 = 5.75
Avg rounds = 29 HP / 5.75 DPR = 4.6 rounds
[/sblock]
The stochastic analysis shows us something
completely different. It says the average fight lasts
5.5 rounds, not 4.6. That's a significant difference... big enough that, if correct, pretty much invalidates DPR as a trustworthy approach.
[sblock=Source code (in Ruby)]
Code:
REPS = 1000000
PRECISION = 1
DISPLAY_WIDTH = 75
MONSTER_LEVEL = 1
MONSTER_CON = 13
PC_ATT_BONUS = 7
PC_DMG_BONUS = 4
class Monster
def initialize
@ac = MONSTER_LEVEL + 16
@hp = 8 + MONSTER_CON + (MONSTER_LEVEL * 8)
end
def dead?
return @hp <= 0
end
def defend(att, dmg)
@hp -= dmg if att >= @ac
end
end
class Pc
def attack(monster)
att_roll = die(20)
att = (att_roll + PC_ATT_BONUS)
dmg = damage(att_roll)
monster.defend(att, dmg)
end
def damage(att_roll)
dmg_dice = die(6) + die(6)
dmg_dice = 12 if att_roll == 20
return dmg_dice + PC_DMG_BONUS
end
end
def die(size)
return 1 + rand(size)
end
def fight
monster = Monster.new
pc = Pc.new
round = 0
until monster.dead?
round += 1
pc.attack(monster)
end
return round
end
def analyze
results = {}
total_rounds = 0
max_value = 0
REPS.times do
rounds = fight
results[rounds] = 0 unless results[rounds]
new_value = results[rounds] += 1
max_value = new_value if new_value > max_value
total_rounds += rounds
end
results.keys.sort.each do |key|
value = ""
ticks = (results[key].to_f / max_value.to_f * DISPLAY_WIDTH).to_i
ticks.times do
value += "="
end
puts "#{key.to_s.rjust(2)}: #{value}" if value != ""
end
avg_rounds = total_rounds.to_f / REPS
format = "%.#{PRECISION}f"
puts "Fights simulated: #{REPS}"
puts "Average # of rounds per fight: #{format % avg_rounds}"
end
analyze
[/sblock]
Why the difference? I'm not entirely sure. (Hopefully it's not a bug! That's why I included the source code.) I think it's partly because, in a real fight, some damage is "wasted" after the monster hits zero HP.
The Monte Carlo analysis also gives us a histogram that summarizes all of the fights. For this simulation, I ran a million fights. 'Cause I could.
Code:
LEVEL 1 SOLDIER VS. DWARF GREATWEAPON FIGHTER (no feats, no powers)
2 (2.3%): =======
3 (18.0%): ==================================================
4 (38.7%): ===================================================================
5 (57.8%): =============================================================
6 (72.6%): ===============================================
7 (83.0%): =================================
8 (89.8%): =====================
9 (94.0%): =============
10 (96.6%): ========
11 (98.1%): ====
12 (99.0%): ==
13 (99.4%): =
Fights simulated: 1000000
Average # of rounds per fight: 5.5
So, although the average # of rounds is 5.5, the majority of fights take 4 rounds. Over 80% of fights take 7 rounds or less to complete, although a very small fraction of this simulation's fights dragged on and on, presumably due to lots of bad rolls.
You can see how the Monte Carlo simulation gives us a much richer, more accurate analysis than the DPR approach. And we're just barely getting started. Next up: feats, powers, and monsters that actually fight back!