A genetic algorithm keeps a population of candidate solutions. Each one is scored for fitness; the fitter ones are more likely to become parents, their DNA is mixed by crossover, and a little mutation keeps new ideas coming. Generation by generation, rockets learn to steer around obstacles, random letters become a sentence, cities get a short route, and triangles become a picture.

Interactive selection puts you in charge of fitness: pick the flowers or biomorphs you like and breed them.

Every simulation below runs right here in your browser, for free, with live controls. Open one, change the sliders, and use the mouse — most of them respond to it.

Evolutionary Computing simulations

Evolving a Phrase

Evolving a Phrase — interactive simulation

The infinite monkey problem solved by evolution. Random typing would take longer than the age of the universe to produce a sentence. A genetic algorithm gets there in a few hundred generations:

Try this: Set the mutation rate to 0 or to 0.05 and compare. Too little gets stuck, too much destroys progress.

Open Evolving a Phrase →

Smart Rockets

Smart Rockets — interactive simulation

Each rocket's DNA is a list of thrust vectors, one for every frame of its life. At the end of a generation, rockets are scored on how close they got to the target. Finishing faster scores higher, and crashing scores lower. Then the next generation is bred.

Nobody programs a path. Through selection, crossover and mutation, the population learns to fly around obstacles.

Try this: Left-click to move the target. Right-drag to draw a new obstacle. Raise the speed to evolve faster.

Open Smart Rockets →

Traveling Salesperson (GA)

Traveling Salesperson (GA) — interactive simulation
Generation 2: an evolution of Evolving a Phrase

The phrase GA evolved strings of letters. Here the DNA is an ordering: the sequence in which to visit every city, and fitness rewards shorter round trips. Checking every route is impossible (40 cities have ~10⁴⁶ tours), but evolution finds very good ones quickly.

Orderings need special operators, because ordinary crossover would duplicate or drop cities. Order crossover copies a slice from one parent and fills the rest in the other parent's order. Mutation reverses a random section (a "2-opt" move), which untangles crossing paths.

Try this: Click to add cities while it runs. Set the mutation rate to 0 and watch progress stall.

Open Traveling Salesperson (GA) →

Interactive Selection: Breed Flowers

Interactive Selection: Breed Flowers — interactive simulation
Generation 2: an evolution of Smart Rockets

Sometimes the best fitness function is you. In interactive selection a person rates each individual, and the GA breeds the next generation from the favourites. It is how aesthetic artefacts evolve: Karl Sims' "Genetic Images", Dawkins' biomorphs.

Each flower's DNA is 10 numbers between 0 and 1: petal count, length, width and pointiness, two hues, centre size, stem height, curve and leaves. Children mix their parents' genes (uniform crossover) and mutate slightly.

Try this: Click flowers to give them 1–3 stars, then press "Next generation". Within a few rounds you can steer toward, say, blue pointy flowers.

Open Interactive Selection: Breed Flowers →

Evolving a Picture from Triangles

Evolving a Picture from Triangles — interactive simulation
Generation 2: an evolution of Evolving a Phrase

The phrase GA matched letters. This one matches pixels. The genome is a list of semi-transparent coloured triangles. Each iteration mutates one gene (move a corner, nudge a colour, change opacity). If the rendered result is closer to the target picture (smaller sum of squared pixel differences), the mutation is kept.

This is a (1+1) evolution strategy, the simplest kind of evolutionary hill-climbing. Watch random shards slowly organise into the target.

Try this: Pick "Text" and type a single bold letter or emoji, then compare 20 triangles with 120.

Open Evolving a Picture from Triangles →

Evolving Steering: Food vs Poison

Evolving Steering: Food vs Poison — interactive simulation
Generation 2: an evolution of Smart Rockets

Each vehicle's DNA holds four numbers: how strongly it is attracted to food, how strongly to poison (negative = repelled), and how far it can see each one. Health drains over time. Food restores it, poison hurts. Healthy vehicles occasionally clone themselves with small mutations, and dead ones leave food behind.

There is no explicit fitness function. Survival is fitness. Over time the average food weight drifts up and the poison weight drifts negative: the population learns to avoid poison. The chart tracks both.

Try this: Turn on debug to see each vehicle's perception radii (green = food, red = poison) and its steering weights.

Open Evolving Steering: Food vs Poison →

Simulated Annealing

Simulated Annealing — interactive simulation
Generation 3: an evolution of Traveling Salesperson (GA)

A different way to search a huge space, borrowed from metallurgy. Keep one route and repeatedly try a small change (reverse a section). Always accept improvements. Accept a change that makes things worse with probability e^(−Δ/T), where the temperature T slowly cools.

When hot, the search jumps around freely and escapes local optima. As it cools it becomes greedy and settles into a very good route, just as slowly cooled metal forms an orderly crystal. Compare with the population-based GA in the previous demo.

Try this: Cool very fast (0.99) and watch it get stuck in a worse route. Press "Reheat" to try again.

Open Simulated Annealing →

Biomorphs

Biomorphs — interactive simulation
Generation 3: an evolution of Interactive Selection: Breed Flowers

Richard Dawkins invented biomorphs for The Blind Watchmaker (1986) to show how cumulative selection creates complex forms. Each one is a recursive branching drawing controlled by nine genes: eight set branch directions and lengths, and one sets the recursion depth.

The parent sits in the centre, surrounded by eight children, each differing by a single mutation. Click the child you like best and it becomes the new parent. In a few dozen clicks you can breed insects, trees, lamps or letters from a single stick.

Try this: Set yourself a goal (say, "something like a spider") and see how many generations it takes.

Open Biomorphs →

Evolve them into something new

Several of these are already evolutions: Traveling Salesperson (GA) grew out of Evolving a Phrase; Interactive Selection: Breed Flowers grew out of Smart Rockets; Evolving a Picture from Triangles grew out of Evolving a Phrase; Evolving Steering: Food vs Poison grew out of Smart Rockets. In Labs you can take any of them a generation further: press Evolve this, get suggestions for what the next version could add, and build the one you like — or combine two or three simulations into one system.

Make your own simulation →
Pick evolutionary computing as a concept, choose an art piece, game, explainer or experiment, and Labs suggests ideas and builds the one you choose.

Open Labs →

More from Labs