LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Server.DungeonGen.Cave

Contents

- Internal operations

Description

Generation of caves (not yet inhabited dungeon levels) from cave kinds.

Synopsis

- data Cave = Cave {
  - dkind :: ContentId CaveKind
  - darea :: Area
  - dmap :: TileMapEM
  - dstairs :: EnumMap Point Place
  - dentry :: EnumMap Point PlaceEntry
  - dnight :: Bool
  }
- buildCave :: COps -> AbsDepth -> AbsDepth -> Area -> Word32 -> ContentId CaveKind -> (X, Y) -> EnumMap Point SpecialArea -> [Point] -> Rnd Cave
- pickOpening :: COps -> CaveKind -> TileMapEM -> ContentId TileKind -> Word32 -> EnumMap Point (ContentId TileKind) -> (Point, (ContentId TileKind, ContentId TileKind, ContentId PlaceKind)) -> Rnd (EnumMap Point (ContentId TileKind))

# Documentation

data Cave Source #

The type of caves (not yet inhabited dungeon levels).

Constructors

Cave |

Fields

- dkind :: ContentId CaveKind

  the kind of the cave

- darea :: Area

  map area of the cave

- dmap :: TileMapEM

  tile kinds in the cave

- dstairs :: EnumMap Point Place

  stair places indexed by their center

- dentry :: EnumMap Point PlaceEntry

  room entrances in the cave

- dnight :: Bool

  whether the cave is dark

#### Instances

Instances details

Show Cave Source # |
Instance details Defined in Game.LambdaHack.Server.DungeonGen.Cave Methods showsPrec :: Int -> Cave -> ShowS Source # show :: Cave -> String Source # showList :: [Cave] -> ShowS Source #

buildCave Source #

Arguments

:: COps | content definitions
-> AbsDepth | depth of the level to generate
-> AbsDepth | absolute depth
-> Area | map area of the cave
-> Word32 | 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.

# Internal operations

pickOpening :: COps -> CaveKind -> TileMapEM -> ContentId TileKind -> Word32 -> EnumMap Point (ContentId TileKind) -> (Point, (ContentId TileKind, ContentId TileKind, ContentId PlaceKind)) -> Rnd (EnumMap Point (ContentId TileKind)) Source #