I came up with a method for generating dungeons with rooms and corridors, and wondered if other people do it the same way.
Basically my first attempt generated a bunch of rooms, and then attempted to connect them up with corridors. This wasn’t very good, had some pathing issues and left many rooms unconnected/unreachable.
For my second attempt, I decided to do things the other way around. I started by generating a series of connected and randomly turning corridors. And then picked random locations along this path and generated rooms at those points.
The result is quite organic looking corridor/room layouts, that are always connected/reachable. I then knocked through some random walls to make extra doorways where rooms or corridors were next to each other but not actually joined. This was to create some further paths and short-cuts through the dungeon.
Here are examples of the different stages of the algorithm being applied (beginning with the same random seed value each time):
Step 1 – Long connected random twisty corridor:
Step 2 – Randomise corridor section widths:
Step 3 Place randomised rooms at random locations on the path:
Step 4 – Knock through some random walls to make extra paths into adjacent rooms:
Step 5 – Find where corridors and rooms connect, to generate doors/archways (Marked as ‘A’):
Again, I’m not sure if this is how this usually done, but I found it to be an interesting experiment and thought I would share. 🙂