← rh.deese.org · run the drawing

Niche, four ways

From Rupert Deese's workshop†Rupert's Niche, in four versions to his direction. His staff of AI agents built them and wrote this page. About his staff

In 2010 Jon McCormack showed that line-drawing agents make more varied pictures when they shape their own surroundings. In 2017 I tried to rebuild his system and never got it to behave like the paper. This year I had it rebuilt from the paper, measured all three, and added a fourth version that does something the paper wished for.

October 2026. The rewrite, the experiments and this write-up were made by Claude, the AI agent I work with, in my personal agent harness. The code is linked at the end.

The idea

A few founder agents start on a blank page. Each one moves a pixel at a time, inks its trail, sometimes branches off a child next to its line, and dies if it runs into ink. Each carries a small genome: how much it curves, how erratically it wanders, how often it breeds, how likely it is to die, and the angle at which its children leave. When the last agent dies, the drawing is finished: a fossil record of every lineage that lived.

McCormack's paper adds one gene, a preferred ink density. Each agent measures the ink in a small square around itself. Close to its preference, it breeds more and dies less; far from it, the opposite. Because the ink is laid down by the agents themselves, a lineage builds the very surroundings its offspring will be judged by. That is niche construction.

The paper's claim, from 20 drawings with the rule and 20 without (its Table 1): with niche construction, the density within each drawing varies 4.3 times as much (p = 1.6 × 10−10), and overall density varies 3.8 times as much between drawings (p = 0.06). To the eye, the drawings gain dense dark masses, big empty bubbles and fans of hatching, where the drawings without it look like even, evenly divided maps (its Figs. 4 and 6, on pages 5 and 6 of the PDF).

Four versions

  1. The paper (2010). We can't run it; we have its text, its numbers and its four 1000 × 1000 example images, which the measurements below use directly.
  2. My 2017 version, the one that has run at /curios/niche/ since then.
  3. The 2026 rewrite, written from the paper alone, with every value the paper leaves out turned into a named setting and chosen by search against the paper's own numbers. Run it.
  4. Perpetual, a fourth version: the same agents, but ink fades after a while, so the page never fills and evolution never has to stop. Run it.
2017 version with niche construction: a few sparse loops
2017, niche on
2017 version with niche construction
2017, niche on
2017 version without niche construction: dense even tangle
2017, niche off
2026 rewrite with niche construction: fans, hatching and empty bubbles
2026, niche on
2026 rewrite with niche construction
2026, niche on
2026 rewrite without niche construction: page filled evenly
2026, niche off
Finished drawings, whole page. Picked by ink, not by looks: each is the drawing nearest its batch's median, except the second 2017 "niche on" drawing, one of its fullest, since most are nearly blank. The 2017 version draws in colour.

What went wrong in 2017

The 2017 version follows the paper's breeding formula exactly. Its trouble is in the settings around it, and they pull the effect backwards. Agents sense density over a 120 × 120 px square, so a lone line reads as about 1% ink. The niche is very narrow (ω = 100: an agent must be within about 2% of its preference to breed at all). Founders prefer 0–20% ink. So almost no founder is ever in its niche, almost nobody breeds, and the drawing dies early. With niche construction on, the 2017 version inks 4% of the page on average (and nearly half its drawings less than 1.5%); with it off, 62%.

Smaller differences pile on top: curvature never evolves (it is fixed at zero and its mutation is commented out); turning noise picks one of six precomputed noise maps instead of adding octaves; every gene mutates at every birth with a large step (σ = 0.3); and agents also die on touching another agent's head. One detail matters for anyone trying it: ?USE_NICHE=false in the URL does not turn niches off, because the string "false" is truthy; only ?USE_NICHE= does.

Rebuilding from the paper

The paper states the rules but not most of the numbers: how often fecundity 1.0 breeds, how deadly mortality 1.0 is, the size of the sensing square, ω, the mutation step, the noise scale. The rewrite makes each a setting and picks values the honest way: run hundreds of drawings, measure them the way the paper did, and keep the settings that land on the paper's figures. A 1000 × 1000 drawing takes about 0.2 s headless, against about 10 s for the 2017 code, so a search of a few thousand drawings takes minutes.

Two readings of the text mattered most, and both are checkable against the paper's figures. Children start beside the parent line, not on it, so a child heading almost parallel can run alongside its parent; without this, the dense hatching in the paper's Fig. 6 can't form. Fecundity is a per-step probability, as the paper says, so a fertile agent in its niche branches every step or two; that is what draws the tight lattices in the paper's dark areas. Equation 1 (how irrationality bends a line) reproduces the paper's Fig. 3 single-agent paths when read as dθ = σ + 0.89 r² × noise(p, octaves 1 + k r).

The settings the search kept: fecundity 1.0 → 100% per step, mortality 1.0 → 10% per step, 20 px sensing square, ω = 10, gestation 5 steps, mutation step 0.045 at a rate of 1 in 6 genes. A drawing lasts about 1,100 steps, makes about 40,000 offspring over about 44 generations (the paper: 103–105 offspring, 10–30 generations), and about a quarter of seeds die out within a few hundred steps, as the 2017 one does. (The live page quietly skips those seeds; the measurements keep them.)

Measured

Every drawing below, from all four sources, goes through the same script. It binarises the image and reports: ink fraction; density variance over 16 px tiles (the paper's measure; on the paper's own figures, windows of 12–20 px reproduce its Table 1 values); the share of the page in large empty regions; and how well the image compresses next to the same ink scattered at random (lower means more structure).

Three things stand out.

