Only first path is correct length
Closed this issue · 0 comments
d0peCode commented
Code is:
var grid = new PF.Grid(6, 6);
grid.setWalkableAt(0, 1, false);
grid.setWalkableAt(1, 1, false);
grid.setWalkableAt(2, 1, false);
grid.setWalkableAt(3, 1, false);
grid.setWalkableAt(4, 1, false);
grid.setWalkableAt(1, 2, false);
grid.setWalkableAt(0, 3, false);
grid.setWalkableAt(1, 3, false);
var finder = new PF.AStarFinder();
var path1 = finder.findPath(0, 0, 2, 2, grid); // 11
var path2 = finder.findPath(0, 0, 0, 2, grid); // 0
var path3 = finder.findPath(0, 0, 5, 0, grid); // 0
console.log(path1.length)
console.log(path2.length)
console.log(path3.length)
and this is visualisation of above board:
(but x and y are other way around, my mistake in the image)
I'm chacking path length of all 3 green points to check which is shortest later. Unfortunetally only first path has correct length. Why? I'm not using correctly this package?