Natural Selection Simulator

A population of individual organisms whose inherited colour decides how likely they are to survive against a background you control.

Watch allele frequency shift over generations, change the habitat mid-run, and switch selection off entirely to see what genetic drift looks like on its own.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

The three things selection needs

Natural selection is not a force pushing organisms towards improvement. It is an arithmetic consequence of three facts about a population, and if all three hold then the frequencies must change whether anything intends it or not. This simulation contains exactly those three facts and nothing else.

  • Variation. The organisms are not identical. Some are dark, some speckled, some light.
  • Inheritance. Offspring resemble their parents, because each parent passes on one of its two alleles.
  • Differential survival and reproduction. Some variants leave more offspring than others. Here that happens because a badly camouflaged organism is more likely to be eaten before it breeds.

Remove any one of the three and the effect stops. Set selection strength to zero and survival stops depending on colour; the frequency still moves, but it wanders instead of trending. Remove inheritance and offspring would be random; nothing would accumulate. Remove variation, which happens by itself once an allele reaches 100 percent, and there is nothing left for selection to act on.

Watch the habitat panel while it runs and notice what does not happen: no individual organism ever changes colour. Each one lives and dies with the alleles it was born with. What changes is the makeup of the population. That distinction between individual and population is the single most common place students go wrong when writing about evolution.

Selection against drift, and why population size decides which one wins

Switch selection off and run the simulation. The allele frequency does not sit still. It drifts, because which individuals happen to breed is a matter of chance and chance does not average out perfectly in a finite population. This is genetic drift, and telling it apart from selection is a genuine skill.

Population size decides how loud the noise is. With selection switched off and no mutation, running 40 independent populations under this model gives a clear picture:

  • 30 individuals, 100 generations: around 33 of the 40 populations lose one allele completely. Drift alone destroys most of the variation.
  • 1,000 individuals, 100 generations: none of them fix. The frequency stays close to where it began.
  • Averaged across all runs, the frequency stays near its starting value. Drift has no preferred direction. It is a random walk, not a trend, and any individual run that looks like a trend is a coincidence.

This is why one run proves nothing. Press New seed and run the same settings again, several times. A pattern that survives five different seeds is telling you about the model; a pattern that appears once is telling you about that seed.

Two practical consequences follow. Small populations lose genetic variation quickly even when nothing is wrong with them, which is why conservation biologists worry about population size on its own. And weak selection in a small population can be swamped entirely by drift: the advantage is real but the noise is louder, so the favoured allele can still be lost.

Reading the two panels

The habitat on the left is the population as it exists right now. The chart on the right is its history. Both are needed, because they answer different questions: the habitat shows you what the population looks like, and the chart shows you what has been happening to the genes underneath.

  • Dots. One per organism, shaded by its inherited colour, on the background you chose. The harder a dot is to see, the better its chances.
  • Crossed-out dots. The individuals that did not survive the most recent generation. Their positions are random, so do not read anything into where they are, only into what colour they were.
  • The teal line. The frequency of the dark allele D across the whole population, counting two alleles per individual. When it reaches 0 or 1 the population has lost an allele permanently, unless mutation is switched on.
  • The shaded bands. The proportion of the population that is dark, speckled and light. These are the phenotypes, which is what selection can actually see.
  • Survival chances. The readout shows what each phenotype is up against under the current background and selection strength. It is the quickest way to check that the pressure is pointing the way you think it is.

Watch the relationship between the line and the bands. The bands move first, because selection acts on appearance within a single generation. The line follows, because allele frequencies only change when the survivors breed. When the two disagree, it is usually because heterozygotes are carrying an allele through a generation that is selecting against the phenotype it produces.

Five experiments and what they show

Each of these takes two or three minutes and makes a point that is hard to make with a diagram.

  • Change the habitat mid-run. Let the population adapt to a dark background, then drag the background slider to pale while it is still running. Selection reverses and the line turns around. Adaptation is to a particular environment, not to the world in general.
  • Wait for fixation, then change the habitat. If an allele has already reached 100 percent, nothing happens. There is no variation left to select on, and the population is stranded. Turn the mutation rate up and watch how long recovery takes.
  • Turn selection off in a population of 30. Run it several times with different seeds. Most runs end with one allele lost, and the direction is different every time. That is drift, and it looks deceptively like adaptation in any single run.
  • Turn selection off in a population of 1,500. Almost nothing happens. Same rules, different outcome, purely because of size.
  • Use weak selection in a large population. Set the strength to 0.1 and the size to 1,200. The change is slow and smooth, with almost no noise. This is much closer to how selection works in the wild than the fast demonstrations are.
  • Set the mutation rate high with selection off. The frequency settles near 50 percent instead of drifting to an extreme, because mutation keeps pushing alleles back the other way.

A note on timescales. Selection strengths of 0.8 make a good demonstration but are far stronger than most real selection, which often amounts to a few percent per generation. That is why real adaptations take hundreds or thousands of generations, and why observing selection in the wild is slow, difficult work.

Frequently Asked Questions

Common questions about the Natural Selection Simulator

A population of individual organisms, each carrying two alleles at a single gene that controls colour. The alleles are codominant, so an organism with two dark alleles is dark, two light alleles is light, and one of each is speckled. Every generation, each organism survives with a probability that depends on how closely its shade matches the background. Survivors pair at random and each passes one allele to each offspring, with a small chance of mutation, until the population is back to its starting size. Nothing else is going on, which is the point: variation, inheritance and differential survival are all that selection needs.