PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

Example not working

Open abhijeet-pandey opened this issue 6 years ago • 1 comments

The first example in the documentation with walkability matrix does not seem to work. var walkabilityMatrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]];

var grid = new PF.Grid(walkabilityMatrix); // typo here in the original documentation - matrix instead of walkabilityMatric var finder = new PF.AStarFinder(); var path = finder.findPath(0, 0, 4, 6, grid);

Produces the following error: TypeError: this.nodes[e] is undefined

abhijeet-pandey avatar Sep 01 '19 12:09 abhijeet-pandey

I'd say this is a duplicate of #132.

I guess you just downloaded the pathfinding-browser.min.js and/or you run your code in the visual demo .

That version of Pathfinding.js is outdated, it does not detect the Grid width/height automatically. The documentation is for the latest version that you can build yourself using npm.

brean avatar Sep 01 '19 13:09 brean