step = (map) => {
const next = new d3.InternMap([], JSON.stringify);
next.flashed = new d3.InternSet([], JSON.stringify);
for (const [[x, y], e] of map.entries()) next.set([x, y], e + 1);
let toFlash = new d3.InternSet(
d3.filter(next.keys(), (p) => next.get(p) > 9),
JSON.stringify
);
while (toFlash.size) {
const changed = new d3.InternSet([], JSON.stringify);
for (const p of toFlash) {
next.flashed.add(p);
for (const n of neighbors(p)) {
next.set(n, next.get(n) + 1);
changed.add(n);
}
}
toFlash = new d3.InternSet(
d3.filter(changed, (p) => !next.flashed.has(p) && next.get(p) > 9),
JSON.stringify
);
}
for (const p of next.flashed) next.set(p, 0);
return next;
}