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

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Client.Bfs

Contents

Description

Breadth first search algorithm.

Synopsis

Documentation

data BfsDistance Source #

Weighted distance between points along shortest paths.

Instances
Eq BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Ord BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Show BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Bits BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

UnboxRepClass BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Associated Types

type UnboxRep BfsDistance :: Type Source #

type UnboxRep BfsDistance Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

data MoveLegal Source #

State of legality of moves between adjacent points.

Instances
Eq MoveLegal Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

minKnownBfs :: BfsDistance Source #

The minimal distance value assigned to paths that don't enter any unknown tiles.

apartBfs :: BfsDistance Source #

The distance value that denotes no legal path between points, either due to blocked tiles or pathfinding aborted at earlier tiles, e.g., due to unknown tiles.

maxBfsDistance :: BfsDistance Source #

Maximum value of the type.

fillBfs :: Array Word8 -> Word8 -> Point -> (PrimArray PointI, PrimArray PointI) -> Array BfsDistance Source #

Create and fill a BFS array for the given level. Unsafe array operations are OK here, because the intermediate values of the vector don't leak anywhere outside nor are kept unevaluated and so they can't be overwritten by the unsafe side-effect.

When computing move cost, we assume doors openable at no cost, because other actors use them, too, so the cost is shared and the extra visiblity is valuable, too. We treat unknown tiles specially. Whether suspect tiles are considered openable depends on smarkSuspect.

Instead of a BFS queue (list) we use the two tabs (arrays), for (JS) speed.

data AndPath Source #

Constructors

AndPath 
Instances
Show AndPath Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Generic AndPath Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Associated Types

type Rep AndPath :: Type -> Type #

Methods

from :: AndPath -> Rep AndPath x #

to :: Rep AndPath x -> AndPath #

Binary AndPath Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

Methods

put :: AndPath -> Put #

get :: Get AndPath #

putList :: [AndPath] -> Put #

type Rep AndPath Source # 
Instance details

Defined in Game.LambdaHack.Client.Bfs

findPathBfs :: BigActorMap -> Array Word8 -> (PointI -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> Maybe AndPath Source #

Find a path, without the source position, with the smallest length. The eps coefficient determines which direction (of the closest directions available) that path should prefer, where 0 means north-west and 1 means north. The path tries hard to avoid actors and tries to avoid tiles that need altering and ambient light. Actors are avoided only close to the start of the path, because elsewhere they are likely to move before they are reached. Even projectiles are avoided, which sometimes has the effect of choosing a safer route (regardless if the projectiles are friendly fire or not).

An unwelcome side effect of avoiding actors is that friends will sometimes avoid displacing and instead perform two separate moves, wasting 1 turn in total. But in corridors they will still displace and elsewhere this scenario was quite rare already.

accessBfs :: Array BfsDistance -> Point -> Maybe Int Source #

Access a BFS array and interpret the looked up distance value.

Internal operations

abortedUnknownBfs :: BfsDistance Source #

The distance value that denotes that path search was aborted at this tile due to too large actual distance and that the tile was unknown. It is also a true distance value for this tile.