Operation Roboid – Map Generation.

Dungeon

 

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:

Map_1

 

Step 2 – Randomise corridor section widths:

Map_2

 

Step 3 Place randomised rooms at random locations on the path:

Map_3

 

Step 4 – Knock through some random walls to make extra paths into adjacent rooms:

Map_4

 

Step 5 – Find where corridors and rooms connect, to generate doors/archways (Marked as ‘A’):

Map_5

 

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. 🙂

8 thoughts on “Operation Roboid – Map Generation.”

  1. It’s not, but it’s actually a really clever solution to get the result you actually wanted, which is often the challenge in procedural generation.

    Here’s an article on how Rogue, the granddaddy of them all, does it: http://kuoi.com/~kamikaze/GameDesign/art07_rogue_dungeon.php

    Yours look very different but still have the connected property that you wanted. I certainly haven’t seen (or remember!) every dungeon generation algorithm, but to my knowledge your method hasn’t been tried before, which surprises me because it appears to be a very elegant solution to universal connectivity.

  2. I’ve done something similer in one of my projects. What I did differently is I would skip step two, then before placing a room I would check the amount of empty spaces that the perimiter of the room would cross (the doorways). If the amount wasn’t in the desired range, the room wouldn’t be placed. Then I did some processing that removed walls to widen cooridors, remove dead ends, and generally make the map more interesting.

    I too started out trying it the other way around, and I did get garuanteed connection, but my algorithim didn’t give my the control over the amount of doorways.

    1. Another difference I caught as I just reread your post: instead of picking a point along the path to create a room at, I would pick a point anywhere in the map.

      Your idea to punch through walls to connect rooms a bit more is good. I didn’t do that, which meant a fair bit of traveling to get where you wanted to go sometimes.

      1. Cool. 🙂

        The chances of punching through walls is quite low, (8% I think) so if you have two long rooms touching, you might get a couple of door/archways made between them, rather that the whole wall partition being removed.

Leave a Reply