Task 3 of 5
One tick is a snapshot; a world is a movie. A kernel has no memory of the previous
frame — time lives in JavaScript. The result of a 2D kernel is an array of
rows, which is exactly the shape the kernel accepts as input, so
current = await step(current) is the whole time machine: output becomes input,
forever.
Your test subject is the R-pentomino — five innocent-looking cells that erupt into chaos (on an infinite grid they don't settle down for 1,103 generations; Conway's group tracked it by hand). You'll run six generations and log the population after each, so you can watch the explosion begin.
'gen ' + g + ': ' + alive + ' alive' after every step.current = await step(current)'gen ' + g + ': ' + alive + ' alive', g from 1 to 6let current = world; then
for (let g = 1; g <= 6; g++) {
current = await step(current);
// …
}
No copying, no bookkeeping — the kernel's output is already a valid input.
Inside the loop, after stepping: let alive = 0; and two nested
loops adding current[y][x]. Cells are 0 or 1, so the sum is the
population.
for loop, and a Metal app encodes one
compute dispatch per frame — the GPU computes each tick, but the CPU decides that time
passes.
This page is an interactive exercise — the editor, the GPU runner and your saved progress need JavaScript. The text above is the full brief.