Module ...
Pathfinding using A*
Functions
_M:calc (sx, sy, tx, ty, use_has_seen, heuristic, add_check, forbid_diagonals) | Compute path from sx/sy to tx/ty |
_M:heuristicCloserPath (sx, sy, cx, cy, tx, ty) | The default heuristic for A*, tries to come close to the straight path |
_M:heuristicDistance (sx, sy, cx, cy, tx, ty) | The a simple heuristic for A*, using distance |
_M:init (map, actor) | Initializes Astar for a map and an actor |
Functions
- _M:calc (sx, sy, tx, ty, use_has_seen, heuristic, add_check, forbid_diagonals)
-
Compute path from sx/sy to tx/ty
Parameters
- sx: the start coord
- sy: the start coord
- tx: the end coord
- ty: the end coord
- use_has_seen: if true the astar wont consider non-has_seen grids
- heuristic:
- add_check: a function that checks each x/y coordinate and returns true if the coord is valid
- forbid_diagonals:
Return value:
either nil if no path or a list of nodes in the form { {x=...,y=...}, {x=...,y=...}, ..., {x=tx,y=ty}} - _M:heuristicCloserPath (sx, sy, cx, cy, tx, ty)
-
The default heuristic for A*, tries to come close to the straight path
Parameters
- sx:
- sy:
- cx:
- cy:
- tx:
- ty:
- _M:heuristicDistance (sx, sy, cx, cy, tx, ty)
-
The a simple heuristic for A*, using distance
Parameters
- sx:
- sy:
- cx:
- cy:
- tx:
- ty:
- _M:init (map, actor)
-
Initializes Astar for a map and an actor
Parameters
- map:
- actor: