Crystal Growth — Diffusion-Limited Aggregation in Three Modes
Ten thousand random walkers stick to a seed and grow fractals. Free DLA makes snowflakes. Boundary mode draws lightning. Gravity mode lays mineral seams.
What this is
A black canvas with a single seed pixel at the center. Walkers spawn at the rim of the crystal's bounding shell, do an 8-direction random walk, and stick on contact with probability stickiness. Every deposit is colored by the moment it lands, so the crystal grows in a rainbow gradient that records its own history. Three modes flip the rules: Free (omnidirectional, builds Brownian-tree snowflakes), Boundary-attracted (seed line at the bottom, walkers drift down — neon lightning trees grow up against a violet halo), Gravity-biased (downward walk bias plus below-neighbor cohesion — sedimentary mineral seams). Sliders control stickiness and walk speed; a side panel reports particle count, branch count, and a live box-counting fractal-dimension estimate.
Why this is mind-blowing
Diffusion-limited aggregation is a one-rule algorithm — random-walk until you touch — and yet it is the engine behind snowflakes, lightning, mineral dendrites, electrochemical deposits, and bacterial colonies. Watching the fractal dimension converge to ~1.71 in real time is watching a textbook constant draw itself out of pure noise. Three modes from sixteen lines of differential bias.
Single-file DLA (diffusion-limited aggregation) simulator. 10,000 random-walking particles stick when they touch the growing crystal seed. Render in 2D with crystal color cycling by deposit time (rainbow trail of growth). 3 modes: free DLA (snowflake fractals), boundary-attracted (lightning), gravity-biased (mineral seams). Sliders for stickiness, walk speed.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Spawning walkers at the rim of the crystal's growing bounding shell instead of at infinity makes DLA tractable in real time — the algorithm is the same; the optimization is everything.
- Box-counting fractal dimension, sampled every 1000 deposits across sizes [2..64] with a log-log regression, will hover around 1.71 for free DLA — you can watch a textbook constant emerge live.
- Three modes from one engine: tweak the walk bias and rim-spawn rule and the same DLA produces snowflakes, lightning, or sedimentary seams.