Cellular Automata

初出 1970 · John Conway — Conway's Game of Life (1970); roots in von Neumann & Ulam, 1940s; Wolfram, 1983. · 年表 ↗

コミュニティ・通称 名称 — von Neumann / Ulam の研究(1940年代)由来の記述的用語。Conway の Game of Life(1970) が最も有名な実例。人名エポニムではない。

ひとことで 離散グリッド上の各セルが近傍状態に基づいて時間発展する系。Game of Life・Elementary CA・反応拡散の前駆体など。

Cellular Automata · Open in new tab ↗ · Motion begins only when you press Run.

コード

上のデモの実際のスケッチ(サンドボックスで再現可能)。これで全部です。

cellular-automata/index.html
const SEED = Math.floor(Math.random()*1e9);

// Conway's Game of Life. Live cells are coloured by "age" (how many
// consecutive steps they've been alive) for visual depth.
let cols, rows, cell, grid, age;

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  cell = Math.max(4, Math.floor(s / 110));
  cols = Math.floor(width / cell);
  rows = Math.floor(height / cell);
  grid = new Uint8Array(cols * rows);
  age = new Uint16Array(cols * rows);
  for (let i = 0; i < grid.length; i++) grid[i] = random() < 0.32 ? 1 : 0;
  colorMode(HSB, 360, 100, 100);
  noStroke();
  frameRate(14);
}

function draw() {
  background(0, 0, 6);
  const next = new Uint8Array(cols * rows);
  for (let y = 0; y < rows; y++) {
    for (let x = 0; x < cols; x++) {
      let n = 0;
      for (let dy = -1; dy <= 1; dy++)
        for (let dx = -1; dx <= 1; dx++) {
          if (dx === 0 && dy === 0) continue;
          const nx = (x + dx + cols) % cols;
          const ny = (y + dy + rows) % rows;
          n += grid[ny * cols + nx];
        }
      const idx = y * cols + x;
      const alive = grid[idx] ? (n === 2 || n === 3) : (n === 3);
      next[idx] = alive ? 1 : 0;
      age[idx] = alive ? Math.min(255, age[idx] + 1) : 0;
      if (alive) {
        const a = age[idx];
        fill((200 + a * 2) % 360, 70, 95);
        rect(x * cell, y * cell, cell - 1, cell - 1);
      }
    }
  }
  grid = next;

  // Reseed a patch occasionally to keep it lively.
  if (frameCount % 240 === 0) {
    for (let k = 0; k < 200; k++) {
      const i = Math.floor(random(grid.length));
      grid[i] = 1;
    }
  }
}

デモのソースを開く ↗

仕組み

セルのグリッド・有限の状態集合・近傍(8 近傍=Moore、4 近傍=von Neumann など)・遷移規則を定義し、同期更新を繰り返す:(1) 各セルで自分と近傍の現状態を読み、(2) 規則で次状態を求め、(3) 全更新を同時適用(同ステップ内で近傍に影響しないよう別バッファを使う)。Conway のライフは誕生/生存数(B3/S23)、1次元 Elementary CA は 3 セル 8 通りの近傍を 8 ビットの「規則番号」(Rule 30、Rule 110 など)に対応づける。単純な規則でもカオス的・チューリング完全になりうる。

パラメータ

系譜

先行例
John Conway
関連
Reaction-Diffusion、Wave Function Collapse、10 PRINT、Truchet Tiles

よく組み合わされるアルゴリズム

このアルゴリズムを使う作品 (15)

Abstraction
hevey
Bomb
scott-draves
Calculating the Universe
troika
Dive
rafael-rozendaal
Gen 3
dca
Mental pathways
fabianospeziari-x-donnoh
mono no aware
ixnayokay
Patterns of Life
vamoss
Pre-Process
casey-reas
Rain Blooms
kazuhiro-tanimoto
Rechnender Raum
ralf-baecker
RGB Elementary Cellular Automaton
ciphrd
Rule 110
raven-kwok
Swimming Pool
paul-brown
Zoologic
ixnayokay

参考文献

最終更新 2026-07-16