1.0.1 • Published 3 years ago
astar-template v1.0.1
astar (a*) path finder
npm install astar-template
const PathFinder = require('astar-template')
let finder = new PathFinder();
finder.debug = function (node) {}
......
let apath = finder.astar(fromNode, toNode);
if(apath.length=0) { //cannot arrive } else { //apath is array of nodes }
must implement your:
function finder.debug(node);
function finder.isSameNode(m,n);
function finder.calcH(curNode,toNode);
function finder.listNeighborNode(node);
function finder.mapcheck(node);
define Node, must with field parent, g, h
class ABCNode {
constructor(a=null, b=null, c=null, src=null) {
this.parent = src;
this.a = a;
this.b = b;
this.c = c;
this.g = 0;
this.h = 0;
}
}
class XYNode {
constructor(x=null, y=null, src=null) {
this.parent = src;
this.x = x;
this.y = y;
this.g = 0;
this.h = 0;
}
}