Generating dungeons, Part 2: Entities and definitions

This article summarises and explains the different generators and entities involved in the generation of the random dungeon. This is the second part of the dungeon generating series. If you have missed any previous parts, this list contains all the posts so far. 

Entities and definitions

GenerationSettings

Contains the different generators for Connections and Rooms. Which generators can be used for branches, the maximum value to generate for the dungeon, RoomSettings, seed for generation, etc, etc.

Room

Contains the basic information about a Room such as position, all tiles it covers, edges and it's perimiter around it. Edges are used when to establish a connection to the room from another entity. Why should a Room contain information about it's edges? Because the Rooms that we will generate in the end won'y just be square Rooms, they'll be shaped in different ways and need to be able to be connected from all sides.

RoomSettings

Defines the constraints and data from which Rooms are created. The constraints can be things like minimum and maximum width and height, the value a Room from this types of setting adds to the global generation value, the tag and/or category which to apply to the generated Room, etc, etc. A settings could for instance be tagged as "start", "end" or "boss" to let the game know where to place the player when he enters the dungeon and where the the main boss for the dungeon is located.

Corridor (Connection)

A Corridor is usually a path of tiles which aren't as wide as a Room and sometimes streches longer than a Room. A typical maze where the traversable path has a width of one is usually created with only corridors and stairs to other levels. In this article, "another level" is treated as another dungeon. I will treat a Corridor with a single turn as two connected Corridors.

Door (Connection)

A door is a thin connection (usually 1 tile thick) which connects two entites between each other. Mostly used between two Rooms or a Room and a Corridor.

Portal (Connection)

A portal is a connection between two Rooms which teleports the player between them when entering it. The Portal could be set into a wall like a Door, or could also decorate the floor of the Room. Portals allows for easy escapes when the generator has generated a path which fold into itself, making further generation impossible unless the generator backtracks. Another way is to "look ahead" when generating entities, but this costs time and gets complicated very easily.

GenerationData

This contains the shared data that generators and other functions uses. It contains the total amount of generated value so far, etc, etc.

Generators

Generators are responsible for creating the different entities listed above.

PathGenerator

The path generator is responsible for creating the path which rooms and corridors are placed. The path generator could be linear or a mazelike. Whatever you need. The generators can themselves create own generators if a new path is branching out from the main one. All generators start by placing the starting room somewhere arbitrary and the generation on the path starts at this position.

A linear generator would generate a Room, connect it with another Room via a Corridor and two Doors or just a Door between them. The Mazelike generator could create a path and after a set distance, create a room. After the room is created, a corridor would be established between these two rooms. 

The layout and path can become very dull all the Rooms and their connection Corridors and Doors end up on the same line. It's not very wise to center all connections (exits and entrances) to Rooms. A way to avoid this is to remeber on which axis the generator has traveled since the last Room and slide the Room along the other axis to achieve some shearing. This makes the dungeon more organic.

A branch generator could inherit from either generator, but adding the possibility to constrain the maximum amount of rooms generated. This is to prevent the branch from extending too long and divert the player from the main path too much.

Each PathGenerator have collections of generators for connections, Rooms, Threats, Rewards and such. If the collection is empty, it should take one of the needed generators from the global collection defined in the GenerationSettings.

RoomGenerator

The room generator is responsible for generating a Room based on the RoomSettings sent into it. When the rooms gets placed, a perimiter is established around the Room as a wall. Unless you want to merge Rooms into bigger ones, the perimiter should be tested for collisions when the Rooms are placed. The RoomGenerator itself shouldn't be responsible for the placement of the Room, it's the path generator which places Rooms along the generated path.

ConnectionGenerator

The connection generator is responsible for generating a connection between two set positions. In most cases, two Rooms. It could also be responsible for merging two Corridors into one if there's two parallel paths going on. Between two Rooms, the connection could either be two Doors and a Corridor, a single Door or a Portal which teleports the player between the two Rooms.

Examples: CorridorGenerator, TurningCorridorGenerator, SingleDoorGenerator, CorridorDoorGenerator, PortalGenerator, MergedRoomGenerator

ThreathGenerator

The threath generator is responsible for generating one or more Threats in a Room or a Corridor.

RewardGenerator

The reward generator is responsible for generating one or more Rewards in a Room or a Corridor.

Tags: Generating dungeons

maj 23 2011 12:23
Add a Comment

Blow him up!