iopstaffing.blogg.se

Dungeon generator algorithm
Dungeon generator algorithm









(grey) The snapshot's bordered areas become the wooden tunnels & flooring (as seen in the demo). Erosion consists of changing a wall-type into floor-type based on surrounding elements (when entirely surrounded, no erosion, but if there are only 2-5 surrounding wall elements, there is a good chance of erosion)ĥ. Place the three big rooms (one on left, one enclosed room in the middle, and one room on the right)Ĥ. Construct a maze that covers the entire room.Ģ.

dungeon generator algorithm

If you type a capitol O and then move in some direction, it will make the entire map visible (so you can see the wood & cave elements as I describe below)ġ. I attempted to do this actually, the demo: Ĭlassic roguelike controls: hjklyubn, you know the drill I'm sure

#DUNGEON GENERATOR ALGORITHM CODE#

(The above are semi-guesses, the nethack source code isn't too well documented) Then, when it would usually construct paths between rooms, it uses a modified form of the maze algorithm (the same maze generator used in Gehennom, and in some other levels).Īlternatively, it creates a maze-level, covers it in small rooms, then trims off the remaining dead-ends. also, the check requiring at least 1 cell between each room isn't used). I want to say (don't take my word for this though) that it places an absurd number of small rooms around (like usual, but more & smaller, so as to leave less gaps. A similar approach could be used, splitting a platform-game's room into various areas, then filling them with content based on how much cell space is provided. When there is a split, sized leave spaces open (so as to respect the paths entering and leaving them). Each of the cells is then split again, and again, until the cell reaches the minimum possible size. The rectangle is then split into a 2x2 grid, where the cells are random-sized. There was a maze-generation algorithm where the entrance and exit are placed on the outer edge. The the shop, for instance, adjusts inventory based on the size of the room. Go through every room and generate content for it, from several templates (including a standard dungeon room with monsters/treasures, shops, beehives, swamps, throne rooms, etc)Įach of the templates is generic, but has its own requirements. Connect the rooms with passages (and generate doors at this point)Ĥ. Make sure there are at least 2 rooms of suitable sizes for the up/downstairs (and check for other neccessary rooms for particular floors), otherwise return to step 1.ģ. Generate some rectangles amongst the entire floor, make sure the rectangles don't collide.Ģ. Nethack (an awesome roguelike) takes an approach as follows:ġ. Hopefully the dungeon generation code is well-written and well-commented.Įdit: whoa, thanks for the PCG wiki link! I never knew such a thing existed! If you need more help with the algorithm, there are plenty of open source roguelikes out there. From here, you can make more complicated algorithms to generate rooms and corridors to get labyrinth corridors or non-rectangular rooms.

dungeon generator algorithm dungeon generator algorithm

If you can't connect rooms with a straight corridor, just make one or more bends in it. Proceed to generate corridors between these doorways, making sure that all the rooms are connected (there are no disconnected rooms, or sets of rooms disconnected from all the others). Then, you randomly create doorways to each room based on some other variables. Basically you choose a number of rooms, a min room size and max room size, and maybe some other variables, and generate a bunch of non-overlapping rooms. The algorithm for those dungeons is pretty simple. If you set some of the options to more conservative values (rectangle rooms, straight/bent corridors, no deadends) you'll notice that you've got what looks like a roguelike dungeon. The generator you link to looks like a pimped-out version of a roguelike dungeon generator.









Dungeon generator algorithm