prepare scanning neighbors

This commit is contained in:
Baipyrus 2024-01-27 23:53:01 +01:00
parent 32ee792157
commit 4b61a2ed24

View File

@ -33,6 +33,18 @@ while (open.length > 0) {
const current = open.splice(record.index, 1)[0];
closed.push(current);
if (current === end) break;
for (let j = -1; j < 2; j++)
for (let i = -1; i < 2; i++) {
if (!(i === 0 ^ j === 0)) continue;
const nx = current.x + i;
const ny = current.y + j;
if (!input[ny]) continue;
const next = input[ny][nx];
if (!next || closed.includes(next)) continue;
}
}
console.log(end.g);