API Reference › Grid › Grid.a_star
method

Grid.a_star

Grid.a_star(x0, y0, x1, y1, wall) -> []Cell

Returns the shortest path from (x0, y0) to (x1, y1) over passable (non-wall) cells, 4-connected with uniform step cost, as a Cell slice from start to goal inclusive — an A* search with a Manhattan heuristic. Empty if the goal is unreachable (or start/goal is a wall). (Named under Grid rather than Path, which is the filesystem-paths library.)

Parameters

wallthe impassable tile char, e.g. '#'

Example

program Demo {
  handler H phase Update {
    let path = Grid.a_star(1, 1, 20, 12, '#')
    if len(path) > 0 { print(len(path)) }
  }
}
← All symbols