Notifications
Article
Procedural Dungeon Generator
Published 2 years ago
728
0
Just a little documentation on what I am currently doing for my game for Unity's 2D challenge
Steps: 1) Spawn random sized rectangles within a circle 2) Separate those rooms 3) Connect large rooms using Delaunay Triangulation 4) Use Minimun Spanning Tree to reduce the amount of connections 5) Turn the connections into "L" shape 6) Select all the rooms that are under the connection line and turn them into corridors
Iteration 1 Got the rooms spawning in with random numbers and separation a bit wonky. But the colors had no significance and instead made it harder to see the proportions.
Iteration 2 Rooms are now colorized based on their size Red: Under 40 units squared Yellow: Under 60 units squared Green: Under 80 units squared Blue: Over 80 units squared Blue rooms are now connected to every other blue rooms as triangles and are ready for the Delaunay Triangulation algorithm
Iteration 3 The triangulated rooms are now put into a Delaunay Triangulation algorithm, which has been kindly butchered by me to create something like this. The reason Delaunay Triangulation is used to connect each room in an orderly random way that should create endless amounts of connections. However, this is far too connected to create a proper dungeon.
Iteration 4 The Delaunay triangles' edges are sent into the Minimum Spanning Tree algorithm (which I also butchered and turned into my own version of it) to remove most of the edges in order to create a less connected rooms and further increase randomness between each dungeon.
Iteration 5 The edges from the Minimum Spanning Tree algorithm are then straightened into "L" shapes. This allows a better connection of smaller rooms and lessen the gaps. All while making it easier to select the rooms.
Dungeon Generation Completed All that is now left to do is turn these rooms into tiles via Unity's Tilemap
GH
Gismar Horsch
2
Comments