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.AreaRnd

Contents

- Picking points inside areas
- Choosing connections
- Plotting corridors
- Internal operations

Description

Operations on the `Area` type that involve random numbers.

Synopsis

- mkFixed :: (X, Y) -> Area -> Point -> Area
- pointInArea :: Area -> Rnd Point
- findPointInArea :: Area -> (Point -> Maybe Point) -> Int -> (Point -> Maybe Point) -> Rnd (Maybe Point)
- mkVoidRoom :: Area -> Rnd Area
- mkRoom :: (X, Y) -> (X, Y) -> Area -> Rnd Area
- connectGrid :: EnumSet Point -> (X, Y) -> Rnd [(Point, Point)]
- randomConnection :: (X, Y) -> Rnd (Point, Point)
- data HV
  - = Horiz
  - | Vert
- type Corridor = (Point, Point, Point, Point)
- connectPlaces :: (Area, Fence, Area) -> (Area, Fence, Area) -> Rnd (Maybe Corridor)
- data SpecialArea
  - = SpecialArea Area
  - | SpecialFixed Point (Freqs PlaceKind) Area
  - | SpecialMerged SpecialArea Point
- grid :: EnumMap Point (Freqs PlaceKind) -> [Point] -> Area -> (X, Y) -> ((X, Y), EnumMap Point SpecialArea)
- connectGrid' :: EnumSet Point -> (X, Y) -> EnumSet Point -> EnumSet Point -> [(Point, Point)] -> Rnd [(Point, Point)]
- sortPoint :: (Point, Point) -> (Point, Point)
- mkCorridor :: HV -> Point -> Bool -> Point -> Bool -> Area -> Rnd Corridor
- borderPlace :: Area -> Fence -> (Area, Area, Bool)

# Picking points inside areas

mkFixed Source #

Arguments

:: (X, Y) | maximum size
-> Area | the containing area, not the room itself
-> Point | the center point
-> Area |

pointInArea :: Area -> Rnd Point Source #

Pick a random point within an area.

findPointInArea :: Area -> (Point -> Maybe Point) -> Int -> (Point -> Maybe Point) -> Rnd (Maybe Point) Source #

Find a suitable position in the area, based on random points and a preference predicate and fallback acceptability predicate.

mkVoidRoom :: Area -> Rnd Area Source #

Create a void room, i.e., a single point area within the designated area.

mkRoom Source #

Arguments

:: (X, Y) | minimum size
-> (X, Y) | maximum size
-> Area | the containing area, not the room itself
-> Rnd Area |

Create a random room according to given parameters.

# Choosing connections

connectGrid :: EnumSet Point -> (X, Y) -> Rnd [(Point, Point)] Source #

Pick a subset of connections between adjacent areas within a grid until there is only one connected component in the graph of all areas.

randomConnection :: (X, Y) -> Rnd (Point, Point) Source #

Pick a single random connection between adjacent areas within a grid.

# Plotting corridors

data HV Source #

The choice of horizontal and vertical orientation.

Constructors

Horiz |
Vert |

#### Instances

Instances details

Eq HV Source # |
Instance details Defined in Game.LambdaHack.Server.DungeonGen.AreaRnd Methods (==) :: HV -> HV -> Bool Source # (/=) :: HV -> HV -> Bool Source #

type Corridor = (Point, Point, Point, Point) Source #

The coordinates of consecutive fields of a corridor.

connectPlaces :: (Area, Fence, Area) -> (Area, Fence, Area) -> Rnd (Maybe Corridor) Source #

Try to connect two interiors of places with a corridor. Choose entrances some steps away from the edges, if the place is big enough. Note that with `pfence == FNone`, the inner area considered is the strict interior of the place, without the outermost tiles.

The corridor connects (touches) the inner areas and the turning point of the corridor (if any) is outside of the outer areas and inside the grid areas.

data SpecialArea Source #

Constructors

SpecialArea Area |
SpecialFixed Point (Freqs PlaceKind) Area |
SpecialMerged SpecialArea Point |

#### Instances

Instances details

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

grid :: EnumMap Point (Freqs PlaceKind) -> [Point] -> Area -> (X, Y) -> ((X, Y), EnumMap Point SpecialArea) Source #

Divide uniformly a larger area into the given number of smaller areas overlapping at the edges.

The list of fixed centers (some important points inside) of (non-overlapping) areas is given. Incorporate those, with as little disruption, as possible. Assume each of four boundaries of the cave are covered by a fixed centre.

# Internal operations

connectGrid' :: EnumSet Point -> (X, Y) -> EnumSet Point -> EnumSet Point -> [(Point, Point)] -> Rnd [(Point, Point)] Source #

sortPoint :: (Point, Point) -> (Point, Point) Source #

Sort the sequence of two points, in the derived lexicographic order.

mkCorridor Source #

Arguments

:: HV | orientation of the starting section
-> Point | starting point
-> Bool | starting is inside `FGround` or `FFloor`
-> Point | ending point
-> Bool | ending is inside `FGround` or `FFloor`
-> Area | the area containing the intermediate point
-> Rnd Corridor | straight sections of the corridor

Create a corridor, either horizontal or vertical, with a possible intermediate part that is in the opposite direction. There might not always exist a good intermediate point if the places are allowed to be close together and then we let the intermediate part degenerate.

borderPlace :: Area -> Fence -> (Area, Area, Bool) Source #