Safe Haskell | None |
---|---|

Language | Haskell2010 |

Breadth first search algorithms.

- data BfsDistance
- data MoveLegal
- apartBfs :: BfsDistance
- fillBfs :: (Point -> Point -> MoveLegal) -> (Point -> Point -> Bool) -> Point -> Array BfsDistance -> Array BfsDistance
- findPathBfs :: (Point -> Point -> MoveLegal) -> (Point -> Point -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> Maybe [Point]
- accessBfs :: Array BfsDistance -> Point -> Maybe Int
- minKnownBfs :: BfsDistance

# Documentation

data BfsDistance Source

Weighted distance between points along shortest paths.

State of legality of moves between adjacent points.

apartBfs :: BfsDistance Source

The distance value that denote no legal path between points. The next value is the minimal distance value assigned to paths that don't enter any unknown tiles.

:: (Point -> Point -> MoveLegal) | is a move from known tile legal |

-> (Point -> Point -> Bool) | is a move from unknown legal |

-> Point | starting position |

-> Array BfsDistance | initial array, with |

-> Array BfsDistance | array with calculated distances |

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.

findPathBfs :: (Point -> Point -> MoveLegal) -> (Point -> Point -> Bool) -> Point -> Point -> Int -> Array BfsDistance -> Maybe [Point] Source

Find a path, without the source position, with the smallest length.
The `eps`

coefficient determines which direction (or 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.

# Internal operations

minKnownBfs :: BfsDistance Source

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