Biology · Simulator 031
A population of moths comes in light and dark forms. Predators spot moths that stand out against the bark. Change the bark colour, predation strength and starting mix, and watch the frequency of the dark allele change over generations.
Each moth has two copies (alleles) of a colour gene: dark D (dominant) or light d. DD and Dd moths are dark; dd moths are light. Each generation:
The simulation tracks real individuals with a seeded random generator, so small populations also show chance effects (genetic drift). The dashed line is the deterministic expectation for an infinite population, using the standard one-locus selection recursion.
This is the classic peppered moth story: soot-darkened trees in industrial England favoured dark moths, and clean-air laws reversed the trend.
Simplified single-gene model with complete dominance, random mating and non-overlapping generations. Real moth colour genetics and predation are more complex.
On dark bark with strong selection, why does the light allele (d) never quite disappear, even after many generations?
When d is rare it is almost always in Dd moths, which look dark and are not selected against. Only dd moths are exposed, at frequency q². That shrinks very fast as q falls, so selection slows dramatically. Mutation also keeps reintroducing d at a low rate. The deterministic curve flattens near zero for the same reason.