Home > Design > The Thoughts of a Procedural Level Generator

The Thoughts of a Procedural Level Generator

November 14th, 2012

So earlier I blogged about how procedural is so cool and rad, etc, whilst also bemoaning that there’s not enough detailed procedural generators that tie different elements like monster and item placement together.  I’m as guilty of this as anyone else, partly because it’s so much quicker to use simple algorithms, but also I guess because people don’t expect any better.  Well, let’s have a look about how a good dungeon generator might think through the creation of a level:

1. Huh? What? Oh goodness, I oversleep()ed and now I have to crank out a dungeon level. Well, let me think, should I have a theme? Yes! And what should the theme be? It’s deep in a dungeon and there’s not been a forge level yet, so I’ll make one of those, yes? Active forge? Yes. Will there be a dominant monster type? Yes. Population? Orcs. 60% dominance.

2. Okay, let me think openly about the general shape.. .. .. .. .. My, that’s a lot of noise/BSP tree/cellular whatsits! I’ll shape that up here with some heightmaps / room space allocation / edge smoothing / whatever else. Ah, that looks much nicer now! Any extra decorations to shape I want for now? No, it’s good as is.

3. Hmm, better check it all connects together. Got a lovely floodfill for that… And whilst I’m at it I’ll check there are no lengthy dead ends by adding a heightmap to the floodfill and connecting up some of the maxima. Can’t be having our avid adventurers backtracking all the time, after all…

4. Should I have a river? Nah… Lava? Sure! Let’s spill it in the east side, let it burn down some walls, go under this corridor (now a bridge over lava) and carry on south-west. Island in the lava? Okay, and I’ll place a special item there for adventurous types to fawn after. Enemies in the lava? Sure, I’ll throw some fire drakes in. They have a lovely ranged attack they can use on anyone crossing the bridge.

5. Might put a small vault in the north of the level. Keep things connected as it’s placed. What monster type? I’ll follow the orc theme and choose some orc assassins. Artifact reward? Nah. Large gold pile? Sure. Trapped entrance door? But of course…

6. Since it’s a forge I’ll make a large central room into a forge room, with a forge inside and some relevant materials. And an orc weaponsmith, and some goblin slaves. Nearest room will be stockroom. I’ll make it 40% armour, 30% weapons, 30% consumables.  Artifact? Okay, medium grade. And a second low grade too. I should definitely place a guardian here – a nice big troll in fact. Doors to this room are locked – I’ll put the key somewhere else on the level which is definitely accessible from the entrance stairs (ah, floodfill, I love you so).

7. Any other special rooms? An altar in the west will suit. Include some scrolls. And a rabid orc priest. Followers? No, but we’ll give him a pet. Fantastical creature? Sure! We’ll make it a griffon. And I’ll throw in some griffon babies too. Aren’t they cute?!

8. Hmm, there’s a dead-end room in the west.  Any chance of a special item for here? Sure, a special potion. In a trapped chest. Guarded by… mages. Path to the dungeon entrance from here is to the north, so I’ll position them in a defensive formation near the door there, with a healer behind them.

9. Now, in the other rooms we’ll place some orcs and a couple of other creatures, with no more than 2 being higher than base level. We’ll give one of them a wolf pet as well. And in one corridor we’ll put an archer – everyone likes archers in corridors, right?  And a trap there too, but we’ll let the archer know not to trip over that. And we’ll have the archer carry a nice bow and dagger.

10. All done now! As a final touch I shall christen this level “Corpsefire Forge”.  Bon appetit, adventurer!

Looks very involved, yes? Kind of like the thoughts a real designer would go through? But that’s the point really – you want something almost as good as hand-made content, but with on-demand infinite generation and variety.  It needs some coding together and a good pool of input values.  The coding is not so hard as you might think – everything above has been done before to some degree in open source games, so at a push you could copy paste this generator together.  But the hard examples to draw from are a lot more work if you don’t want the same few combinations popping up over an over again.  I guess this is partly why big roguelikes are so popular – the larger content pool allows for greater variety in random encounters.

Some day I’ll make a cool generator like this.  Honest  ;)

  1. December 5th, 2012 at 02:34 | #1

    me :

    So a procedural generator along those lines would have lots of twisty passages, with doors along them to break line of sight. But the monsters would be focussed in the rooms more than the corridors, and their AI would hold them back from engaging until the player is in an open space, unless being shot at. The occasional glimpses of danger/treasure can be deliberately placed just within line of sight for the player.

  2. me
    December 4th, 2012 at 18:07 | #2

    I design levels more on rhythm then on theme. Cramped twisty corridors where you cannot see far ahead so tension builds. Occasional glimpses of coming danger and treasure from across a chasm to build anticipation. And rooms so that you can fight with interesting positional tactics (because corridor fighting has less interesting choices).

  3. November 21st, 2012 at 02:17 | #3

    This is inspiring! :)

  4. Daniel Slaney
    November 15th, 2012 at 04:44 | #4

    This reminds of the IRDC 2012 conversation about dungeon generation, specifically that some of us thought there was plenty of room for improvement.

    There’s a good thesis covering some of the aspects of better dungeon generation here (I think I mentioned it on the Roguelike Radio episode but forgot to supply a link):


    The author doesn’t mention how to turn the graphs into actual level geometry though which would impede immediate implementation.

Comments are closed.