Conway's Game of Life demonstrates emergent complexity from simple rules:
- Any live cell with 2-3 neighbors survives
- Any dead cell with exactly 3 neighbors becomes alive
- All other cells die or stay dead
Patterns
Implemented classic patterns: gliders, oscillators, still lifes, and spaceships.
function evolve(grid: boolean[][]): boolean[][] {
const next = createEmptyGrid();
for (let i = 0; i < grid.length; i++) {
for (let j = 0; j < grid[0].length; j++) {
const neighbors = countNeighbors(grid, i, j);
next[i][j] = neighbors === 3 || (grid[i][j] && neighbors === 2);
}
}
return next;
}