On multi-level dungeons

When you enter a dungeon in the overworld, if it’s the first time for that specific dungeon, it’ll have to be generated. But how to make a multi-level dungeon that makes a bit of spatial sense? Here’s what I came up with:

First, create a list of lists of boards. A jagged array, if you will. The amount of levels is randomized, as is the amount of boards for each level. Pick one board from the top level as the dungeon’s entry point, and one from the bottom as the goal. You could visualize it something like this:

Now, for each level, pick a random board or two and connect it to a random board one level down. Each pair of boards is noted in a special list of connected boards:

Now we use that list I just mentioned to connect each board to its right-hand neighbor, but only if either of them is not already connected:

And voila, you can trace a path from the entry to the goal, but only if you actually have a map drawn out. For the player, finding the path is part of the challenge.

This has been implemented earlier today.

Feel free to use this method in your own games.

[ ]

Leave a Reply

Your email address will not be published. Required fields are marked *