Diffusion-Limited Aggregation

初出 1981 · Thomas Witten、Leonard Sander — Diffusion-limited aggregation — Witten & Sander (1981). · 年表 ↗

発明者による命名 名称 · 命名 Thomas Witten、Leonard Sander (1981) — 発明者による記述的命名。Witten & Sander が 1981 年に「diffusion-limited aggregation」と命名。

ひとことで ランダムウォークする粒子が成長中の構造に到達すると凝集する、フラクタル状の樹枝状パターン生成。

Diffusion-Limited Aggregation · Open in new tab ↗ · Motion begins only when you press Run.

コード

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

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

// Diffusion-Limited Aggregation on a square lattice. A single seed sits at
// the centre; random walkers spawn on a circle just outside the cluster and
// stick the moment they touch it. The build accumulates frame by frame, so
// the canvas is never cleared after setup.
const G = 200;          // lattice resolution
const MAX = 8000;       // particles before stopping
let occ;                // occupancy grid (0 = empty)
let s, cell, cx, cy;
let R = 3;              // current cluster radius, in cells
let attached = 1;

function idx(x, y) { return y * G + x; }

function setup() {
  randomSeed(SEED);
  s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  background(8, 8, 12);
  pixelDensity(1);
  noStroke();
  colorMode(HSB, 360, 100, 100);

  cell = s / G;
  cx = G >> 1;
  cy = G >> 1;
  occ = new Uint8Array(G * G);
  occ[idx(cx, cy)] = 1;   // central seed
}

function draw() {
  const WALKERS = 300;
  for (let n = 0; n < WALKERS && attached < MAX; n++) {
    const spawnR = Math.min(G * 0.49, R + 5);
    const a = random(TWO_PI);
    let x = Math.round(cx + spawnR * Math.cos(a));
    let y = Math.round(cy + spawnR * Math.sin(a));
    const killR = spawnR + 8;
    const killR2 = killR * killR;

    for (let step = 0; step < 4000; step++) {
      const d = Math.floor(random(4));
      if (d === 0) x++; else if (d === 1) x--; else if (d === 2) y++; else y--;
      if (x < 1 || y < 1 || x >= G - 1 || y >= G - 1) break;   // off lattice

      const dx = x - cx, dy = y - cy;
      if (dx * dx + dy * dy > killR2) break;                    // wandered off

      if (occ[idx(x + 1, y)] || occ[idx(x - 1, y)] ||
          occ[idx(x, y + 1)] || occ[idx(x, y - 1)]) {
        occ[idx(x, y)] = 1;
        attached++;
        const r = Math.sqrt(dx * dx + dy * dy);
        if (r + 2 > R) R = r + 2;
        // hue ramps with distance from the seed: warm core → cool tips
        const t = Math.min(1, r / (G * 0.5));
        fill((30 + t * 260) % 360, 70, 100);
        rect(x * cell, y * cell, cell + 0.6, cell + 0.6);
        break;
      }
    }
  }
  if (attached >= MAX) noLoop();
}

デモのソースを開く ↗

仕組み

1 個以上の種粒子を固定したクラスタから始め、(1) 遠方からランダムウォークする粒子を放ち、(2) 一歩ずつブラウン運動させ、(3) クラスタ粒子に隣接(接触)したらその場で固着させてクラスタに加える、(4) 遠くへ離れすぎたら破棄して新しい粒子を放つ、を繰り返す。先端ほど到来粒子に先に当たり内部を遮蔽するため、成長は末端に集中し、自己相似な樹枝状フラクタル(2D でフラクタル次元 ≈ 1.71)が生まれる。

パラメータ

系譜

関連
Reaction-Diffusion、Particle System

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

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

Axo
jiwa
Masonry
eric-davidson
Mycelia
jmy

最終更新 2026-07-16