Dungeon Calculus: A Mathematical Approach to Adventure Design

I’m currently 72 sessions into a D&D5e campaign I started in March of 2019. It is day 189 for the adventurers. The players are just beginning to reach level 10ish. I have a roadmap for the game out to level 20. Who knows how far we’ll make it or how long this will go on?

When I started this I said to myself, “I want to run the most straightforward D&D campaign I can think of.” I decided there would be a map, on the map there would be adventure sites (i.e. dungeons). I would feed the players “rumors” about problems in the world that emanated out from those sites. As the players traveled between the adventure sites they would encounter hazards on the roads and little micro-adventures in the towns and villages along the way.

At the start of the campaign I have the players one piece of world lore: there is a big war between a monotheisitic culture and all the little polythestic cultures that inhabit the area. I said that the PCs were not on either “side” and instead had been burned by this war and had banded together to survive and make the best of a battle scarred world.

I broke up the adventure site ideas I had by D&D5e’s tier system. When they were nearing the end of Tier 1, I started prepping and rolling out the rumors about the adventure sites in Tier 2. They are nearing the end of Tier 2, so I am in the process of prepping Tier 3.

As I sat down to prep the adventure sites I began to wonder how many of them there should be per Tier and how large each one should be. I found a wonderful little chart in Xanthar’s Guide to Everything that tells you just how many Treasure Hoards the players should find per Tier.

Next, I wanted to know about how many encounters should there be between Treasure Hoards. So, I wrote a computer program that would tell me how many encounters there should be for each level by comparing the XP chart in the Player’s Handbook with the XP value of a medium difficulty encounter for each level as described in the Dungeon Master’s Guide. This was the result (with a bit of rounding here and there).

I use the term “monster” very deliberately because D&D5e’s XP system is very weak on anything other than defeating monsters (more on this later).

If you compare these numbers to the expected Treasure Hoards per Tier an interesting breakdown reveals itself. If you break Level 3 into two sets of 6 encounters, and Level 4 into three sets of 5, you end up with the requisite 7 Treasure Hoards for Tier 1. If you break up Levels 5-9 into three sets of 5 and level 10 into three sets of 6, you get the requisite 18 Treasure Hoards for level 2. With a bit of rounding Tier 3 and 4 break down into two sets of 5ish encounters at each level to hit the requisite 12 and 8 Treasure Hoards for those tiers. Level 20 is not on the chart because there is no “next” level but presumably you want the PCs to have a chance to be level 20, so it’s easy to imagine it conforms to the rest of the Tier in terms of content.

This ultimately means there’s about 4-6 monster encounters between each Treasure Hoard. That’s actually kind of small, so I decided that these didn’t represent individual adventure sites but rather dungeon levels. So I began making groupings of various sizes. For example I decided that the very first adventure site would be fairly large. It would be four levels deep and take the players all the way through level 3. Then there would be three additional adventure sites of only one level each and that would finish off Tier 1. Tier 2 ended up having nine adventure sites of various depths and Tier 3 will have five. Tier 4 is slated to be one giant eight level megadungeon.

I now had a new question. Other than monsters, how large should the dungeon be? To find the answer I took a look at older versions of D&D. How old? All the way back to 1974. Book 3: The Underworld & Wilderness Adventures of the original set of booklettes contains the following on how to randomly populate the dungeon.

I was really surprised to discover that by these odds only about one-third of the dungeon will contain monsters and only about a quarter of it will contain treasure.

I then took a look at the Moldvay Basic edition of D&D and found the following:

What’s interesting about this process is that it actually preserves Gygax’s distribution. About one-third of the dungeon will have monsters, and about a quarter of the dungeon in total will have treasure. What Moldvay did was divide the remaining two-thirds into two parts. One third will be empty and the other third is explicitly into traps and special encounters.

With this information I wrote another computer program. This program doesn’t actually use the random rolls. Instead it takes in the number of monster encounters (one-third of the dungeon) and then extrapolates the rest of the dungeon contents from the Moldvay distribution.

For example, my first Tier 1 dungeon is four levels deep with a total of 24 monster encounters. With that input the program produces this:

