ndarray-pathfinder
A* pathfinding through an ndarray of cost values.
Implemented by wrapping ndarray accessors around abstract-pathfinder.
Installation:
npm install --save ndarray-pathfinder
Usage:
var finder = // array through which to pathfindingvar arr = 25 5 5 // barriersarrarrarr // start/end nodesvar start = 0 0var goal = 3 3 // returns path as array of n-length arraysvar path = // path: [ [0,0], [0,1], ... ]
Optional arguments:
var preferDiag = truevar { if value < 0 return -1 return 1 + value}var path =
preferDiagonal
- a flag that adds a small term to the heuristic to prefer cells closer the goalcostFunction
- a function to convert ndarray values to movement costs
Notes:
- Orthogonal (l1) moves only for now
- Should work in any dimension (2D or above)
By:
Andy Hall. MIT license.