Two allele variants of one gene ā A (green) dominant/favored-by-default and a (amber) ā segregate in a population of diploid organisms (genotypes AA, Aa, aa) drawn from InstancedMesh spheres. With no selection, genotype proportions settle at the Hardy-Weinberg equilibrium:
p² + 2pq + q² = 1
p = freq(A), q = freq(a) = 1 ā p
Clicking "change environment" flips which allele the simulated predator spots more easily, giving one genotype a survival edge captured by a selection coefficient s. Each generation the favored allele's frequency updates by the classic one-locus selection recursion:
p' = pĀ·(1 + s) / (1 + sĀ·p)
- Selection coefficient (s) ā the relative fitness advantage of the favored allele; s = 0 is neutral drift only, s ā 0.8 is strong, fast directional selection.
- Large / small population size ā both populations experience the same selection pressure, but the small one also samples its next generation via finite binomial draws, so random chance can swing p up or down independent of fitness ā genetic drift. Watch the small population's line jitter far more than the large one's, especially near s = 0.
- Generation speed ā how many simulated generations tick per real second.
Real-world relevance: this is the same pā² = p(1+s)/(1+sp) recursion textbooks use for peppered-moth industrial melanism, insecticide-resistance spread and antibiotic-resistance fixation ā and the drift comparison shows why small conservation populations lose alleles faster than large ones even without any selection at all.