PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabsLessons
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry
ENRUESPTFRDE

Related simulators

Continue with similar topics in this category — or all 53 in Biophysics, Fluids & Geoscience.

View category →
NewUniversity / research

Predator–Prey Functional Response

Launch Simulator

Lotka–Volterra vs Holling type I/II/III: saturating kill rate, prey carrying capacity, nullclines, and limit cycles.

NewUniversity / research

Logistic Harvest & Maximum Sustainable Yield

Launch Simulator

Logistic growth with constant harvest: MSY = rK/4, stable stock, unstable collapse threshold, and population trajectory.

NewUniversity / research

Hardy-Weinberg Population Genetics

Launch Simulator

Allele frequency p, p²/2pq/q² genotype frequencies, plus selection, mutation, and genetic drift toy trajectories.

NewSchool

Soil Water Retention Curve

Launch Simulator

van Genuchten θ(ψ), effective saturation S_e, Mualem K(θ), field capacity, wilting point, and plant-available water.

NewUniversity / research

Geostrophic Balance & Thermal Wind

Launch Simulator

Pressure-gradient force balanced by Coriolis: isobars set geostrophic wind, while meridional temperature gradients produce vertical shear between 1000 and 300 hPa.

NewUniversity / research

Infinite Slope Stability

Launch Simulator

Limit-equilibrium factor of safety for a shallow planar slide: slope angle, cohesion, friction, depth, and rainfall-driven pore pressure set the landslide threshold.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Biophysics, Fluids & Geoscience/Natural Selection: Beetles, Predators and Camouflage

Natural Selection: Beetles, Predators and Camouflage

Beetles with a colour trait on an adjustable background: predators eat high-contrast ones, survivors breed with mutation σ.

Environment

0.3
0.7

Population

0.03
120
2

Each generation has two phases: predators remove beetles with probability growing with the contrast between beetle and background, then survivors breed back to the carrying capacity; each offspring inherits its parent’s colour ± a random mutation. Changing population size restarts the run; the other sliders act live.

Shortcuts

  • •Space / Enter — play / pause
  • •R — reset population

Measured values

Generation0
Mean colour0.500
Background colour0.30
|mean − background|0.200
Std. deviation σ_pop0.120
Survivors last generation120 / 120
Removed by predators0.0%

About this model

This is an individual-based model of natural selection acting on one continuous, heritable trait. Each beetle carries a colour value c between 0 (light) and 1 (dark) and sits on a background of colour b. A generation has two phases. In the predation phase every beetle is removed with probability P = min(0.95, 1.5·s·|c − b|), where s is the predation strength: the greater the contrast with the background, the more likely a predator spots it. In the reproduction phase the survivors breed back to the carrying capacity N; each offspring copies a randomly chosen surviving parent and adds a Gaussian mutation with standard deviation σ. Nothing else is modelled: there are no sexes, no genes or alleles, no age structure, no predator population dynamics, and the background does not react to the beetles. The mean colour drifts toward b over roughly 15–30 generations and the spread narrows; a sudden change of background shows re-adaptation, and σ = 0 shows that without new variation selection eventually fixes a single colour. Because selection is random sampling, every run differs — compare several runs before drawing conclusions. For the same ideas expressed with discrete alleles and frequencies p and q, continue with the Hardy–Weinberg Population Genetics simulator (earth-life-fluids/hardy-weinberg-population-genetics).

Who it's for: Middle- and high-school biology (grades 7–11) introducing adaptation, variation, heredity and natural selection with a visual, hands-on model.

Key terms

  • Natural selection
  • Variation
  • Heritability
  • Mutation
  • Camouflage
  • Selection pressure
  • Carrying capacity
  • Adaptation

How it works

A population of beetles carries a continuous colour trait from 0 (light) to 1 (dark) and lives on a background with its own colour. In each generation predators spot and remove beetles with probability proportional to the contrast |colour − background| times the predation strength; the survivors then reproduce until the population is back at the carrying capacity, with each offspring inheriting its parent’s colour plus a small random mutation σ. Over generations the mean colour of the population drifts toward the background — natural selection acting on heritable variation — and the histogram narrows. Flip the background suddenly and watch the population re-adapt; set σ = 0 and the variation is eventually lost altogether.

Key equations

P(eaten) = min(0.95, 1.5 · s · |c − b|) (s = predation strength, b = background)
c_offspring = clamp(c_parent + N(0, σ²), 0, 1)
mean c̄ = Σc/N, σ_pop = √(Σ(c − c̄)²/N)

Frequently asked questions

Why does the population not become exactly the background colour?
Mutation keeps injecting new colours every generation, and predation is probabilistic, so a few mismatched beetles always survive by chance. The mean settles close to the background and fluctuates around it; the standard deviation stays near a balance between mutation adding spread and selection removing it.
What happens when the mutation σ is set to 0?
No new variation enters. Selection removes the most contrasting colours each generation while offspring are exact copies of their parents, so the colour range shrinks until every beetle is identical and the histogram collapses to one bar. The population is then "stuck" and cannot re-adapt if the background changes.
Do the beetles choose or change their colour to match the background?
No. An individual never changes colour during its life. Only the population changes, because beetles that happen to match survive and pass their colour to more offspring. That difference between individual change and population change is the heart of natural selection.
Why are two runs with identical settings different?
Which beetles get eaten and which mutations appear are random draws, as in a real population. Small populations show larger run-to-run differences; raise the population size to see the mean colour curve become smoother.