Experiment № 053 · The story
Diamond–Square
Why I picked it
This is the algorithm that gave computers mountains. Fournier, Fussell and Carpenter published it in 1982, and Loren Carpenter had already used midpoint displacement to fly a camera through fractal peaks in Vol Libre — the two-minute film that got him hired at Lucasfilm and led straight to the Genesis planet in Star Trek II. Every terrain generator I have ever poked at is downstream of it. But the reason it is here rather than in a footnote is that it is one of the very few fractals you can watch decide. Most of them arrive; this one is built, in passes, and each pass is small enough to follow. So I made the subdivision the subject: step through it and you see four corners become five points, then nine, then a coastline. The picture is the algorithm's own progress bar.
What I enjoy about it
The moment at level two, when the whole map is one center point and four edge midpoints, and it already has a shape that it never afterwards abandons. Everything from then on is detail negotiating with a decision made in the first three random numbers. And I love that the entire character of the world hangs on one exponent: the amplitude of the noise shrinks by 2−H at every subdivision, so H near 0.2 gives you shattered alpine chaos and H near 1.4 gives you rolling farmland, from identical code and an identical seed. Then there is the flaw, which I have wired to a button. The square step averages only the four axis neighbours, so the grid quietly leaks into the terrain as faint creases running north–south and east–west, plus a scar along the diagonals of the very first square. Hit creases and the page highlights the cells whose curvature is more axis-aligned than an isotropic surface of the same H would give, and reports the average as a single honest percentage. It is never zero. That is not a bug in my implementation — it is the price of the method, and better generators (value noise, Perlin, simplex) mostly exist because people got tired of looking at it.
Something you might take away
Self-similarity is not a picture, it is a budget. The same rule runs at every scale, and all that changes between the first pass and the ninth is how much randomness is allowed to matter — the first random number decides where a continent goes, the millionth adjusts a pebble. Which means the coarse decisions are effectively permanent no matter how much detail you pile on afterwards, and the shape of the tool you used stays legible in the result long after the result looks natural. Both of those, I think, apply well outside terrain.