Every creature carries one continuous trait value (0 = pale coat, 1 = dark coat) — a stand-in for the peppered-moth story of industrial melanism. The ground colour is the environment's camouflage target. On each turnover tick, one individual is retired with probability weighted by how poorly its trait matches the target (predation), and one offspring is born from a parent chosen with probability weighted by fitness, with its trait nudged by mutation. Repeated over many ticks this is natural selection in miniature: heritable variation, differential survival and reproduction, and a population mean that tracks the environment.
fitness(trait) = exp( −(trait − target)² / 2σ² )
P(death_i) ∝ 1 − fitness(trait_i)
P(parent_j) ∝ fitness(trait_j)
child.trait = parent.trait + N(0, mutation²) [clipped to 0..1]
- Population size — more individuals means the population mean moves more smoothly and drift plays a smaller role.
- Environment tone — the camouflage target the ground itself displays; move it to simulate a changing habitat.
- Selection pressure — sets σ (narrower = stronger, more punishing selection against a mismatched trait).
- Mutation rate — how much a child's trait can drift from its parent's; the source of new variation each generation.
- Industrial event — snaps the environment tone dark instantly, mirroring how soot-blackened bark flipped the fitness landscape for peppered moths within a few generations.
Watch the dark-allele frequency (the fraction of the population past the trait midpoint) climb or fall as the mean trait chases the moving target — that shift is evolution by natural selection, no designer required.