PathFinding.js
PathFinding.js copied to clipboard
Bug with matrix
This code return error (Mozilla Firefox and Chrome)
var matrix = [
[0, 0, 0, 1, 0],
[1, 0, 0, 0, 1],
[0, 0, 1, 0, 0]
];
var grid = new PF.Grid(matrix);
var finder = new PF.AStarFinder({
allowDiagonal: true
});
var path = finder.findPath(1, 2, 4, 2, grid);
TypeError: this.nodes[e] is undefined ...s},r.prototype.getNodeAt=function(t,e){return this.nodes[e][t]},r.prototype.isWa... pathfin....min.js (string 1, 4329)
Example in codepen http://codepen.io/kirillpopov/pen/dXBbxL
Thats not an error the 1st dimension in the matrix is height, the 2nd dimension is width.
After this very vague response, i have debugged the issue to the new method of the Grid.
var grid = new PF.Grid(matrix);
it should actually be
var grid = new PF.Grid(width,height,grid);