Single NPC Dungeon Delving Simulation

Previous week was simulation of level progression of NPC adventurers. The logical continuation is to pit such generated characters against dungeons, and run simulations for the outcome.

Dungeons: A Series of Challenges

The Tomb Of Horrors.

The Haunted Graveyard.

The Forgotten Crypt.

The Lair of the Werewolf King.

All these are locations where adventures take place, and typically adventurers slay lots of monsters and acquire treasure and artifacts. Since we’re still at a high level of abstraction, instead of creating dungeons and placing monsters, we can simulate the outcome in a simpler way, as a series of challenges:

Adventurer walks in, faces a skill test (e.g. how good is the two-handed skill) or a skill category test (e.g. how good are the combat skills on average), takes damage based on the test result (which is a scalar rather than a bool) and heals a bit. If the test passes, adventurer gains XP and proceeds to next challenge.

A dungeon is configured for a such coarse simulations as follows:

  • Number of challenges: How many challenges should adventurers succeed in to complete the dungeon.
  • Challenge rating:  The difficulty of the dungeon, in terms of character level.
  • Skill Challenge Pool: The skills that can be tested against, if the challenge is skill-based.
  • Skill Category Challenge Pool: The skill categories that can be tested against, if the challenge is category-based.
  • Skill Challenge Chance: The chance of encountering a skill-based challenge rather than a category-based one.

The two challenge pools (skill and skill category) contain subsets of skills/categories, each with a specified DC (difficulty class) modifier as compared to the average for the CR (challenge rating) of the dungeon.  So for example a dungeon could have particularly hard lockpicking tests, or very easy combat.

Adventurers can have their personal “retreat threshold” (aka bravery), so some will flee if their health is below 20%, others when it’s below 5%, others never.

The simulation goes as follows in pseudocode:

for each encounter:
    calculate challenge rating # progressively harder
    calculate test mastery level base
    test_type = weighted select skill or category
    if test_type == category:
        sample category # from the list of categories that we can test for this dungeon
        adjust test mastery level 
        run skill check against adventurer's average skill level
        calculate success and apply damage
    elif test_type == skill:
        sample skill # from the list of skills that we can test for this dungeon
        adjust test mastery level 
        run skill check against adventurer's skill level
        calculate success and apply damage
    if adventurer.dead():
        return status::Death
        if success:
            adventurer.awardxp( challenge_rating )
            flag encounter for retry

        if adventurer.health_critical():
            return status::Retreat

return status::Success

For simulation purposes, mana acts as a “mana shield”; when mana is available it can be utilized to block off damage at half effectiveness, e.g. at 100 damage, 48 mana left => 24 damage absorbed, mana goes to zero, adventurer takes 76 damage.

I developed two tests to see the simulation in action, single-delve and lifetime-delve

Single-delve tests

These tests take single adventurers and put them against a single dungeon. Run enough tests at all potential character levels, and we can get an idea of survivability rates at different levels. All characters are generated using the level-up strategies from the previous post.  Below are a few graphs that show the success/retreat/death per adventurer level by varying the general cautiousness of adventurers (CR mod), the number of challenges of the dungeon and their retreat threshold.

Here is a GIF with all graphs, to avoid flooding the page, as there are many many combinations (first retreat value varies, then challenges, then CR mod):

Lifetime-delve tests

These tests take single adventurers, starting from level 1 and put them continuously against dungeons until they die or reach level 30. The adventurers pick a dungeon level compared to their level, using a CR modifier (-5 is easier dungeons, up to 0, as above is suicide given the previous graphs). Here is a GIF again with all graphs, much less data this time, so easier to follow: ( retreat varies first, then challenges)

Next time, party time

Clearly the survivability rates are not great, especially at higher levels. So, as it is natural, parties can and will form, as there is strength in unity. The party simulation will not be too complicated, and should give a reasonable boost to survivability esp. at higher levels.

Finally there’s another wild idea. These simulation results can be exported to JSON, so that when AI has to make choices about which dungeons to tackle, it will use the graph results. The more the AI knows about a dungeon (CR, encounter num, etc), the more accurate the survivability percentage it will be, utilizing rumors, dungeon lore skills, etc. So, it can make a more informed decision.

Another fun idea is to try to use something like tracery (or a home-brewed adaptation) to generate “adventure stories”.

Adventurer archetypes: Level-up strategies

After writing down the extensive catalog of attributes and skills, it’s only natural that we have to create several characters to test things out. Characters (adventurers in this case) can be grouped in terms of their general capabilities and function; in many RPG games this would be a character class. In Age of Transcendence, there are no character classes; NPCs and players develop their skills as they see fit. In this model, “classes” are just suggestions on how a character may develop. Below, I call the classes “archetypes” and the development suggestions “level up strategies”.

