How does it work?
The three ingredients of natural selection
Natural selection needs no plan and no goal. Three things are enough:
- variation — individuals differ in their traits (here: speed, size, sensing range, and color);
- inheritance — offspring get their parent's genes, sometimes with a small random change, a mutation;
- differential reproductive success — some traits help an individual find food or avoid a predator, so their carriers leave more offspring.
When all three are at work, the makeup of the population has to change from generation to generation. That is evolution. A single creature doesn't evolve — the population changes.
The best fit, not the strongest
“Survival of the fittest” is often misread as “survival of the strongest.” But fittest here means “best suited,” not “in the best shape.” The simulation shows this clearly: on an island with little food, the small and thrifty win; with predators around, those whose color blends into the background do. A trait that helps in one world can hurt in another.
A creature's energy budget
Each creature has four genes: size r, speed v, sensing range z, and color k (from 0 — light, to 1 — dark). Every step it loses energy:
Estep = 0.02·r3 + 0.03·r3·v2 + 0.012·v2 + 0.02·z
body upkeep · body motion (like kinetic energy ½mv², since mass grows as r³) · leg movement · senses
A food item gives 12 units of energy. When a creature has stored twice the cost of an offspring, Eo = 20·(0.4 + 0.6·r3), it divides. When its energy drops to zero, it starves. Speed lets it reach food first and escape, senses let it spot food earlier (and predators too), and a large size gives a longer reach, protects against predators, and lets it eat creatures at least ¼ smaller. Every advantage has a cost — that's why traits don't grow without limit.
Offspring inherit the genes with a mutation:
g′ = g·eμ·ε (color: k′ = k + μ·ε)
ε — a random number from a normal distribution (mean 0), μ — mutation strength from the slider
Camouflage
Every so often a predator looks around within a radius of 130 units. The chance that it spots a creature grows with the square of the contrast between the creature's color k and the background color t:
pspot = 0.003 + 0.18·(k − t)2
When the bark darkens, light creatures suddenly stand out — just like light peppered moths on soot-blackened birches.
Genetic drift — evolution by chance
Who leaves offspring is also decided by plain luck: one individual gets crushed under a rock before it can reproduce. In a large population such accidents cancel out; in a small one they can change everything. The Wright–Fisher model: the population has N individuals, so 2N copies of the gene; each generation is drawn at random from the previous one. The allele frequency p wanders randomly:
Var(Δp) = p(1 − p)2N
Ht = H0·(1 − 12N)t
A neutral allele becomes fixed with a probability equal to its initial frequency p0, and the mean time to fixation or loss is t̄ = −4N[p0 ln p0 + (1 − p0) ln(1 − p0)] generations — for p0 = ½ that's about 2.8·N. When the allele has an advantage s, the chance that it becomes fixed is given by Kimura's formula:
u = 1 − e−4Nsp01 − e−4Ns
for a single new mutation (p0 = 1/2N) in a large population that's only about 2s — even a beneficial mutation usually disappears!
The breeder's equation — how fast a trait changes
If the survivors' mean trait differs from the mean of the whole population by S (the selection differential), their offspring will shift by only part of that difference:
R = h2·S
h² — heritability: how much of the differences between individuals is due to genes (for finch beak depth the Grants found it to be high — the demo assumes 0.8)
Darwin and Wallace
Charles Darwin and Alfred Russel Wallace arrived at this idea independently. Their papers were presented together on July 1, 1858, at the Linnean Society of London, and on November 24, 1859, Darwin's “On the Origin of Species” was published. Today we also know what they didn't: where variation comes from (mutations in DNA) and how traits are inherited (Mendelian genetics).
Simplifications: the creatures reproduce asexually (by dividing), so their genes don't mix; each trait is a single number rather than the effect of many genes; the world is a torus (whoever goes off one edge comes back on the other side); predators neither evolve nor reproduce. We tuned the energy-cost formula so the trade-offs are easy to see — in real animals the metabolic rate grows roughly as mass¾ (Kleiber's law). The peppered moth's coloring actually depends mainly on a single gene, while here color is a continuous trait. In the drift model, for large populations we approximate binomial sampling with a normal distribution. The numbers in the “Evolution in nature” cards are approximate.