BoLS logo Tabletop, RPGs & Pop Culture

D&D: Dungeons and Datamining – Combat By The Numbers

7 Minute Read
Sep 3 2018

What is best in D&D? In this beautifully thorough analysis of combat in D&D, one GitHub user uncovers exactly that. So come find out, according to the data, what matters most in any encounter in Dungeons and Dragons.

Data science provides insights into everything from who’s going to win the next election, to what brand of discount clothing you’re going to buy from an ad–perhaps even on this website–but you can use data science for good too, and over on GitHub, someone has analyzed combat in D&D with a fine-toothed data-comb. Over on GitHub, user cyberscribe (Robert Peake) has fed all manner of combat data through a simulation to find out what really matters in Dungeons and Dragons. And all of the preceding reminds me that we do in fact live in the future.

Sure it’s turned out to be the slightly dystopic cyberpunk future (which I guess makes sense, it’s almost 2020) but it is the future nevertheless. We’ve got cyberscribes doing some datamining about what makes a game tic. And not to get too click bait-y here, but I was actually shocked by the results. This turns the game on its head a little–and so as we dive in, bear in mind that making the most mathematically effective choice isn’t always the most fun (for some people) but it gives some really cool insights into how combat works, and how to fight good in D&D.

via GitHub

Let’s just go through this paper together–it’s pretty cool. There’s a lot of information to glean from it, we’ve broken down the gist of it at the end, but this is some real insightful stuff, and an engaging read too. Without further ado, let’s dive into these data science investigations into the world’s greatest roleplaying game.

The aim of this research is to use computational analysis to provide useful insights to game masters seeking to exploit a deeper understanding of the components of combat effectiveness in service to creating combat encounters that are informed, intentional, and appropriate to the circumstances of their game.

Cyberscribe talks a lot about combat complexity and challenge and why it’s important to understand exactly what makes combat tick when planning their encounters. It’s pretty insightful

[I]t is important for a game master to be able to create challenges for the players so that their accomplishments and progress feel earned. Quantified character levels and creature challenge ratings are used to pit a group of characters against a group of creatures to ensure an appropriate challenge during combat.


A combat encounter that is too easy can be boring; one that is far too difficult can result in the death of one or more players’ characters. While such encounters can be deployed strategically in service to the narrative, when they occur unintentionally, they can be frustrating to both the players and the game master. It is therefore important for a game master to have a realistic understanding of combat effectiveness in order to create encounters that are appropriately challenging and intentional.

However, even within the scope of combat–one subset of the role-playing experience–an encounter can include variables such as: unique terrain features, the starting distance of the encounter, complex spells, powerful magic items, and the relative experience of the game master and players in these types of combat situations. It is therefore impossible to fully simulate all of the factors involved either mathematically or computationally.

Basically, the more you understand how combat works, the better you’ll be able to construct encounters that feel satisfying on both sides of the table. Because you want encounters that occasionally make players feel threatened, and you want encounters that feel like the victory is earned. And moreover, that it’s something that can be earned in the first place.

In order to try and understand what makes combat challenging, and how to cook up the difficulty level of an encounter, first combat had to be broken up into a number of relevant variables. In this research they are:

  • ac (armour class) – measures defensive capability; in order for an attack to succeed d20 + hit_mod must equal or excede this value in a turn

  • hp (hit points) – measures ability to withstand successful attacks without dying; for each successful attack during a turn the target loses dam_avg hit points; when hp is less than or equal to zero the target is dead

  • init (initiative) – measures combat agility; d20 + init is rolled at the start of a round; the entity with the highest total number goes first

  • att_num (number of attacks) – measures speed of attack; the number of attacks that can be made by this entity in a single turn

  • hit_mod (to hit modifier) – measures ability to make successful attacks against ac on an attacker’s turn [a.k.a. attack bonus or attack modifier]

  • dam_avg (average damage) – measures ability to inflict harm; decrements hp by this amount during a turn when an attack succeeds

With all of these variables in play, Peake sets about simulating a whole bunch of combat as scientifically as possible.

Details of the computational analysis are provided in the form of a Jupyter notebook, which can be executed to reproduce the results of all experiments described.

All of this goes into figuring out what changes your likelihood of winning an encounter. The results are surprising. Some things make sense, like Initiative doesn’t really matter–but then other things are a little mind blowing. Things like: Hit Modifier and Armor Class don’t really matter either.

More surprisingly, ac (armour class) and hit_mod (hit modifier) also had almost no correlation to combat success (r ~ 0.08 in both cases). Given the extent to which armour is seen as a measure of defensive effectiveness and the hit modifier is seen as a measure of offensive effectiveness, this may seem counter-intuitive to long-time players.


Now that reality is broken and everything you thought you knew turning out to be a lie, what actually does matter? Turns out it’s all about damage and your ability to endure it. The only kind of damage mitigation that matters (in an appreciable way) is your ability to deal out a creature’s HP total before it deals yours. Whether this is by increasing the amount of hit points you have, or the amount of damage you do is up to you. Both are about equally important.

However, att num (number of attacks) showed a stronger correlation to combat success (r ~ 0.42) as did dam_avg (r ~ 0.48). The product of these two, which we call dam_max (maximum average damage output per turn) showed a slightly higher correlation (r ~ 0.58) as did hp (hit points) (r ~ 0.57).

Combining dam_max and hp into a new metric by taking the square root of their product gives us hp_dam (hit-point-damage metric) with a very strong (r ~ 0.93) correlation to combat effectiveness.

There’s even a chart. But basically the more damage you can deal and the more you can endure, the better you’re able to control the fight in your favor. Even vs. high level monsters, you’d be surprised at how much this matters. This means that Fighters and Barbarians can be surprisingly effective, even late game.

There’s an experiment done with a party of 4 Wizards vs. 4 Fighters–though I’m not sure how effectively that’s measuring the effects a Wizard’s spells can have on combat; some of the most devastating spells deal no damage, but can solve a fight immediately. Forcecage, for instance, will shut down many an encounter without even breaking a sweat.

At any rate, there are some amazing take aways from all of this:

The most surprising result is the relatively lower importance of ac and hit_mod in predicting combat success. This should be taken in context of a large-scale analysis–in single encounters, a creature that “rarely hits” or “rarely misses” will indeed be highly ineffective or effective (respectively). After all, the game experience is enjoyed in the moment–and the death of a player, while just a tally mark in our analysis, is a significant in-game event. In this way, a conservative challenge rating system may be to everyone’s benefit.

While low-level parties are vulnerable, there is a perception among game masters that high-level parties can be difficult to challenge in combat. One theory to explain this is that the linear progression of hit points is out of alignment with the original game designer’s vision. Our analysis of the importance of hit points would tend to support the idea that a “damped” progression at higher levels would provide one solution.


However, other options–such as “piling on monsters”, as well as a range of “buffs” exist to provide challenge rating parity. One can also adjust the pairings based on the conservative nature of the system (pitting four cr 20 fighters against a single cr 30 monster, for example).

So there you have it folks. Dungeons and Datamining.

Just further proof that Adventuring is Algebraic!

  • D&D: A Rested Development