ExCollision.Pathfinding.AStar (ExCollision v1.1.0)

View Source

A* pathfinding over tilemap. Uses ExCollision.Protocols.TileSource for walkability. Coordinates are tile indices (column, row) or {x, y} in tiles.

Summary

Functions

Finds path from start to goal over the tilemap.

Checks whether a point on the tilemap is walkable.

Functions

find_path(source, start, goal, opts \\ [])

@spec find_path(
  ExCollision.Protocols.TileSource.t(),
  {integer(), integer()},
  {integer(), integer()},
  keyword()
) :: {:ok, [{integer(), integer()}]} | {:error, :unreachable}

Finds path from start to goal over the tilemap.

start, goal — {tile_x, tile_y} (tile indices). Returns {:ok, [ {x, y}, ... ]} or {:error, :unreachable}.

Options:

  • :allow_diagonal — allow diagonal movement (8 directions). Default false (4 directions only).

walkable_at?(source, arg)

Checks whether a point on the tilemap is walkable.