Safe Haskell | None |
---|---|
Language | Haskell2010 |
Game.LambdaHack.Client.Bfs
Contents
Description
Breadth first search algorithms.
- data BfsDistance
- data MoveLegal
- minKnownBfs :: BfsDistance
- apartBfs :: BfsDistance
- fillBfs :: Array Word8 -> Word8 -> Point -> Array BfsDistance -> ()
- data AndPath
- findPathBfs :: Array Word8 -> (Point -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> AndPath
- accessBfs :: Array BfsDistance -> Point -> Maybe Int
Documentation
State of legality of moves between adjacent points.
Constructors
MoveBlocked | |
MoveToOpen | |
MoveToClosed | |
MoveToUnknown |
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.
Arguments
:: Array Word8 | |
-> Word8 | |
-> Point | starting position |
-> Array BfsDistance | initial array, with |
-> () |
Fill out the given BFS array.
Unsafe PointArray
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
.
findPathBfs :: Array Word8 -> (Point -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> 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.
accessBfs :: Array BfsDistance -> Point -> Maybe Int Source #
Access a BFS array and interpret the looked up distance value.