Roquelikes, dungeon generators, procedurally generated levels and worlds are very popular. There are a lot of options and tutorials around the web for generating heightmaps, but what I found is that there aren’t many ideas on generating dungeons. Well, there are actually quite a few ways to generate dungeon systems. But there is one approach that I really like, and I will discuss that today.
Essentially, this approach exists out of 2 functions;
#1: Pick a random door.
#2 Generate a room, this can be any kind of form, square, circular, it doesn’t matter.
#3 Generate walls, these walls form a border around the room.
#4 Pick random walls, and let them be doors.
#1 Pick a random door,
#2 Create a hallway, from this door to any location, this hallway can have any length or width.
#3 Create a wall around this hallway
#4 At the end of the hallway, create a door.
#5 Pick random walls, and let them be doors.
Initially, you need a door at any random location. But this is basically the concept of how it works. Inside a loop, you perform the two functions randomly. Below you can see a series of images with examples.
Credits to Clint Bellanger for the tiles.