mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-14 09:43:49 +00:00
a* neighbor calculations
This commit is contained in:
parent
4b61a2ed24
commit
14c6eec96f
@ -44,6 +44,17 @@ while (open.length > 0) {
|
||||
if (!input[ny]) continue;
|
||||
const next = input[ny][nx];
|
||||
if (!next || closed.includes(next)) continue;
|
||||
|
||||
const nd = current.g + next.c;
|
||||
if (open.includes(next)) {
|
||||
if (nd < next.g)
|
||||
next.g = nd;
|
||||
continue;
|
||||
}
|
||||
|
||||
next.g = nd;
|
||||
next.h = man_dist(next, end);
|
||||
open.push(next);
|
||||
}
|
||||
}
|
||||
console.log(end.g);
|
||||
|
Loading…
Reference in New Issue
Block a user