FRENAR
N°05 · Canvas 2D · Generative

Cellular Automaton

Trivial rules, staggering complexity. Conway's Game of Life — click to draw, watch the patterns evolve.

click/drag to draw · space to pause
// Automate cellulaire — Game of Life (Conway 1970)
function step(grid, cols, rows) {
  const next = new Uint8Array(cols * rows);
  for (let y = 0; y < rows; y++) {
    for (let x = 0; x < cols; x++) {
      let n = 0; // compter les voisins vivants
      for (let dy = -1; dy <= 1; dy++)
        for (let dx = -1; dx <= 1; dx++)
          if (dx || dy)
            n += grid[((y+dy+rows)%rows)*cols + (x+dx+cols)%cols];
      const alive = grid[y * cols + x];
      // B3/S23 : naissance si 3 voisins, survie si 2 ou 3
      next[y * cols + x] = (alive && (n===2||n===3)) || (!alive && n===3) ? 1 : 0;
    }
  }
  return next;
}
Your turn

Draw a glider (the classic 5-cell pattern). Can you create an oscillator that loops forever? What happens when two gliders collide?

From simple rules to complex systems — explore emergence

Book a session