The rewrite matches the paper's niche drawings on almost everything but the darkest patches. Ink 22% (paper 20%), page in big empty regions 50% (paper 49%), compression ratio 0.60 (paper 0.57). Its density variance is 0.024 against the paper's 0.063: its dense patches are real, but not as black as the paper's.

The 2017 version gets the effect backwards. Niche construction makes its drawings sparse, not varied: with niches on, 87% of the page sits in big empty regions, and the variance falls to an eighth.

With the paper's rules applied as written, niche construction does not raise within-drawing density variance. Against a control with the same settings and niches off, the variance ratio is 0.8 (p = 0.3). Against a control with fecundity lowered so it lays the same amount of ink, it is 1.0. What niche construction does do, everywhere, is leave more of the page empty and the ink more clustered.

That last finding is the interesting one, so it gets a map. Each square below is 16 drawings (8 with niches, 8 without) at one setting of fecundity and mortality, everything else fixed.

Niche construction adds empty space at every setting. It raises density variance at almost none (the ratio runs 0.3 to 1.0). The paper's 4.3× gap does not appear anywhere on this map. The sticking point is the paper's drawings without niches: they cover the whole page evenly at low density (17% ink, 10% of the page in big empty regions). The rewrite without niches can do even, or sparse, but not both: lower fecundity far enough to get 17% ink and lineages die out in patches, leaving 41% of the page empty. The likeliest explanation is that the paper's two experiments ran with different settings, not just with and without the one gene. One of its two example drawings without niches is mostly straight lines meeting at right angles, a style its niche drawings barely show, which fits that guess. The paper doesn't say, so this stays a guess.

Rewrite without niches, fecundity lowered: ink in patches with large empty areas
2026, niche off, low fecundity
Rewrite without niches, fecundity lowered
2026, niche off, low fecundity
Detail at full size of a rewrite drawing with niches: hatching, fans and bubbles
2026, niche on, 1:1 detail
Detail at full size of a 2017 drawing without niches
2017, niche off, 1:1 detail
Left: the ink-matched control, sparse but patchy. Right: two 400 px details at full size.

The paper also plots how the population's preferred density tracks the ink actually on the page (its Fig. 8). There, agents always prefer slightly more ink than the page holds: the gap starts near +0.1 and closes to about +0.01 by step 2,000. The rewrite starts the same way (+0.06 to +0.09) but falls faster and keeps going: it crosses zero near step 700, and from then on the survivors prefer less ink than the page holds, ending near −0.15. The late survivors are the agents still finding open ground at the edges of a full page, and a page-wide average can't see that.

Is the eye wrong?

Looking at the rewrite's niche drawings, you see what the paper describes: regions drawn in clearly different styles, feathery fans here, foam of small bubbles there, ruled lattices somewhere else. Density variance can't see style: a fan and a foam can hold the same amount of ink. So the script also measures texture: it cuts the page into 32 px tiles and, for each, records density, how strongly the lines in it run one way, and how far apart they sit; then it asks how spread out those tiles are.

On the paper's own figures this measure agrees with the eye: the tiles in its niche drawings are twice as spread out as in the drawings without (2.0×, though that rests on two images each). The rewrite moves the same way, by less: 1.33× against the same-settings control (p = 10−5) and 1.14× against the ink-matched one (p = 0.006). The 2017 version goes the other way again (0.66×). So the eye isn't wrong. In the rewrite, niche construction shows up as more kinds of texture, not as more variance in ink.

A fourth version: a drawing that never ends

The paper closes on two limits. Agents have no way to make their surroundings less dense, and evolution only gets 10–30 generations because every drawing fills up and dies. Both come from ink being permanent. So in the fourth version, ink fades: each mark disappears 3,000 steps after it was laid. Old growth greys and clears, new lineages move into the gaps, and when a population crashes, a newcomer arrives on a blank patch. Nothing else changes.

Perpetual, niches on, step 10,000
niche on, step 10k
Perpetual, niches on, step 20,000
niche on, 20k
Perpetual, niches on, step 30,000
niche on, 30k
Perpetual, niches off, step 10,000
niche off, 10k
Perpetual, niches off, step 20,000
niche off, 20k
Perpetual, niches off, step 30,000
niche off, 30k
Snapshots of one seed. Darker ink is newer.

Lineages now reach 60 to 180 generations, against about 44 in a drawing that ends. The two worlds look nothing alike: without niches, the page fills to 55–65% grey and fronts of new growth sweep across it as old ink clears; with niches, it holds at about 23–32% ink, with ferns, lattices and foam in separate regions and 30–45% of the page open.

Measured by density alone, the never-ending world without niches is about as varied as the one with them (normalised variance 0.25 against 0.21), because its sweeping fronts make big light and dark patches too. Texture tells them apart: the entropy of tile textures (how many kinds there are) is 1.9 times as high with niches (5.2 against 2.8 bits, p = 5 × 10−12), though part of that gap is the world without niches being so full that most tiles look alike. The variety comes from different places: without niches, from time (old ink against new); with niches, from lineages holding different ground in different styles.

What it adds up to

Sources

Paper: Jon McCormack, "Enhancing Creativity with Niche Construction", Artificial Life XII, pp. 525–532, MIT Press, 2010 (PDF). After Mauro Annunziato's The Nagual Experiment (2002). 2017 code: github.com/rdeese/McCormack-niche. Rewrite source: niche.js (the simulation, no dependencies) and perpetual.js (the fourth version). Paper figures are measured but not reproduced here; see pages 5–6 of the PDF.

† From Rupert Deese's workshop. Rupert's Niche, in four versions to his direction. His staff of AI agents built them and wrote this page. About his staff: rh.deese.org/staff/