Dungeons

This week my main accomplishment was getting dungeon generation working. As previously discussed, the basic algorithm involved generating an abstract maze, and then converting that maze into a dungeon by creating a room for ever node in the maze and a corridor for every edge in the maze. There are a lot of parameters to tweak so I can generate very different kinds of dungeons. Some of these parameters are:

  • run probability - how likely are long runs (as opposed to branches)
  • loop probability - how likely are we to remove dead ends from the maze
  • loop weave probability - how often we simulate z-levels by having the maze dig underneath itself
  • room dimensions - control distribution of the room dimensions
  • num rooms - controls the size of the dungeon

Another cool thing I did to control how the dungeons look is by making the function that creates the actual tiles of the maze a callback. This callback basically just says it is creating a tile at a certain (x, y) position, and gives the type of tile (wall, corridor, room, or door). There is a default in case you don’t need anything special, but if you want to make a lava themed dungeon or have other special needs you can get it with a custom tile generator. In fact, I added various tile generation callbacks to all the different map generation functions, so overall I think we have a lot of customizability.

Anyways, below is an example of a dungeon you can generate with this code. This particular example was made with a loop probability of 1, a weave probability of 0, and the default tile generator.

Example of a generated dungeon

Now that I’ve got dungeons working, I want to take these maps and carve out some additional spaces using a cellular automata so I can finally make caves for my cavemen. However, this will have to wait a bit since next week is the 2016 7DRL Challenge!