Game Lab · Genetic algorithm

Paper Plane Designer

Fold a plane with the sliders, then press Throw! How far can you make it glide? After that, 40 robot planes will evolve to beat you.

How the flock did, generation by generation

Metres flown (and % on the pad, once that challenge is on)

Best plane (m)Average of the best half (m)A challenge switched

Checkpoints — the champion plane of each generation. Tap one to throw it again, with today's challenges.

The champion's family tree — its parents, grandparents and great-grandparents. Tap any plane to throw it.

Random first-generation plane Mix of two parents (crossover) Copy of one parent Kept unchanged (a champion) Your design ✦ = got a random nudge (mutation)

How it works

40 random planes

Each plane is just five numbers, its genes: wing size, wing tilt, nose weight, throw angle and throw speed. The first 40 are picked at random.

Throw them all

Every plane is thrown in the same pretend air. Lift, drag, weight and balance decide the flight. The distance is its score.

Pick parents

Grab three planes at random; the best of the three becomes a parent. Good planes win more often, but lucky weaker ones sometimes get picked too.

Mix and nudge

A baby gets a mix of two parents' numbers (crossover) and sometimes a small random nudge (mutation). The two best planes are kept unchanged.

Repeat

New flock, new throws. Nobody tells the planes how to fly: designs that happen to fly further simply have more babies.

What just happened?

For grown-ups: what's really going on

This is a real-valued genetic algorithm optimising five design parameters against a black-box simulator. There are no gradients and no neural network: the "model" is the population itself.

  • Genome: 5 genes in [0, 1], decoded linearly to wing area scale (0.6–2.0), elevator tilt (−2° to 12°), nose ballast (0–4 clips), launch angle (−10° to 45°) and launch speed (4–16 m/s).
  • Physics: a 2-D rigid-body glider integrated with semi-implicit Euler at 240 Hz. Lift L = ½ρv²S·CL(α) with CL = 5α in attached flow; drag D = ½ρv²(S(CD0 + kCL²) + body). Above about 14° angle of attack a logistic blend switches to flat-plate behaviour (CL ≈ 0.9 sin 2α, CD ≈ 1.6 sin²α): the stall.
  • Pitch: moment coefficient Cm = Cm0(tilt) − h·CLα sin α, where the static margin h grows with nose ballast (negative with no clips, so the plane is statically unstable and tumbles), plus aerodynamic pitch damping. The trim angle of attack is roughly Cm0/(h·CLα): tilt and nose weight must be balanced together, which is exactly why one-slider-at-a-time tuning is hard.
  • Safety: airspeed, pitch rate and speed are clamped, angles wrapped, and the flight capped at 24 s. Verified in Node over thousands of random designs: no NaN or runaway values.
  • GA operators: population 40; tournament selection (k = 3); blend crossover (BLX-α style, α = 0.15) with probability 0.7; per-gene Gaussian mutation with probability 0.4 and σ set by the "Random nudges" slider; elitism of 2. Your design can be injected as an immigrant.
  • Fitness: distance flown (minus a penalty for hitting the cave roof). In pad mode: 100 − 2.5·|miss| − 6·max(0, vimpact − 3), so it must aim and touch down gently.
  • Headwind: −4 m/s with two sine gusts, which is close to the plane's own gliding speed. Large light wings get blown back, so evolution shifts towards smaller wings and higher wing loading (a faster glide), which is what real glider pilots do with water ballast.
  • Measured in Node (seeds 1–5, 30 generations = 1,200 throws): the best-half average rose from 18–30 m to 53–58 m (already 50–55 m by generation 5), the best plane from 43–57 m to 60–65 m. Switching a challenge on at generation 15: headwind dropped the best to about 22–25 m and it passed 27 m within 3–12 generations; the cave roof dropped it to 7–50 m and it passed 40 m within 1–9; on the pad the champion landed softly within 4–8 generations.
  • An honest baseline: with only 5 genes, a pure random search over the same 1,200 throws finds a single plane about as good (59–66 m). The GA's real strengths show elsewhere: the whole population moves to good designs (useful when the rules change), and its advantage grows quickly with more genes, where random search drowns. The landscape also has a thin ridge of nearly neutrally-stable designs that sometimes reaches the end of the park: evolution occasionally finds it, random search rarely does.
  • The family tree follows parent links back through the population; chains of unchanged elites are collapsed into one node ("kept ×n").