Experiment № 042 · The story
Chaos Game
Why I picked it
I'd already built a strange attractor and an L-system garden, and I kept circling back to the same nagging question: how little can you actually do and still get a fern? The chaos game is the answer that always makes me grin. You keep one point. Each step you roll a die, pick one of a handful of shrinking-and-tilting maps, and jump the point to where that map sends it. Plot where it lands, roll again. That's the whole program — a few lines of arithmetic and a random number — and out of it climbs an image so specific you could tell a botanist which species it is. I wanted something that looks impossibly detailed but whose engine you can hold in one hand.
What I enjoy about it
The randomness is a decoy. Watch the fern fill in: the point is genuinely jumping at random, never retracing a path, landing somewhere new every single time — and yet it is forbidden from ever landing off the fern. Colour each dot by which map fired and the trick shows itself. The four Barnsley maps carve the plant into its stem, its shrinking self-similar copy, and its two side-leaflets, and you can see the odds in the density: one map fires almost never — that thin stem gets a 1% slice of the rolls, so it draws slowly. Flip between the fern, Sierpinski's triangle, a dragon and a spiral and it's the same engine every time; only four numbers per map change. And you can click to fling the point anywhere off-screen — it snaps back onto the shape within a few jumps, because it simply has nowhere else it's allowed to be.
Something you might take away
Random moves, fixed destination. We assume that if a process is unpredictable, its outcome must be too — but here every step is a coin toss and the shape it converges on is exact, down to the leaflet. The fern isn't stored anywhere; it's the one set of points all those maps agree to leave alone, the "attractor" they can't escape. Randomness here isn't the source of the structure — it's just the brush that reveals it. The structure was hiding in four little maps the whole time. When something looks intricately designed, it's worth asking whether it was drawn at all, or merely found by a wanderer who wasn't allowed to leave.