Labs · Evolutionary Computing
Evolving a Phrase
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:
- Fitness: the share of characters that match the target, raised to a power to reward the best candidates more.
- Selection: parents are picked with probability proportional to fitness (a weighted "mating pool").
- Crossover: the child takes the first part of one parent and the rest of the other.
- Mutation: each character has a small chance of becoming random.
Set the mutation rate to 0 or to 0.05 and compare. Too little gets stuck, too much destroys progress.
Controls
- Target phrase
- Population size
- Mutation rate
- Fitness exponent
- Generations per frame
Evolved into Traveling Salesperson (GA), Evolving a Picture from Triangles.