# `Cauldron2D.Grid.Path`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d/lib/cauldron_2d/grid/path.ex#L1)

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. Default `false`
  * `:neighbours` — `:four` or `:eight`. Default `:four`
  * `:limit` — how many cells may be expanded before giving up. Default `10_000`
  * `:cost` — `astar/4` only: a function from a cell to the cost of stepping into it,
    a positive number. Default `1` everywhere

# `cell`

```elixir
@type cell() :: {integer(), integer()}
```

# `passable`

```elixir
@type passable() :: (cell() -&gt; boolean())
```

# `astar`

```elixir
@spec astar(passable(), cell(), cell(), keyword()) :: {:ok, [cell()]} | :none
```

The cheapest way, by `:cost`, guided by the distance still to go.

# `find`

```elixir
@spec find(passable(), cell(), cell(), keyword()) :: {:ok, [cell()]} | :none
```

The way with the fewest steps.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
