home/ atoms/ conways-game-of-life-rules

Conway's Game of Life updates each cell based on neighbor count: fewer than 2 or more than 3 active neighbors → dies; exactly 3 → activates; 2 → unchanged

Conway’s Game of Life is a cellular automaton on a 2D grid. Each step, every cell examines its 8 neighbors and applies: (1) fewer than 2 active neighbors → becomes inactive (underpopulation); (2) 2 active neighbors → state unchanged; (3) exactly 3 active neighbors → becomes active (reproduction); (4) more than 3 active neighbors → becomes inactive (overpopulation). These simple rules produce emergent complexity: stable structures, oscillators, gliders, and unbounded growth. In a GPU implementation, computing neighbor counts requires grid wrap-around for edge cells and the ping-pong pattern to avoid in-place mutation.

Examples

switch activeNeighbors {
  case 2: { cellStateOut[i] = cellStateIn[i]; } // unchanged
  case 3: { cellStateOut[i] = 1; }               // become/stay active
  default: { cellStateOut[i] = 0; }              // die
}

Assessment

A cell is currently inactive and has exactly 3 active neighbors. What is its state after one step? An active cell has 2 neighbors — does it survive?

“Any cell with fewer than two neighbors becomes inactive.”
corpus · your-first-webgpu-app-google-codelab · chunk 23