A genetic algorithm

Darwin’s Finches

Pick an island, release a flock of storm-blown mainland finches and watch natural selection shape them, one generation at a time.

1 Choose an island

A BrainB Beak (0 short & fat … 15 long & thin) C Wings (0 short … 15 long)D Speed

Controls

2 Fitness by generation

100% is the island’s ideal bird, 0% an average random bird, below 0% worse than average. Hover for the raw scores.

Show as a table

Fittest birds

3 The island’s population

Survived Newborn Founder Died

4 Evolution lab

Single runs are luck. These run the simulation 40 times over and average it out.

Race all five islands

Same population size on every island. How quickly do the runs find the ideal bird?

Does a bigger population help?

The chosen island at every population size, from 4 to 40 birds.

How it works

The chromosome

Each finch carries 16 bits: four genes of four bits, so each gene is a number from 0 to 15. That makes 65,536 possible birds. The page scores every one of them, so it knows each island’s ideal bird in advance.

The founders

The first finches are storm-blown strays from the mainland, suited to somewhere else: every trait of every founder is at least 7 steps (out of 15) from what its new island needs, so the first birds look nothing like the ideal. Switch Founders to Random birds and a lucky founder often starts close to the ideal.

Selection

Each generation the birds are ranked by the island’s fitness formula. The fitter half survive and the rest die. Survivors are paired at random and each pair has two chicks, so the population stays the same size. That is why it goes up in fours.

Breeding and mutation

Single-point crossover: both parents’ chromosomes are cut at the same random point and the tails swapped, giving two chicks. Then each of a chick’s bits has a small chance of flipping. Each island sets its own mutation rate.

Gray code

In plain binary, 7 is 0111 and 8 is 1000: a one-step change in a trait needs all four bits to flip at once, so evolution can stall just short of the best bird (a “Hamming cliff”). In Gray code, neighbouring numbers always differ by one bit. Switch the encoding to see the difference.

Fast and slow islands

Smooth formulas with a high mutation rate evolve fast. Where genes are linked (brain and beak in the rainforest) or there is a false peak (running on Ember Isle), evolution is slower, and small populations can get stuck.

Bigger populations

More birds means more variety in the gene pool, so good combinations turn up sooner and false peaks are easier to escape. Use the sweep in the lab to see it.