–Dungeon Distribution–
Monster: 12
Monster w/Treasure: 12
Trap: 8
Trap w/ Treasure: 4
Empty: 20
Empty w/ Treasure: 4
Special: 12
Total: 72

The reason I run the program based on the total monsters in the dungeon rather than go level by level is that this functionally creates a “room budget” for the entire adventure site. If I want to make the dungeon feel more dangerous the deeper you go I can “spend” more of the empty room budget in the earlier levels and more of the traps and specials budget on the lower levels while preserving the distribution for the dungeon as a whole (i.e. one-third of the entire dungeon will still be empty even if most of those empty rooms are on the top two levels).

This left me with a new issue: varying encounter difficulty. For ideas about that I turned to the D&D3.5 Dungeon Master’s Guide and found this super handy chart:

D&D 3.5’s concepts of easy, challenging, very difficult and overpowering map very nicely to D&D 5e’s concepts of easy, medium, hard and deadly. So, I extended my program to apply that distribution to the number of monster encounters provided. For the previous 24 encounter dungeon this is the resulting distribution:

–Difficulty Distribution–
Easy: 7
Medium: 12
Hard: 4
Deadly: 1
Total: 24

I discovered, however, that this left me with one remaining problem. D&D 5e’s encounter chart drops the XP threshold for difficulty the more monsters you add. This is to account for the fact that more attacks per round make an encounter more difficult regardless of the danger of each individual attack. What this means is that the XP value of an encounter with multiple opponents is less than the expected value of the encounter based on difficulty alone.

For example, at first level 5 bandits is considered a medium difficulty encounter for four PCs. The total XP of 5 bandits is 125. The expected XP for a medium difficulty encounter for four PCs is 200. The multiple opponent encounter creates a 75 XP deficit. Easy encounters obviously have an even larger deficit with regard to the medium XP values that were used to calculate the number of encounters needed to level.

The question is, do the hard and deadly encounters make up the deficit? The answer is, they do not. Infact, assuming every encounter contains between 3 and 6 monsters there will be almost exactly a 50% XP deficit for the expected leveling pace of the dungeon.

I was faced with deciding how I could make up the deficit? One possibility was simply double the size of all my dungeons. The dungeons were already quite large (average 15-18 rooms per dungeon level) and I did not relish the thought of making them bigger. So I took a look at the Treasure Hoard tables.

It turns out that the average gold piece value of the Treasure Hoards for Tier 1 and Tier 2 nearly make up the deficit exactly. So, I simply reinstated XP for gold from older editions. It turns out for Tier 3 you have to cut the Treasure Hoard value in half or you will greatly outpace the leveling rate. It basically becomes 1 XP for every two gold pieces in value. I have not done the math for Tier 4 yet but I expect I might have to cut it in a quarter or more.

Anyway, this has been serving me very well for nearly two and half years now. I figured I’d share in case anyone else wanted to get super mathy about their D&D.

, ,

