You must be 18+ to view this content

Turk's Crawling Dungeon may contain content you must be 18+ to view.

Are you 18 years of age or older?

or Return to itch.io

Deep Dank Dungeons


In the previous blog post, I talked about the total overhaul Turk’s Crawling Dungeon has experienced in recent months. A good chunk of the thinking and planning that went into the overhaul was dedicated to rewriting the dungeon generation code. After all, what’s a dungeon crawler without a good dungeon? 

In previous versions, Turk’s Crawling Dungeon made use of prefabricated rooms assembled randomly to emulate a randomly generated level. I chose this approach mainly because it seemed a heck of a lot easier than generating a truly random dungeon. To achieve true randomness, I’d need to write a lot of code: code for positioning rooms, code for building them, code for furnishing them, code for connecting them to one another, code for this, and that, and all the rest. 

I simply didn’t have the time for all that coding. With prefabs, at least I could save time by hand-designing the rooms, then sprinkling some randomness in later, in the form of loot spawns and enemy selection. This was sufficient, until it wasn’t. I got bored of seeing the same rooms over and over. I craved the uniqueness of a truly random dungeon, so I set about redesigning TCD’s dungeon generation from scratch.

The Cool Zone

I call the individual “levels” of Turk’s Crawling Dungeon “Zones”. Zones are built up out of “Features”, the most important of which being the “Chamber”. Chambers, simply put, are rooms. They are also the main stage on which most of the action will unfold, and as such, their size, shape and placement are the building blocks with which the entire game experience will be built.

Zones begin generation by accreting a random number of Chambers, placing them so as not to overlap. They are sculpted either as a rectangle or by using cellular automata, which create Chambers with an organic shape. Chambers generated after the first are then connected via a corridor to the Chamber placed before it. Boom! We already have the skeleton of a dungeon.


(Pictured above: empty Chambers in a newly-generated Zone.)

To add a little flair to the Zone we have so far, I throw a splash of color onto the floor and wall tiles. Using perlin noise maps to govern the RGB values, I add a cool tinge to the floors and a warm one to the walls. The cool/warm contrast is spicy, and I suspect it does something to enhance the readability of walls vs. floors.

Onto the tricky part: we have these (nicely-hued) Chambers and corridors, but nothing’s in them! This is where “Environments” come in. Zones assign Environments to Features at this stage of generation, and these Environments will end up controlling how these Features are decorated.

Environments consist of two main parts: “Furnishers” and “Furnishings”. Furnishers are the rules with which decorations are placed, and Furnishings are categorized objects that get placed by Furnishers. Each Environment is decorated according to these components.

Furnishers will be called at random by the Environment to decorate a position in a given Feature. Furnishers will then decorate that spot by searching for Furnishings in a specific category, then placing them according to their ruleset. For example, the “Tables and Chairs” Furnisher checks if a position is empty before putting down an object from the Environment’s “Table” Furnishing category, followed by two adjoining “Chair” Furnishings. This system allows for new Furnishings to be defined on-the-fly, and for Furnishers to be multi-purpose; a “Bush” Furnisher can just as easily put down enemy objects in a cluster as it can foliage.


(Pictured above: the same Chambers shown further above, after furnishing.)

Once Chambers are furnished, we can put down some enemies and loot. Place a set of stairs leading down to the next level of the dungeon, and voila, the Zone is generated.


Results

I think that so far, the new Zone generator is far superior to the old prefab system. Now, every dungeon is perfectly unique and interesting to look at. They play fairly well, too! 

Zone generation parameters are easy to configure, which will make modding a breeze. Even more importantly, it will make development of different Zone types as easy as editing the XML. The flexibility this system affords is well worth the effort it took to code, and I hope this read was interesting from a technical perspective.

The new version of TCD comes out August 13th, 2021, and I’m excited to share my progress with you all. Cheers!


Get Turk's Crawling Dungeon

Leave a comment

Log in with itch.io to leave a comment.