bopsrank.blogg.se

Random dungeon map generator algorithm
Random dungeon map generator algorithm









random dungeon map generator algorithm

random dungeon map generator algorithm

If the difference in weight is high, then the algorithm will prefer going through existing rooms and corridors, making the paths more tortuous, and with fewer choices to reach a certain destination. If the difference in weight is small, then digging new corridors will be reasonably cheap, and the algorithm will make many corridors in between rooms, with many possibilities to go from a place to another. For this, run a pathfinder to dig corridors (let's say, A*) in between each pair of rooms, giving a random chosen weight to existing spaces (rooms or other corridors) compared to space not yet carved (the walls). It places the chests by using the A path finding algorithm to find the path between the 2 staircases, then places the random chests in areas furthest away from that path. Places up/down staircases, and adds chests in random areas.

RANDOM DUNGEON MAP GENERATOR ALGORITHM CODE

Hopefully the dungeon generation code is well-written and well-commented. If you need more help with the algorithm, there are plenty of open source roguelikes out there. Then, you need to make sure that all rooms are connected to each other. Generates a random rogue-like dungeon that could be used as a dungeon generator for 2D games. From here, you can make more complicated algorithms to generate rooms and corridors to get labyrinth corridors or non-rectangular rooms. An adaptive algorithm could even define some zones that are made of large hallways, and others of very small rooms. Random parameters will define the size of rooms and their numbers. I managed to get reasonably good looking levels by using the following algorithm, based on a square grid:įirst, create a set of rooms.











Random dungeon map generator algorithm