8 responses to “Dungeon Calculus: A Mathematical Approach to Adventure Design”

  1. Two layers of purchase

    As with almost any Dungeons & Dragons oriented post, my replies resemble personal testimony rather than critical thought. Here goes …

    I paid almost zero attention to D&D between December 1982 and early 2000. I bought a version in 1986 while working at a neighborhood center, to play with the kids, and it looked almost entirely foreign to me; I was given a copy of 3.0 at GenCon 2000 and it wasn’t just foreign, it was alien. In the latter case, at the top of the what the buttered fuck list, was the absence of experience points for the monetary value of things you discovered and liberated during the adventure.

    Now, in my mind, I had never liked the concept of treasure in my fantasy role-playing. My favorite fantasy inspirations were either not concerned with it or featured it as a problem, a way for people to get into trouble, rather than as a component of a main character’s success. However, I had also realized that the game as written simply could not function without a very substantial injection of new currency into the overall ecology of character development – “economic stimulus,” I suppose, as if the distribution of riches throughout an adventure were some sort of Federal Reserve + U.S. Treasury type policy.

    This happened in two ways. First, without the experience points, the treasure still fed back into the game’s overall currency because without it, no new torches, no new rations, no improvement in armor or specialized gear like silver weapons, all the way up to no resurrections. You need those things, ergo, loot you must. This is taken to its purest, most deadly-rationally constructed form in 5th edition Tunnels & Trolls, in which treasure does not give you experience points, but it is the only way to upgrade weapons and armor – which is far more mechanically significant than in D&D – and the only way ever to get spells. The text says “we feel treasure is its own reward,” in derision toward the D&D method, but it is full of shit. Level up all you want but if you stay dressed in ragged underwear and keep wielding a 1+2 dagger as you did at the start, you’ll die in the next five minutes. Gold currency is fundamental to the juxtaposition of danger vs. character improvement in T&T, and it's given real weight because changes in armor, weaponry, and available spells are worth vastly more bang-per-buck than they are in D&D, and much more consistently so with every increased unit of effectivenes.

    Whereas in D&D, although that dynamic existed as I described, it was secondary to the huge impact of treasure on leveling up … and I think that was both artificially and critically necessary simply because the totals for leveling up were otherwise unreachable. I’m not claiming this was due to visionary, thoughtful game design; to the contrary, I go so far as to say it’s an artifact which happened upon a very accessible (if crass) concept that encouraged continuing to play. But once established and cemented, it was part of D&D’s brand as solid as Three Hearts and Three Lions carrot-nosed trolls or the knowledge that when the golems with numbers painted on them attacked, you kill the ones with the prime numbers. Briefly, it worked in terms of “play some more” and in terms of identifying with the game, doubling down on not playing other games, and thinking of yourself as knowing it (as Platonic knowledge, itself rebranded through the centuries as “have you heard the Word”).

    Arguably the removal of this feature from modern D&D – I’m not sure if it was in 2000 with 3rd edition or before then – is probably the most significant design deviation from the established culture of play. Based on what you've analyzed here, I am forced to conclude that the designers, at this point, probably removed it as a "bad" feature without critical reference to what it actually did during play. I think your description is sound, so the necessary and sensible thing to do – if you're going to eliminate it – is to double all XP rewards, or, probably more reasonable, halve the amount needed for each new level.

    • “Arguably the removal of this

      "Arguably the removal of this feature from modern D&D – I’m not sure if it was in 2000 with 3rd edition or before then – is probably the most significant design deviation from the established culture of play."

      The AD&D 2e Dungeon Master Guide (1989) is the transition point.  It lists several official ways to gain experience points, but getting XP for treasure is explicitly classified as an optional rule.  (There is then an extra-optional rule that allows Thieves and Bards to gain double XP for gold.)  It's an absurd decision, frankly, because the XP charts carry over pretty much unchanged from 1e, where 70-80% of your experience came from treasure.  It's like someone said, "Whoa, hold on, this incredibly slow rate of advancement is not slow ENOUGH." 

      I expect Cook was trying to make looting less integral to the game fiction, but couldn't go all the way and nuke the leveling thresholds, which is what 3e finally had the nerve to do.

    • Along the lines of more

      Along the lines of more personal testimony than critical thought … pretty much all talk about GP as XP in D&D is alien to me. Back in that AD&D '78-'82 timeframe, the transactional units I used, and saw used across a couple US states, with local variation, were "module/adventure completion" and/or "time to level!" Maybe monster-slaying XP was considered if "wow, you beat some tough monsters [nowadays "encounters"], maybe it's time to level earlier than expected", or etc. But fundamentally, the questions were "did we finish something?" and/or "is it time to level-up?" If so, THEN we need a number, so that all the 5-15% bonus values can be calculated and division across multi-class/dual-class applied. The number of XP could be anything (i.e., not enough to level or enough for leveling+) at the "we finished something" milestone; otherwise, it had to be enough so that SOMEONE leveled (current highest level? current lowest? an average? Could be any/all of those …) DM judgement might give bonus XP to a character for … whatever, and less XP for a character if a player hadn't been there for some sessions. I think we sometimes SAID "less XP if you act inconsistent with your alignment", but I don't remember it actually happening. A direct mathematical connection between the events/elements of play (encounters, gold, etc.) and the game rule level-up event wasn't a big deal.

      Something I note in thinking about this: XP-to-level varied across classes back then, and (generally) grew more as you levelled up than it would in later editions. Also, the tradeoff of multi-class-but-generally-lower-levels was considered important. We (rightly or not) thought there was SOME "design" involved in all that, so entirely ignoring XP would've been bad.

      I make no claim that this is a textually supported framework. Or that it's a good idea. Maybe there were magazine articles (obscure or not) and/or conversations at conventions involved. Maybe I saw this in multiple places because I made/helped make play happen this way – if so, I certainly wasn't super-intentional or rigorous about it. But I do think focus on the level rather than the points is common/useful.

      So all that said, I see a real focus on "good leveling up" in your system, Jesse, and I recognize that focus as a big part of most flavors of D&D. Looks functional and fun from here!

    • @Gordon: I have a lot less D

      @Gordon: I have a lot less D&D and AD&D hobby-aware experience than you, especially after the early stages. I acknowledged this in my comment, which describes personal experience only. In the 80s, the D&D-focused people I played with who took so-called campaign play seriously also felt strongly about every point and coin, by the book, like CPAs or actuaries … which is probably why those campaigns never went very far. To recall further, these players started shifting to Rolemaster or GURPS Fantasy or who-knows-what, trying to continue the campaigns.

      The changes I described above – halving the level requirements, etc – proceed reasonably to asking "what are we even doing this for" and moving to encounter increments or even just time-served. 

    • @Ron – Yeah, the variability

      @Ron – Yeah, the variability – by person AND over time for each person, even ignoring "edition" entirely – of what D&D IS, rules-wise, is substantial. Something I know you frequently point out, and which I think can be underappreciated generally. In some ways, what's surprising is that I DIDN'T run into gold/XP (with apologies/reference to your D&D religion series) "worship" as an element, as I certainly did run into (and bounce off) other CPA/actuarial-styled play.

      What I appreciate about Jesse's system here is that it looks like a WORKING use of something alien to me. I think it grapples with the meaningful "how to make levelling work" issues intelligently, DESPITE the fact this XP/gold thing isn't really part of my D&D toolset.

  2. Sense of Challenge / Risk in Combat?

    Jesse, I don't want to distract from your very perceptive and clever use of math here to adjust the XP curves for the players, but honestly I am just FLOORED that your group has played so much of a game that I've barely dipped into.  At the risk of derailing slightly, can I ask – What's been your sense of risk / challenge in combat (or elsewhere) over the course of the game?

    Different versions of D&D have struck different balances here, sometimes varying a lot over the course of campaign play.  In TSR D&D, it is a minor miracle for a character to survive to level 3… but after that, they're a lot sturdier against most foes who lack a "save or die" attack.  

    My extremely brief experiences with 4e made it seem like combat was a consistently tense affair, but I don't know enough about high level play.

    In contrast, I've played a decent amount of Tier 1 5e, and frankly, have never once felt any sense of peril.  The combat tactics aren't especially interesting at that level of play, and the GM seemed to think the rulebook's challenge-rating system was badly askew.  I suspect this may be a result of the way the game handles long rests.  But I'm really curious about your thoughts here.

    (Incidentally, all of that stuff from Basic about the room contents, and the 3e difficulty chart, are all things I've used repeatedly.  They work pretty well together.)

    • I want to echo James’s call

      I want to echo James's call for more detail on what play of the game over so many sessions looks like. Your group, Jesse, certainly seems to be living the extended-campaign D&D dream that people seem to be always struggling to make happen.

    • I’ll get to the combat

      I'll get to the combat specifically in a minute but let me point out some features that makes this game sustainable. It's really is rooted in the idea that I wanted to run the most straightford D&D game imaginable, which really is freebooters seeking fortune and glory in the dark corners of the earth. I have a list of what all the adventure sites will be all the way from level 1 to 20 but there is no campaign plot. It's just ever darker corners of the earth with more treasure and bigger threats. That's it.

      Two, perhaps, minor exceptions to that are the two world-lore level "twists" I have planned that come at the two biggest shift in PC power, Tier 3 and Tier 4. Tier 3 will open with a third faction entering the war. A desert land from the west filled with Undead, Beholders and Star Spawn. All my Tier 3 adventure sites are out there. Tier 4 will open with all the bloody fighting cracking open a portal into a Dante's Inferno-esq megadungeon.  And that's it for "plot" prep of any kind. They're really just excuses to shift tone and atmosphere but to keep doing exactly what we've been doing.

      Another feature is that this game is socially as casual "poker night." I have 5 players. We play if at least 3 of them can make it. We just don't talk about the absent players. It's like they weere never playing at all. When they show it's like they were there the whole time. People do only get XP for sessions they participate in so there is a level spread between the PCs. All of this is a non-issue.

      So, you can see with all that "D&D and chill" attitude you can see why I'm not particularly concernned with how dangerous the adventures actually are. It's all about engaging with weird stuff that may or may not blow up in your face. In the real word, you go into a halloween/fun house maze knowing you're not going to die but it still scares the shit out of you. That's what my adventures are like.

      And here's where my mathematical dungeon distribution really pays off.

      D&D5e is fundamentally a press-your-luck game. How much dungeon can you crawl before you run out of spells and class powers? It isn't about any one encounter itself being dangerous. It's about maybe the next one being just one too many.

      Using the math above, I end up with dungeons levels that are between 15 and 18 room each. But dungeons range between 1 and 4 levels deep and the PCs never know what kind of place they are in. Also, "levels" are used a bit loosely.  I have one adventure that is a lighthouse where the stacked up rooms of the lighthouse above ground are the first level, the sea caves below it are the second level and those lead into a Kua-Toa temple that is the third level even though it's the same physical depth as the sea caves.

      The players never know how much more dungeon lays ahead. I also roll for random encounters about once an hour of game time and more frequently if the players are exiting the dungeon (about one every previously visited room to see if it's "repopulated").  I always roll to see if there's a random encounter when the players short rest and I roll about 4 times if the PCs try to long rest. They know resting inside the dungeon is dangerous. Even if they have something like Tiny Hut they know that means they will likely just wake up surrounded if they try to use it inside an active dungeon.

      So the pacing tension is, "Do we keep going? Do we risk a short rest? Can we get out if we need to long rest?"

      Now, remember under my math distribution 1/3rd of all this is just plain empty. But I don't just say, "This is an empty room." I write little atmospheric descriptions. Empty rooms are great place to have cryptic warnings written in blood on the walls or other evidence of recent activity. They basically aid in revealing backstory (my advennture sites do have history and purpose) and raising tension.

      But more importantly you can't tell emptry room apart from a room with a hidden danger like a trap or invisble monster. And some times you can't tell a feature in an empty room from some kind of puzzle. And of course, by the math, a small portion of empty rooms have a treasure in them somewhere.

      So all the rooms that don't have obvious monsters in them kind of blur together and always raise the question: Do I blow a resource in this non-combat situation?  Detect Magic?  Fly over the Chasm? What if they do set off a trap?  Use healinng now or save it for later? What about Speak with Animals to get info out of the animals in this livestock room we found? The ever present question: Is it worth it? What if we fail to pick a lock? Do we break it open, risking noise an random encounter?

      This is why when people say "nothing happens" is a boring result.  Not if you're doing what I'm doing.  Because "nothing happens" likely means you just ate through some of those "press-your-luck" resouces.  "Nothing happened" here but everything else just got an ounce harder.  There's a lot of, "Fuck it, I cast Detect Magic" followed by "Yeah, there's nothing magical here."  "God damnit, well, it lasts 10 mins, lets move quickly and maybe we'll find something before it expires." in this game.

      Now, there's one thing I do want to mention about the difficulty of individual encounters. In my write up I mentioned how the DMG drops the total XP threshold of enemies the more you have presumably to account for the action economy. I think at some point they realized that doesn't accurately account for all the crazy shit PCs can do, and "Hard" encounters by that math aren't hard at all.  There's an alternative encounter building method in Xanthar's Guide to Everything that is both easier to use and doesn't bother to account for more enemies.

      So under the DMG method Bandits vs 1st level PCs looks like this:

      Easy: 3, Medium: 5, Hard: 6

      Under Xanathar's method it looks like this:

      Easy: 4, Medium: 8, Hard: 12

      Encounters under Xanthar's method are both more difficult and do not produce an XP gap.  So, I'm thinking about using it to plan Tier 3 and Tier 4 and drop the XP for teasure because Treasure math at those tiers is no longer in sync with the XP curve.

      Hope that answers your question, James!

Leave a Reply