Dungeon maze generationCommunity Forums/Developer Stations/Dungeon maze generation
| While not really into the dungeon game scene... I was scanning around other forums and blogs today and thought that this blog gives a good explanation of generating a pretty good dungeon maze. I thought it may be of interest to some of the folks here. |
| Here's an early version of some procedural dungeon generation code I'm working on in Blitz3D. It needs more work to remove unwanted corridors and link corridors to rooms. It's based on the discussion in the blog you linked ( http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/ ).|
The code is adapted from my maze generation code in the code archives ( http://www.blitzbasic.com/codearcs/codearcs.php?code=3178 ) (3D version: http://www.blitzbasic.com/codearcs/codearcs.php?code=3179 ).
Basically I've taken the maze code, added some code to generate rooms, and modified the 'DoRandomWalk' function to allow island corridor sections to form where the walk-path is blocked (not really required with this code as rooms are setup so they can't butt up against each other or against the outside of the array).
EDIT: Fixed a couple of bugs. Added the 'RemoveAllUnloopedCorridors' function, which removes all corridor sections that dead-end (currently it removes the entire corridor maze, as there are no loops). Added the 'DecreaseMazeDensity' function, which removes the end cell of any corridor sections that dead-end for each iteration (the 'attempts' parameter specifies how many iteration attempts will be run).
EDIT2: Fixed another couple of bugs and added regions (with color coding). Regions are needed to test where to place doorways and other connections to connect the whole dungeon together.
Public domain code. Use it however you want.