< DevBlog


I just finished Derek Yu’s book on his creation of the game Spelunky (aptly entitled Spelunky). I was interested in the general process of the game’s creation but I was also keeping my eye out for something more specific. We want this game to have algorithmically generated level design – there’s no question of that. But we also want the randomness and chaos of each new world to be interwoven with handcrafted or ‘authored’ content. Spelunky is a perfect example of this. And what I was looking for was Yu’s approach to tie them together.

Each new Spelunky level is generated from an algorithm but the different building blocks of that level use what Yu calls ‘templates’. When a template is used, it’s not like everything in it is set in stone. Here’s a template example.


Some characters are fixed – 0’s are empty space and 1’s are walls. Other characters are more randomized – 2’s have a 50% to be empty and 50% to be a wall. Still other characters are more complicated – 6’s call for a smaller template (Yu calls it a ‘chunk’) to be inserted inside this one.

So templates, it seems, are Spelunky’s strategy to interweave authored and procedurally generated content. Templates with randomization within them and with the possibility of templates within them. Each Spelunky level calls for up to 16 of these in a 4×4 grid. And when you combine the randomization of the order of those templates, the randomization of blocks within those templates, the randomization of the chunks within them and then of the monsters, treasures, etc on top of it all – you’re left with level generation that genuinely feels new each time. It cleverly integrates the handcrafted elements. Well done, Derek.

In terms of implementing this in Snakelikeian caves… it’ll need to be adapted. A Spelunky level is composed of a 4×4 grid of areas. The templates are able to slot right into these areas. Our caves are more chaotic in terms of available template real estate. But I like that!

We can keep most of our templates quite small (5×5 or 6×6). We can have different sets of templates for dead-ends, wide open areas, narrow passages. Maybe there’s a nest of Quadskitters in that dead-end. Maybe the open area is a peaceful clug farming community, maybe the mighty Octobo lurks around the next bend. I’m excited to see the way these populated templates function when they’re abutting one an other and their inhabitants begin to interact. We’ll have to slither there together to find out.

In the next 3 posts we’re gonna focus on a few of the template types we know we want to add: Demi-Bosses, Puzzles, and Peaceful Areas.

Comments are closed.