UNPKG

pathfinding-es

Version:

Comprehensive pathfinding library for grid based games

27 lines (22 loc) 897 B
import AStarFinder from './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); const orig = this.heuristic; this.heuristic = (dx, dy) => orig(dx, dy) * 1000000; } BestFirstFinder.prototype = new AStarFinder(); BestFirstFinder.prototype.constructor = BestFirstFinder; export default BestFirstFinder;