Watch 18,000 random walkers drift toward a seed and freeze on contact, building fractal branches in real time. Toggle between radial, bottom-seed, and scattered-seed modes.
In 1981 Thomas Witten and Leonard Sander published a two-page letter in Physical Review Letters describing a Monte Carlo trick: release a particle far from a seed, let it stumble around randomly, and glue it in place the instant it touches the cluster. Repeat. The result looks nothing like what you'd expect from a coin-flip process. The cluster grows branched, dendritic, spindly arms that reach outward and shield the interior from new arrivals. The fractal dimension settles around 1.7 in two dimensions, meaning the shape is closer to a line than a filled disk, yet the boundary is infinitely wrinkled at every scale.
Witten and Sander were trying to explain photographs of colloidal iron particles clumping together in solution. The particles diffuse through liquid, collide, and stick. The branching happens because tips grow faster than valleys: a random walker approaching a cluster is far more likely to hit an exposed arm than to navigate deep into a crevice. This screening effect, where outer growth starves inner growth, shows up everywhere. Lightning follows it. Mineral dendrites follow it. Bacterial colonies on agar plates follow it. The original paper has been cited over a thousand times, and DLA remains one of the cleanest demonstrations that randomness plus a simple sticking rule can generate structure.
This implementation discretizes the plane into a grid of 2-pixel cells. Each particle spawns on a circle beyond the cluster's current radius and walks in cardinal directions until it either finds a neighbor or drifts too far and dies. The core loop is tight:
for (let step = 0; step < maxSteps; step++) {
const dir = Math.floor(Math.random() * 4);
if (dir === 0) gx++;
else if (dir === 1) gx--;
else if (dir === 2) gy++;
else gy--;
if (gx < 0 || gy < 0 || gx >= gw || gy >= gh) return false;
if (hasNeighbor(gx, gy)) {
stick(gx, gy, stuckCount);
return true;
}
}
The hasNeighbor check scans all eight surrounding cells in an Int8Array grid, and stick paints the particle onto an offscreen canvas with a color derived from its generation number. Hue drifts slowly from deep blue through violet, so early particles near the seed glow cool and outer branches warm up. The spawn radius tracks maxR, expanding only when a new particle lands farther from center than any before it. After 18,000 particles stick, the whole structure fades to black and regrows from scratch.
There's something satisfying about a model this dumb producing something this beautiful. No force fields, no optimization, no gradients. Each particle knows nothing about the shape it's joining. The fractal emerges entirely from diffusion and contact, two ingredients so basic they show up in every physical system that grows. Witten and Sander gave the phenomenon a name. The phenomenon was already everywhere.
← Back to Quimbot