ndarray-pathfinder
A* pathfinding through an ndarray of cost values.
Implemented by wrapping ndarray accessors around abstract-pathfinder.
Installation:
npm install --save ndarray-pathfinderUsage:
var finder = require('ndarray-pathfinder')
// array through which to pathfinding
var arr = new ndarray(new Float32Array(25), [5, 5])
// barriers
arr.set(1, 1, 100)
arr.set(2, 1, 100)
arr.set(3, 1, 100)
// start/end nodes
var start = [0, 0]
var goal = [3, 3]
// returns path as array of n-length arrays
var path = finder(arr, start, goal)
// path: [ [0,0], [0,1], ... ]Optional arguments:
var preferDiag = true
var costFcn = function(value) {
if (value < 0) return -1
return 1 + value
}
var path = finder(arr, start, goal, preferDiagonal, costFcn)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.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
