Designing Procedural Dungeons for Torgar’s Quest

Torgar's Quest
There are many ways to approach procedural level design. For Torgar’s Quest, I wanted randomly generated mine-like dungeons, so I went with the carving approach: starting with a map filled with “walls” from which you cut out the level.

The key to this approach is designing the carver object, the thing that cuts out rooms and corridors. You need to make sure, you don’t get too close to the map edge, or you will have a hole in your level. You’ll also want to decide when to turn in a new direction, and to do so at a good rate, thus avoiding long, unbroken corridors on one end of the spectrum and huge caverns on the other end. I spent a lot of time changing parameters to find an algorithm that generated the kind of map I wanted.

Torgar's Quest

I realized, I would need more than one carver object in order to spawn off side corridors. At first I spawned these at different pre-determined coordinates and let them do their thing. However, this approach proved imperfect, because half the time one or more carvers would fail to connect with the others, so there was no path there, which in turn caused problems when spawning in things like the player and the level exit.

To fix this, I ended up creating a master carver, which would then spawn other sub-carvers from within its own path. These new carvers thereby start from somewhere along the main path and create forks in the map. The trickiest part then, was balancing when and where to spawn in the sub-carvers, in order to get a dungeon that felt right. Again, this came down to trial and error.

Torgar's Quest

How I did it was based on time. The master carver runs for X seconds, and after a quarter of the time has elapsed, it spawns the first sub-carver, then again at half time, and finally again at three quarters. At full time, the master carver destroys all carvers and moves on to spawning in monsters, etc.

One challenge with this approach is time. The carvers need to crawl around and generate the map, but I did not want long load times for the player. A few seconds was fine, because it gave me a chance to display a new bit of the game story, but it had to be balanced. Initially it took too long for the maps to generate, so to fix this, I sped up the frame rate of the game while the map generated, thereby speeding up time in a way.

Once the carvers are done, the loading screen goes away and the action begins.

For more about Torgar’s Quest, check out the website (where you can play the browser version, too).

Introducing Torgar’s Quest (roguelike)

Torgar's Quest (alpha)For several months now, I have been working on a 2D village building game, Founder, using the Gamesalad engine. Since Gamesalad runs on Mac and mine started randomly rebooting several times a day, I could no longer reliably work on my village builder.

Bummer. Doubly so because I have limited time, so a trip to the Apple Store will have to wait until after the holidays.

They say you should make lemonade, when Life gives you lemons, so I fired up my PC instead, and GameMaker Studio, which I have been using more and more anyway, and started a project I had wanted to try for a long time: building a roguelike dungeon crawler.

Thus Torgar’s Quest was born!

For those not in the know, a roguelike is a turn-based game inspired by the classic game, Rogue, in which you run around fighting things on a randomly generated map. Oh yeah, and there’s no saving the game, so if you die, you have to start over. Read more about roguelikes elsewhere (I will be following up with a post on how I went about it later).

I was initially thinking of this project as an exercise in coding the procedural level generation, just a bit of fun while I wait to get my Mac fixed. But as it sometimes happens, the side project took on a life of its own, and I let it, because I love roguelikes.

Within a few days, and with the use of a fantastic, free tileset, I had a working alpha build. From here, it’s a matter of tweaking the balance, adding a few more features and audio. It’s still a work-in-progress, but I am going to keep Torgar’s Quest pretty small.

Right now, a playthrough takes just a few minutes to play, unless you get really lucky or play better than usual (read: me), and that is pretty much perfect for what I am looking for.

Eventually, the finished game will be available for sale, but while it’s still in alpha, it is absolutely free to download and play (at the time of writing, it’s Windows only). The game even has its own website, where you can play a web-based version as well.