Generating dungeons, Part 1: The basics

Sample from an early prototype of my generator

This part of the article talks about the basic concepts and entities of generating a dungeon. The dungeon generator discussed takes the viewpoint based on rooms which are connected in different ways to other rooms. We will discuss a modular design of a generator which can be extended and rebuilt to create whatever 2D dungeon you have in mind. The image on the right shows a sample of a generated dungeon. The code generating it will be released as open source when I feel it's up to par. If you feel like contributing to it, send me an e-mail or twitter me.

Introduction

Random dungeon generators have a big role in a lot of games. If you're building a game and don't want to spend 80% of your time designing maps, it might be a good solution. I belive that some main dungeons should be manually created while the ones that are for grinding purposes or sidequests can be generated. They can also be generated with a static seed number to keep them the same from one session to the other. Another way would be to use a generated dungeon as a start when creating your own ones.

Most dungeons contains areas resembling rooms. The rooms are connected by corridors, doors and sometimes other means by traveling such as portals. A lot of the generators use only square rooms, while some have more intricite design. Other generators have rooms can have the shape of a T,L,U,Y,etc.

In this series, I want to talk about my approach to generating dungeons.

Basic generation principle

My basic principle is that the generator is generation a path. The path can consist of only corridors, only room or probably both. Some rooms are connected directly to other rooms and some are connected by corridors. In some cases there are portals between rooms. The dungeon has a start somewhere and and an end somewhere. Some dungeons have multiple end and starts, but I'm focusing on generations with one start and one end. A dungeon should also have branches protuding from the main path which can contain more threaths or rewards. Some branches could also be connected back to the main path to the player doesn't have to backtrack. The most important part is that the game is fun and spending more time running back and forth isn't extending the gameplay/playing time, it's just boring in the end.

Limiting endless generation

One way to limit endless generation is to specify the max number of rooms to generate, another one is to give each room a value depending on their characteristicts (maby the time it takes to resolve the room until one can move on to the next one) and have a max generation value for the dungeon. I'm selecting the value principle.

Varied generation of parts

The rooms need to be of different sizes and different shapes. The corridors will have so curve and bend, sometimes to straight. A way to accoimplish this is to have generators for rooms that generated different shapes. The generators can then in turn take settings which specify constraints such as maximum width and height and how much generation value that room has.

Threats and rewards

A most important part of a dungeon is the threaths/obstacles to overcome and the rewards for traversing it. It's the core of gameplay. If it's a obligatory dungeon, the rewards might be zero. I'm adding a Reward and Threat value to the RoomSettings. These will be transfered to the generated Room. The PathGenerator could also contain a MaxThreatGenerated and a MaxRewardGenerated value, but I'll stick with the GenerationValue. All dungeons shouldn't be balanced to each other, some should contain more rewards and some less.

Summary

To sum it all up, we have a PathGenerator which created rooms and corridors and occasially branches out a new path which should contain some sort of perk/reward for the player. The rooms are created with RoomGenerators based on a RoomSetting which gives them distinct shapes. The CorridorGenerators works with the same priciple as the RoomGenerator, but without settings.

Stay tuned for the future posts on dungeon generation

Tags: Generating dungeons

maj 23 2011 11:02
Add a Comment

Blow him up!