/** * @class Simplified A* algorithm: all edges have a value of 1 * @augments ROT.Path * @see ROT.Path */ ROT.Path.AStar = function(toX, toY, passableCallback, options) { ROT.Path.call(this, toX, toY, passableCallback, options); this._todo = []; this._done = {}; this._fromX = null; this._fromY = null; } ROT.Path.AStar.extend(ROT.Path); /** * Compute a path from a given point * @see ROT.Path#compute */ ROT.Path.AStar.prototype.compute = function(fromX, fromY, callback) { this._todo = []; this._done = {}; this._fromX = fromX; this._fromY = fromY; this._add(this._toX, this._toY, null); while (this._todo.length) { var item = this._todo.shift(); if (item.x == fromX && item.y == fromY) { break; } var neighbors = this._getNeighbors(item.x, item.y); for (var i=0;i