UNPKG

pathfinding

Version:

Comprehensive pathfinding library for grid based games

29 lines (24 loc) 957 B
var AStarFinder = require('./AStarFinder'); /** * Best-First-Search path-finder. * @constructor * @extends AStarFinder * @param {Object} opt * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed. * Deprecated, use diagonalMovement instead. * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching * block corners. Deprecated, use diagonalMovement instead. * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement. * @param {function} opt.heuristic Heuristic function to estimate the distance * (defaults to manhattan). */ function BestFirstFinder(opt) { AStarFinder.call(this, opt); var orig = this.heuristic; this.heuristic = function(dx, dy) { return orig(dx, dy) * 1000000; }; } BestFirstFinder.prototype = new AStarFinder(); BestFirstFinder.prototype.constructor = BestFirstFinder; module.exports = BestFirstFinder;