Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generation of caves (not yet inhabited dungeon levels) from cave kinds.
Synopsis
- data Cave = Cave {}
- buildCave :: COps -> AbsDepth -> AbsDepth -> Area -> Int -> ContentId CaveKind -> (X, Y) -> EnumMap Point SpecialArea -> [Point] -> Rnd Cave
- pickOpening :: COps -> CaveKind -> TileMapEM -> ContentId TileKind -> Int -> Point -> (ContentId TileKind, ContentId TileKind, ContentId PlaceKind) -> Rnd (ContentId TileKind)
Documentation
The type of caves (not yet inhabited dungeon levels).
:: COps | content definitions |
-> AbsDepth | depth of the level to generate |
-> AbsDepth | absolute depth |
-> Area | map area of the cave |
-> Int | secret tile seed |
-> ContentId CaveKind | cave kind to use for generation |
-> (X, Y) | the dimensions of the grid of places |
-> EnumMap Point SpecialArea | pos of stairs, etc. |
-> [Point] | boot positions to be treated as fixed |
-> Rnd Cave |
Generate a cave using an algorithm inspired by the original Rogue, as follows (in gross simplification):
- The available area is divided into a grid, e.g, 3 by 3, where each of the 9 grid cells has approximately the same size.
- In some of the 9 grid cells a room is placed at a random position and with a random size, but larger than the minimum size, e.g, 2 by 2 floor tiles.
- Rooms that are on horizontally or vertically adjacent grid cells may be connected by a corridor. Corridors consist of 3 segments of straight lines (either "horizontal, vertical, horizontal" or "vertical, horizontal, vertical"). They end in openings in the walls of the room they connect. It is possible that one or two of the 3 segments have length 0, such that the resulting corridor is L-shaped or even a single straight line.
- Corridors are generated randomly in such a way that at least every room on the grid is connected, and a few more might be. It is not sufficient to always connect all adjacent rooms, because not each cell holds a room.