You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Определяем координаты входа и выхода из лабиринта
const startx = 5;
const starty = 2;
const exitx = 7
const exity = 9;
var width = 9;
var height = 9;
var grid = new PF.Grid(width, height);
for (var i = 0; i < lab.length; i++) {
for (var j = 0; j < lab[i].length; j++) {
if (lab[i][j]=="1") {
grid.setWalkableAt(j, i, false);
}
else{
grid.setWalkableAt(j, i, true);
};
}
}
console.log(grid);
var finder = new PF.AStarFinder();
37 line) var path = finder.findPath(startx, starty, exitx, exity, grid);
Uncaught TypeError: Cannot read properties of undefined (reading '7')
at r.getNodeAt (pathfinding-browser.min.js:1:4349)
at r.findPath (pathfinding-browser.min.js:1:7595)
at js.js:37:19
have such problem
How can I decide it?
Leave a code:
const lab = [
["1", "1", "1", "1", "1", "1", "1", "1", "1"],
["1", "1", "1", "1", "0", "1", "1", "1", "1"],
["1", "1", "0", "0", "0", "1", "1", "1", "1"],
["1", "1", "0", "1", "0", "1", "1", "1", "1"],
["1", "1", "1", "0", "0", "0", "0", "0", "1"],
["1", "1", "1", "1", "0", "1", "1", "1", "1"],
["1", "1", "1", "1", "0", "1", "1", "0", "1"],
["1", "1", "0", "0", "0", "0", "0", "0", "1"],
["1", "1", "1", "1", "1", "1", "0", "1", "1"]
];
// Определяем координаты входа и выхода из лабиринта
const startx = 5;
const starty = 2;
const exitx = 7
const exity = 9;
var width = 9;
var height = 9;
var grid = new PF.Grid(width, height);
for (var i = 0; i < lab.length; i++) {
for (var j = 0; j < lab[i].length; j++) {
if (lab[i][j]=="1") {
grid.setWalkableAt(j, i, false);
}
else{
grid.setWalkableAt(j, i, true);
};
}
}
console.log(grid);
var finder = new PF.AStarFinder();
37 line) var path = finder.findPath(startx, starty, exitx, exity, grid);
document.getElementById("decider").innerHTML = path;
The text was updated successfully, but these errors were encountered: