Task 2 of 5
In 1970 John Conway picked the simplest rules he could find that make a world worth watching. Birth: a dead cell with exactly 3 live neighbors comes alive. Survival: a live cell with 2 or 3 neighbors stays alive. Everything else — lonely or overcrowded — dies. That's the whole game (the notation is B3/S23).
There's a classic bug in CPU implementations: update the grid in place and
cells start reading half-new, half-old neighbors. A kernel is immune by construction —
every thread reads the old world argument and writes into a brand-new output.
The double buffer isn't a technique here; it's what a kernel is.
1 exactly when count === 31 exactly when count === 2 || count === 30Declare let next = 0;, flip it to 1 in the cases
that live, and return next; once at the end. Two ifs cover
the whole rulebook.
if (self === 1 && (count === 2 || count === 3)) next = 1;
if (self === 0 && count === 3) next = 1;d_old/d_new device
pointers and trade them every launch.
This page is an interactive exercise — the editor, the GPU runner and your saved progress need JavaScript. The text above is the full brief.