Spawn Adventurer From Archetype

An archetype is a configuration to build an infinite set of similar (in some aspects) adventurers. The parameters at the moment are:

  • Race list
  • Age range
  • Alignment list
  • Starting level range
  • Level-up strategy list

When creating a character from an archetype, we choose a race from the race list, sample an age from the range, sample alignment from the list, sample a level from the range and choose a level up strategy. The interesting and complicated bit is the level-up strategy.

Level-Up Strategy

The level-up strategy is the configuration that the game logic uses to develop characters differently through the levels. For example, a level-up strategy for a fighter would focus on mostly improving strength, and focusing on skills such as body-building, heavy armor and weapon masteries, while one for a thief would focus on agility, daggers and/or bows and stealth skills.

The approach that I’m using is a mix of coarse and fine granularity weights, and it consists of:

  • Attribute improvement weights: a weight value per attribute, so that when we want to allocate attribute points, we do weighted sampling.
  • Well-rounded-ness: This is a scalar specifying how balanced a character will be. A balanced character will improve many attributes and skills, while an unbalanced will be more of a savant type, focusing heavily on a few skills, ignoring most others.
  • Skill focus: A list of tuples (skill name, target mastery level, allow surpassing target mastery level).
  • Skill category weights: A list of weights, one per skill category.

When we level up, we first allocate the unspent attribute points based on their respective weights.

Immediately after, we allocate a percentage of the unallocated skill points (based on wellroundedness: savants use more) to improve skills in the focus list, until we reach a target mastery level. When we reach the mastery level, we either never touch the skill again, or if we allow surpassing the target mastery level, we still consider it for advancement as explained below.

After we allocate focus skills, we have a remainder of skill points. These will be allocated to the rest of the skills, excluding the focus skills that have reached the target mastery and can’t improve. The weight for each of these remainder skills is the product of a) the skill’s category weight, b) the number of skills in the category and c) the distance of the skill’s value to the required skill value of the maximum mastery we can achieve with the current attributes. (note: (b) looks odd but it’s useful, as if we say that Offence (with about 10 skills) is as important as Adventuring (3 skills), it’s 3 times more likely that a skill in Adventuring gets a point)

There’s an extra important consideration. Some skills form subcategories, such as all “Weapon style”skills forming the “Weapon Style” subcategory, all “Melee weapon mastery” ones, etc. In these cases it’s more typical that a character develops one or two more than others, rather than equally developing the whole selection. For this reason, I

Finally, well-roundedness is used every time we do weighted sampling by replacing the weights with “w = pow(w,2-well_roundedness)”. It’s also used for the skill subcategories in the same way.

Below are some example level-up progression results using matplotlib. Title shows some info (Yes, some is bonkers, like neutral paladins). Y axis is the skill value, with grid lines at mastery levels (30 is Master, 50 is Grandmaster). X axis shows attributes (first 5) and skills. Darker colors show values at earlier levels, while lighter colors show values at later levels, as explained in the legend. The images are large, so you might need to open them in a separate window, or zoom.




Still here? Well, there are videos of these progressions too 🙂




Here still? Here’s my spreadsheet with the draft level-up strategy configuration. Well-roundedness seems to have an inverse effect, so I’d say that the graphs were helpful in noticing that 🙂


