GD Game Database

Improving gameplay features in rooms of procedurally generated dungeons




Improving gameplay elements in procedurally generated dungeons.

Abstract

Introduction

‘Enter the Gungeon’ and ‘The Binding of Isaac’, two beloved 2D games under the rogue like genre. By utlizing PCG to generate their rooms and dungeons, the developers offer infinite replayability in their level design without the work of manually creating maps, layouts and rooms. But, it is not that easy. To create good looking rooms like in ‘Enter the Gungeon’, developers use premade rooms that are randomly put together to form a dungeon, which takes considerable amount of time to create. In ‘The Binding of Isaac’, rooms are randomly generated and filled with obstacles like rocks, fireplaces, poops and other elements to fill in the empty space, elements that are re-used throughout many other areas and rooms. As for enemies in these games, they are spawned based on other defined rules, which do not necessarily correspond with the room’s content and overall feel. We can observe that, even though PCG is used to generate the levels and dungeons, some of it’s effectiveness is taken away by having to design and develop part of the content beforehand, while other generated gameplay elements like obstacles might not always be in line with the room’s design and feel.

Problem statement

PCG loses parts of it’s effectiveness when having to design and create rooms beforehand, while filling generated rooms with meaningfull and coherent gameplay elements is challenging.
We’re interested in researching ways to procedurally generate rooms with gameplay features that are coherent and fitting to the room itself, without relying on predesigned rooms and layouts.

Research question

How can rooms in procedurally generated dungeons be generated with meaningfull gameplay elements that fit the rooms?

Highlevel goal

Generating a dungeon with different shaped rooms, that have different themes (Snowy, fire, grass), wherein each room is filled with content that fits the theme.

Room Requirements

The focus for the research lies in generating rooms inside a dungeon. To do so correctly, following measurable and tangible results, the requirement for the rooms consists of: - Rooms have different sizes. - Rooms have different shapes. - Each room has a randomly selected theme. - Tiles inside the rooms are placed based on the room’s theme. - A room has one or more group of tiles that form a puddle, based on the theme (Group of ice, water, or lava tiles for Snow, Grass, and Fire themes). - Rooms are connected via corridors. - Above elements should all be generated using various techniques and algorithms. - Different outcomes can be achieved by tweaking numbers, weights and other settings via an accesible interface (i.e the Unity Inspector).

Room themes

Earlier, I mentioned different kind of themes a room can have. These themes are defined by a different colored tileset for the room tiles, as well as some logic in code to handle the themes accordingly. The themes in quetion and their respective tiles are:

Snow Theme
  • White tiles representing snow as basic ground tile.
  • Ice cube tile to represent puddles.
  • Half snow- half water/ice tiles in 8 variations to place around puddles.
  • Water/Ice tiles with snow corners in 4 variations to place in corners around corners.
Grass theme
  • Green tiles representing grass as basic ground tile.
  • Full blue tile representing a water puddle.
  • Half grass- half water tiles in 8 variations to place around puddles.
  • Water tiles with green corners to place in corners around puddles.
Fire theme
  • Dark red tiles representing hot ground as basic ground tile.
  • Full orange tiles representing lava as puddle tile.
  • Half ground- half lava tiles in 8 variations to place around puddles.
  • Lave tiles with ground in corners in 4 variations to place inside corners around puddles.

Development

This section of the paper focuses on the developed project in the Unity game engine.

Techniques

To meet the requirements stated earlier in this paper, the project utilizes multiple algorithms related to PCG. The algorithms that have mainly been used and explored are:
- Binary Space Partitioning (BSP). - Random walk / Drunkard’s walk. - Wave Function Collapse (WFC).

Part I: Creating a dungeon

At the core of the project, lies a failry simple dungeon generator that utilizes the Binary Space Partitioning as well as the Random Walk algorithm to create a dungeon with multiple different shaped rooms, who are connected via corridors. Full credit goes to the Youtube creator “Sunny Valley Studio”, who made an extensive tutorial about 2D procedural dungeon generation in Unity. Following this tutorial allowed me to have a good starting point to modify and tweak further. By following the tutorial and going from there, the starting point looks something along the lines of:

The next step was tweaking the algorithm to produce rooms with more reliability in their sizes. To do so, adjusting the weight of the random walk algorithm could be done, but resulted in unfavorable results such as overlapping rooms, very unorganized edges, empty spaces and multiple rooms forming a single room. At this point, it became clear that Random walk was not the best solution to create rooms for this project. Additionally, the algorithm was very hard to steer properly, producing similar results would be hard to do so with just the random walk algorithm. To tackle this problem, the process of generating rooms should be refactored. By creating a Room class, that holds data such as it’s size, bounds and theme, the dungeon could be generated by creating new objects on certain positions. The use of a bounds allows for a primitive shaped room, that can be clamped between a min- and max size. Doing so resulted in rooms that are more easily to reproduce, as well as making them easier to work with in the future with additional logic. By also addinga random selected theme to each room upon creation, gizmos can be used to visualzie the current state:

To increase variety inside the rooms, I utilize the random walk algorithm to create puddles inside the rooms. By starting inside the middle of the room and adjusting the weights of the algorithm to walk for a limited distance, the rooms can offer some diversity. To visualize these puddles, as well as the rest of the room, the algorithm places a puddle tile corresponding to the room’s theme on each random walked position, and places a default ground tile on all other positions within the room. Doing so creates the following results:

This works, sort of. While the puddles are definitely created and the correct tiles are being placed, the random walk algorithm still does not seem to produce the desired results. Many puddles go out of bounds of the room, or create very unusual shapes.

Article by

Sam Leguijt


Categories

1

PCG