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

A tile grid in blocks, for finding a way when the tiles are many: a block is passable
when every tile in it is open, and a path is a run of block centres.

    coarse = Cauldron2D.Grid.Coarse.new(grid, {width, height}, block: 2, wrap?: true)
    {:ok, path} = Cauldron2D.Grid.Coarse.find(coarse, me.pos, enemy.pos)
    goal = Cauldron2D.Grid.Coarse.waypoint(grid, me.pos, path)

`grid` is the function `Cauldron2D.Collision` takes, a tile coordinate to `:open`,
`:solid` or a half tile. A point in a block that is not passable — on a base, in a
pocket — starts from, or is sought at, the nearest passable block within two of it.

# `t`

```elixir
@type t() :: %Cauldron2D.Grid.Coarse{
  block: pos_integer(),
  height: pos_integer(),
  passable: MapSet.t({integer(), integer()}),
  width: pos_integer(),
  wrap?: boolean()
}
```

# `block_of`

```elixir
@spec block_of(t(), {number(), number()}) :: {integer(), integer()}
```

The block the tile at `point` is in.

# `centre`

```elixir
@spec centre(t(), {integer(), integer()}) :: {float(), float()}
```

The tile position at the centre of a block.

# `find`

```elixir
@spec find(t(), {number(), number()}, {number(), number()}, pos_integer()) ::
  {:ok, [{float(), float()}]} | :none
```

The path from `from` to `to` as block centres, or `:none` when there is none within `limit` blocks.

# `new`

```elixir
@spec new(Cauldron2D.Collision.grid(), {pos_integer(), pos_integer()}, keyword()) ::
  t()
```

The coarse map of `grid`, `size` tiles across and down; options `:block`, tiles to a block (default 2), and `:wrap?` (default false).

# `passable?`

```elixir
@spec passable?(t(), {number(), number()}) :: boolean()
```

Whether the block holding the tile at `point` is passable.

# `waypoint`

```elixir
@spec waypoint(Cauldron2D.Collision.grid(), {number(), number()}, [{float(), float()}]) ::
  {float(), float()}
```

The point of `path` to make for from `from`: the furthest in a clear straight line on `grid`, else the first.

---

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