#gamedev Creation of a dungeon generator

This post will talk a little about how we are building the dungeon generator for our new rogue like that is currently on kickstarter.

mazegen

 

sample1

 

The system follows a simple process

Step 1 create and (e)mpty grid of random size

step 2 attempt to place 100 randomly sized but no smaller then 4×4 rooms into the grid. If there is an intersection move on to the next attempt. If not place the room(1) and (W)alls.

Step 3 Place a random number of (D)oors on each room on random walls and locations this is weighted to be most likely to place a single door and exponentially less likely to place multiple door.

Step 4 Using a depth first maze system (previously I have shared this source code) Create (h)allways and additional (w)alls around the entire grid making sure to not intersect any rooms.

Step 5 ensure each door makes a hallway that reaches either another room another door or another hallway. This step still needs slight work to check if it is running alongside a hallway and if so to just breach down or up or left or right into it. This step currently just blast a straight hallway out from the door until a collision happens. The direction is found by checking the direction the door is in relation to the room numbers.

Step 6 Count and mark all deadends and find how many dead ends we wish to leave remaining (always less then 50 percent) Find all dead ends and randomly remove to the nearest intersection/turn then recount remark and remove over and over until the total number of dead ends is less then the goal amount

And this is where we currently leave off.

Next I will start to implement a method of removing some of the unneeded twist and turns as well as reduce the number of loops so that all rooms are not directly connected to eachother.

If you would like to try this generator for your self you can find this current version on the yoyogames marketplace.

 

Follow us and watch for more updates where we go into more detail.

 


Leave a comment

Your email address will not be published.