Procedural Dungeon Generation: Dungeon Generation Using Box2d Part 2

For this week, I continued to work on dungeon generation using Box2d part two. The first part is to generate and separate rooms with Box2d, and the second part is to match and create rooms on the dungeon map, and to create hallways between randomly chosen rooms.

Steps:

  1. Create overlapped rooms in a circled based on normal distribution
  2. Add rooms to Box2d world
  3. Simulate physics to separate all rooms until none is colliding
  4. Match rooms on dungeon map
  5. Pick and draw random rooms as main rooms
  6. Create hallways between rooms

This algorithm currently accepts two inputs. Max Room Num determines how many rooms are created and added to box2d world. Main Room Chance determines the chance of each room becoming main room. If the number of max rooms is very large comparing to grid size, some rooms will be outside of the grid after physics simulation, and those room will be removed from the list.

According to the data, the average time of the algorithm is faster than BSP dungeon, but slower than agent-based dungeon and tyrant dungeon. Its room number is not as stable as the other algorithms because it has an input of probability to generate rooms.

Comparing to the other algorithms, the room distribution of the algorithm is a little different. Since rooms are generated inside a circle and then separated by physics simulation, they will be distributed close to center. BSP dungeon distributes rooms uniformly. Agent-based dungeon and tyrant dungeon distributes room randomly, but their rooms will always reach the border of the grid.

For next week, I will focus on bug fixing, optimization and final presentation.

For future work, there are new inputs, data and algorithms that can be implemented. it will be valuable to add new tile types such as door and stair. Room can have custom defined shapes. It can also support exporting serialized dungeon map from TestBed. A better hallway build function can be implemented.

Leave a comment