Ways across a tile grid: breadth-first for the fewest steps, A* for the cheapest.
{:ok, path} = Cauldron2D.Grid.Path.find(&open?/1, {0, 0}, {5, 2}, size: {6, 5})
{:ok, path} = Cauldron2D.Grid.Path.astar(&open?/1, {0, 0}, {5, 2}, size: {6, 5}, cost: &terrain/1)The grid is a function from a cell {x, y} to whether it can be walked. A path is the
cells from the first step to the goal, the start left out; the same cell as start and
goal is []. :none is no way within the limit.
Options
:size—{width, height}of the grid in cells. Required:wrap?— whether the edges join. Defaultfalse:neighbours—:fouror:eight. Default:four:limit— how many cells may be expanded before giving up. Default10_000:cost—astar/4only: a function from a cell to the cost of stepping into it, a positive number. Default1everywhere
Summary
Functions
The cheapest way, by :cost, guided by the distance still to go.
The way with the fewest steps.
Types
Functions
The cheapest way, by :cost, guided by the distance still to go.
The way with the fewest steps.