Themed Room Generation - Devlog #9


Another week has passed and we have been hard at work...

The way TotS generates its rooms changed a lot during its development. Initially we were still focusing on the placement of the rooms themselves, meaning they didn't have much in form of flavour. We soon noticed a need to make rooms more interesting, both to make them more diverse and enable the player to properly memorize them in order to navigate the maze without a mini-map.

Which brings us to this week's topic:

Themed Room Generation:

We want to elaborate a bit on the process of how the game's rooms are filled, and we'll use the room shown in the attached gif, a medium-sized prison adjacent to a sewer, as an example.

Our first step to make rooms more distinguishable was to implement rules for their generation. Things like room size, level depth and location on its layer determine what kind of purpose or "theme" a room can have. After determining a room's theme, a ruleset is used to populate and fill that room with content.

A room's objects fall into three categories: walls, floor and content. 

The sewer outlets in our exemplary room are part of the wall category, while the puddles on the floor of course fall into the floor category. The content category consists of objects inside the room which aren't related to either the wall or floor, such as the prison bars in the adjacent prison.

In the process of populating a room with objects appropriate for its theme, the generation considers a ruleset for each individual object it tries to place. Let's take the sewer outlets as an example. They are part of the wall category and their ruleset looks like this:

  • It has to form a line with exactly two walls (so it can't be placed in a corner)
  • It has to be placed at least 3 tiles away from doors
  • The room has to have at least one but at most two sewer outlets

When the room is generated, each of its tiles is placed in a randomly ordered list. Each tile is then checked against its ruleset, and if it fulfills it, the sewer outlet is placed there. If it doesn't, it gets skipped and is later reconsidered for another object.

Each room tile can only once be filled with objects of each category, so there can't be multiple floor objects in one space. However, objects of different categories can indeed be placed on the same tile, for example a crate standing in a puddle (content and floor categories respectively).

Once all content is added to the room, creatures are selected based on the type of room and placed inside. Their amount and positions are based on similar kinds of rulesets, making it possible to directly influence their position. Enemies shouldn't end up in locked prison cells, for example.

This is the gist of it. We considered many different approaches to room generation in the beginning. Most prominently a template-based process as seen in many other games with randomly generated levels, but went with the ruleset idea instead. While these rulesets can become quite complex for intricate rooms (like the prison), it offers us unique qualities like more unique room designs and much more flexibility. In the end, we are quite happy with the way it turned out and are interested to hear your opinion on this topic.

That's it for now, so hang tight for next week's update!

Cheers

GG

Get Tales of the Shepherd

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.