Selection needs three ingredients
Darwinian evolution by natural selection requires exactly three properties in a population: variation (individuals differ in heritable traits), heredity (offspring resemble parents), and differential fitness (some variants leave more surviving offspring than others). Give a simulation those three properties — creatures with a mutable genome for speed, sensory radius and camouflage colour, food that is limited, and predators that can only catch what they can see or outrun — and selection is not something you program in as a rule. It falls out automatically from which creatures survive to reproduce.
Each generation, or continuously as creatures die and reproduce, the trait distribution of the population shifts toward whatever combination of speed, sensing and camouflage let the last generation's survivors out-eat and out-run everyone else. No creature decides to evolve; the population's average genome simply drifts because the individuals who deviated in a bad direction are, on average, not around to pass their genes on.
Trade-offs are what keep it interesting
If speed, sense radius and camouflage were free, selection would push every trait to its maximum and the population would converge to a single optimal creature and stop. Real evolution stays interesting because traits are costly. A faster creature typically burns more energy per unit time and needs to eat more; a larger sense radius demands a bigger investment in sensory tissue; bright camouflage that hides you from one predator, or blends with one background, may make you conspicuous against another. The simulation captures this with an energy budget: every trait pulls from the same energy pool, so a creature investing heavily in speed has less to spend on the metabolic cost of maintaining a large sensory range.
Evolutionarily Stable Strategies
John Maynard Smith and George Price formalised the endpoint of this process in 1973 as an Evolutionarily Stable Strategy (ESS): a strategy which, if adopted by almost the whole population, cannot be invaded by any rare alternative strategy. Formally, a strategy S is an ESS against alternative T if either S does strictly better against S than T does against S, or they tie against S but S does strictly better against T than T does against itself.
E[payoff(S,S)] > E[payoff(T,S)] (S strictly beats T at S) OR E[payoff(S,S)] = E[payoff(T,S)] AND E[payoff(S,T)] > E[payoff(T,T)] (tie, then S wins vs T)
An ESS is not necessarily the trait combination that maximises the population's average fitness or its total food intake — it is simply the point no individual mutant can profitably deviate from, which is why evolution can settle into strategies that look wasteful from the outside (elaborate camouflage arms races, unnecessarily fast pursuit speeds) yet are stable because no single mutant benefits from unilaterally backing off.
Frequency-dependent selection and camouflage
Camouflage in this simulation is a nice illustration of negative frequency-dependent selection: a colour's advantage depends on how common it already is relative to the background and to other creatures' colours, not on some absolute quality. If the whole population converges on one camouflage colour, a predator that specialises in searching for that exact colour against that exact background gets very effective very quickly (search-image formation), and a rare mutant with a different colour can suddenly do better simply because predators are not looking for it. This is the same dynamic that maintains colour polymorphism in real prey species and keeps the simulated population from collapsing to a single monoculture strategy even under constant predator pressure.
Watching convergence in the simulation
Run the simulation long enough and you can watch the population's trait histograms narrow: speed and sense-radius distributions compress around whatever balance beats the current predator population, while camouflage colour often stays more spread out precisely because of the frequency-dependent effect above. Turning up predator density typically pushes the population toward higher average speed and larger sense radius at the cost of population size (fewer creatures can be supported once more energy is spent on traits instead of reproduction) — a direct, visible trade-off between individual survival traits and total carrying capacity.
Frequently asked questions
Does the simulation program in a target for the creatures to evolve toward?
No. Only three mechanisms are hard-coded: traits are inherited with mutation, food and predation limit who reproduces, and reproduction requires surplus energy. Any apparent goal-seeking is an emergent statistical consequence of which random trait combinations survived, not a built-in objective.
What exactly is an Evolutionarily Stable Strategy?
A trait or strategy that, once it dominates a population, cannot be beaten by any rare alternative strategy trying to invade. It is a game-theoretic equilibrium (Maynard Smith & Price, 1973), not necessarily the combination of traits that is best for the population as a whole — only the one no individual mutant benefits from deviating from.
Why doesn't camouflage colour converge to a single winning value like speed does?
Because camouflage advantage is frequency-dependent: a colour that is common becomes easy for predators to specialise against (search-image formation), so a rare, different colour gains a temporary edge. That negative feedback keeps colour diverse even after speed and sense-radius have settled near their ESS values.
Try it live
Everything above runs in your browser — open Natural Selection and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Natural Selection simulation