The 3D version enumerates the 16-cell Punnett square once and colors it exactly. This 2D companion instead simulates real random meiosis, one offspring at a time, as a physical Galton board: each falling ball passes four decision rows — Parent 1's Locus A allele, Parent 2's Locus A allele, Parent 1's Locus B allele, Parent 2's Locus B allele — and at each row it nudges left (dominant allele contributed) or right (recessive allele) with a genuine fair coin flip, exactly matching Mendel's Law of Independent Assortment.
4 independent fair coins per offspring → 16 equally likely paths (bins), 1/16 each
domA = NOT (bit_P1A=recessive AND bit_P2A=recessive) → P(domA)=3/4
domB = NOT (bit_P1B=recessive AND bit_P2B=recessive) → P(domB)=3/4
bin index = bit_P1A·8 + bit_P2A·4 + bit_P1B·2 + bit_P2B·1 (0..15, board position)
Choosing an epistasis rule doesn't change how the balls fall — it only changes which of the 16 physical bins get grouped into the same phenotype color, exactly like the 3D model's recolor step. What's genuinely different here is that the ratio you read (9:3:3:1, 9:3:4, …) is not looked up — it emerges live from real random sampling and gets noisier or smoother depending on how many offspring have dropped, the same way real breeding counts do.
Standalone verification (Node, no dependencies): the 16-bin → phenotype-class grouping reproduces all seven textbook ratios (9:3:3:1, 9:3:4, 12:3:1, 9:7, 15:1, 13:3, 9:6:1) exactly from first principles. A 2,000,000-offspring Monte Carlo run of the actual coin-flip code converged to every expected class percentage within 0.061 percentage points, and the bin-level χ² statistic (df=15) landed close to its theoretical mean of 15 for every rule (8.7–17.5 across the seven). The four board-position weights (8,4,2,1) were confirmed super-increasing, so all 16 genotype paths land in visually distinct bins with zero collisions. P(dominant allele present) measured 0.7501 against the 3/4 predicted by one-locus segregation.
- Cross type — switch instantly recolors the 16 bins by phenotype class; existing offspring counts are kept (the genetics didn't change, only which classes look identical).
- Offspring per second — how fast new balls are dropped through the board.
- Drop 1,000 instantly — samples 1,000 offspring in one step (no animation) so the ratio and χ² converge immediately, demonstrating the law of large numbers.