Archetype Name FighterX FighterS Fighter Thief Mage Bard Ranger Paladin
STR 4 4 4 1 1 1 2 3
AGI 2.5 2.5 2.5 3 1.5 2 3 1
INT 1 1 1 2 4 2 2 1
PER 1.5 1.5 1.5 3 2.5 2 2 2
CHA 1 1 1 1 1 3 1 3
[total] 10 10 10 10 10 10 10 10
Body/Mind 5 5 5 5 5 5 5 5
Offense 6 6 6 3 1 2 3 5
Defense 6 6 6 2 3 2 3 5
Stealth 0 0 0 5 0 2 3 0
Lore 2 2 2 2 5 5 3 1
Perception 1 1 1 4 1 2 3 3
Crafts 2 2 2 0 3 0 1 1
Magic 0 0 0 0 5 1 0 2
Social 1 1 1 2 1 5 1 2
Adventure 2 2 2 2 1 1 3 1
[total] 25 25 25 25 25 25 25 25
Well rounded 0 1 0.5 0.5 0.5 0.5 0.5 0.5
Athletics Expert+ Expert+ Expert+
Fortitude Expert+ Expert+ Expert+ Adept+
Reflexes Expert+ Adept+
Willpower Expert+
Concentration Expert+
Body building Expert+ Expert+ Expert+ Adept+
Meditation Novice Novice Novice Expert+
Weapon style [two-handed] Grandmaster Master Master
Weapon style [one-handed] Grandmaster
Weapon style [dual-wielding Expert+
Weapon style [ranged] Master
Melee weapon mastery [blunt]
Melee weapon mastery [slashing] Master
Melee weapon mastery [daggers] Master
Melee weapon mastery [polearms] Expert+
Ranged weapon mastery [bows/crossbows] Master
Ranged weapon mastery [slings/blowpipes]
Ranged weapon mastery [thrown]
Armor [light] Master Expert
Armor [heavy] Master Master Master Master
Shield mastery Master
Sleight of hand Expert+
Hide Master
Lockpicking Grandmaster
Move silently Master
Item lore Expert+
Creature lore Expert+ Expert
History and legends Expert+ Adept
Dungeon lore Expert+ Adept
Arcane lore Expert+
Literacy Expert+ Adept
Detect traps Expert
Spot Expert
Listen Expert
Sixth sense
Disarm traps Expert
Make weapons
Make armor
Make accessories and utility
Enchant item Expert+
Alchemy Expert+
Wand mastery Expert+
Staff mastery Expert+
Magic school mastery [command]
Magic school mastery [alteration]
Magic school mastery [divination]
Magic school mastery [creation]
Magic school mastery [destruction] Master
Leadership Expert Master
Persuasion Master Master
Renown Master
Perform Grandmaster
Scouting Master
Survival Grandmaster

(Formatting (bold, colors) is not copied over unfortunately, I’ll update this if I find out how)

Attributes, skills and masteries

My intention for this first draft of attributes and skills is to use a mix of systems that I like: Dungeons and Dragons, Might & Magic and Elder Scrolls. Needless to say, this is a draft and several things will change.

The system is classless: characters are free to develop as they like, mixing and matching from a large pool of skills, where standard archetypes (fighter/wizard/rogue) are implemented as strategies for attribute and skill allocation.


Attributes define the potential of a character for performing/using skills. They change infrequently, so they act as a skeleton for builds. They affect skills by providing bonuses (or penalties) and restricting skill mastery. I’m going with the typical DnD attributes except constitution.

  • STRENGTH: Physical power and resilience. Affects hitpoints.
  • AGILITY: Motor skills.
  • INTELLIGENCE: Intellect, reasoning. Affects spellcasting.
  • PERCEPTION: Intuition, awareness, insight.
  • CHARISMA: Influence on others

For starters, I’ll use the DnD scale where a value of 10 is average. Similarly, characters gain a point every 3 levels.


Skills are areas of expertise and training. They are split into multiple categories: Body and mind, offense, defense, stealth, lore, perception, crafts, magic, social and adventure. The categories are just a way of grouping related skills, so that players do not see a massive flat list of skills.

Skills can be used in a variety of scenarios, when a character is attempting certain actions (swim in the river/climb mountains: use Athletics. Attack with a greatsword: use “two handed style”. Talk to a guild member, use “persuasion” or “renown”. etc).

Skills start at 0 can be trained up to 50. Characters will earn 5 skill points each level to distribute. A skill value cannot be higher than 2x character level. So, a skill can be maxed at lvl 25. For reference, the soft cap for character level would be around 30, reached at about 20h of playtime.

Skills have optional associated major and minor attributes (in the below table, in column 3, if only one initial appears, it’s a major attribute). Major and minor attribute affect skill advancement as explained in the masteries section below.

Athletics Body and mind SA Climbing, swimming, etc
Fortitude S Resilience to effects on the body, e.g. poison and disease
Reflexes A Avoidance of physical effects
Willpower P Resilience to effects on the mind, e.g. charm, sleep, hypnotize. Also used for morale checks in combat.
Concentration I Resistance to being interrupted while using powers and casting spells
Body building S Hit points bonus
Meditation I Mana points bonus
Weapon style [two-handed] Offense S Effective wielding of two-handed weapons + tactics
Weapon style [one-handed] SA Effective wielding of one-handed weapons, with or without shield + tactics
Weapon style [dual-wielding AS Effective wielding of two weapons simultaneously + tactics
Weapon style [ranged] AS Effective wielding of ranged weapons + tactics
Melee weapon mastery [blunt] SA Effective use of blunt weapons: stunning, etc
Melee weapon mastery [slashing] AS Effective use of swords and axes: bleeding, etc
Melee weapon mastery [daggers] A Effective use of daggers: backstab bonuses, critical, etc
Melee weapon mastery [polearms] SA Effective use of polearm weapons
Ranged weapon mastery [bows/crossbows]
AS Effective use of bows and crossbows
Ranged weapon mastery [slings/blowpipes]
A Effective use of slings and blowpipes (stunning for slings, criticals for both, etc)
Ranged weapon mastery [thrown] SA Effective use of thrown weapons (knockback effects when using heavy items, etc)
Armor [light] Defense A Effective use of light armor: focus on mobility and stealth
Armor AS Effective use of medium armor: tradeoff between protection and mobility/stealth
Armor [heavy] S Effective use of heavy armor: focus on protection
Shield mastery SA Effective use of shields: bucklers to tower shields
Sleight of hand Stealth A Pickpocketing creatures, burglary
Hide A Hide in shadows (opposite of Spot skill)
Lockpicking A Opening locked doors, chests and any containers that are mechanically locked
Move silently A Opposite of Listen skill
Item lore Lore PI Item identification and knowledge
Creature lore PI Creature knowledge
History and legends PI Knowledge about myths, legends, history and past world events
Dungeon lore PI Knowledge about dungeons (architecture, layouts, etc)
Arcane lore PI Knowledge about arcana
Literacy I Knowledge and ability to decipher dead languages, old scripts, etc
Detect traps Awareness P Ability to detect traps
Spot P Ability to spot difficult to see creatures, items and dungeon features
Listen P
Ability to listen to moving creatures in dungeons, other dungeon sounds (e.g. water running in secret room), enemy ambush in the wilderness, etc
Sixth sense P Ability to sense danger (ambush, powerful creatures, strong traps)
Disarm traps Crafts AP Ability to disarm traps
Repair SP Ability to repair items
Cooking IP Ability to cook nourishing meals
Make weapons SI Ability to make weapons. Skill in particular weapons is needed too
Make armor SI Ability to make armor. Skill in particular armor is needed too
Make accessories and utility AI Ability to make jewelry and general utility items
Enchant item Magic I Ability to enchant items
Alchemy I Ability to effectively mix potions
Wand mastery I Effective use of wands (single hand, with shield, dual-wielding)
Staff mastery I Effective use of staves as magic spell conduits
Magic school mastery [command] I Effective use of command magic spells (charms, curses)
Magic school mastery [alteration] I Effective use of alteration magic spells (buffs, debuffs)
Magic school mastery [divination] I Effective use of divination magic spells (magic mapping, detection)
Magic school mastery [creation] I Effective use of creation magic spells (heal, summon)
Magic school mastery [destruction] I Effective use of destruction magic spells ( elemental, damage)
Leadership Social C
Ease of recruiting and maintaining followers. Also, summoning strength/effectiveness, otherwise e.g. powerful summons can turn against you. Also affects party morale in combat
Persuasion C Extract information, convince, reduce relationship penalties
Haggling C Cheaper prices for everything
Renown C Effectiveness of adventuring feats and deeds in terms of renown
Perform C Musical instruments, dancing, acting
Scouting Adventure PI
Sight radius, more info on nearby overworld entities (e.g. creature groups and locations), ambush bonuses
Survival PI Effective camping and travelling in the wilderness, ambush bonuses, finding more food
Find more things, find less curse and more blessed items, maybe occasional reroll when getting gravely injured

Again, the above is still work in progress and several things are prone to change. What’s missing at the moment are active abilities, but that’s for another time and out of the scope of this post.

Skill mastery levels

For each skill, there are several mastery levels / tiers. Everybody starts at the Novice level. When the character has allocated a certain number of points to a skill and fulfills certain attribute requirements (see Major/Minor attributes in previous section and column 3 in previous table), the character is eligible for advancing the mastery level, typically using a guild/trainer (for grandmaster level and maybe more, quests would be involved, as in Might and Magic games). Advancing a mastery level will give fixed bonuses and affect interactions with the character in the game world, unlocking quests, affecting relations, etc. For requirement purposes, the game will use natural values, not counting effects from spells/items/etc.


Skill mastery level names Skill Req Maj Attr Req Min Attr Req
Novice 0 0 0
Apprentice 1 4 2
Adept 5 8 5
Expert 15 12 8
Master 30 16 11
Grandmaster 50 20 14

If a character does not fulfill the attribute requirements for a skill, they cannot allocate points any further. For example, a fighter character with STR=17, DEX=13 and INT=10 can achieve:

  • Master in Heavy Armor ( STR > 16)
  • Master in Shield ( STR > 16, DEX > 11)
  • Expert in Make Weapons ( STR > 12, INT > 8)


The game will use standard cRPG values for life and spellcasting.

Max hitpoints for a level can be calculated from level, Strength attribute and Body building skill. Max spell points are similarly calculated from level, Intelligence attribute and Meditation skill. The formula draft at the moment (which will change with 99.9% certainty) is:

Level x ((Attribute-10) x 1.5 + Skill x 0.5 + 10)

Testing things out

At the moment I have a character generator based on predefined archetypes (fighter/wizard/mage/etc), so the next step is to design “challenges” for characters, their cost in terms of HP/MP and their value in terms of experience.