This demo walks through a Genetic Algorithm (GA) one lifecycle stage at a time so you can see exactly what happens between generations.
Problem: evolve a population of strings until one matches a target you provide (default CAIRO). Each chromosome is a list of letters, and its fitness is the number of letters that match the target in the same position. The run stops as soon as one string matches the target exactly.
Stages (shown as a badge at the top of the stage panel):
- Initial Population. Random strings, not yet scored.
- Fitness. Every string is scored against the target. Matching letters are tinted.
- Select Parents. The strings chosen to breed are highlighted.
- Crossover. Parents are combined into offspring. Cut points appear as dashed lines.
- Mutation. Random letters change. Mutated positions are tinted and underlined.
- Next Generation. The offspring become the new population, and elitism keeps the best.
A run starts when the page opens. Click Step (Next) to move one stage at a time, Prev to look back, or Play to let it run on its own (choose every stage or a whole generation per tick). Open Settings to change the run, then click Reset / Initialize. The chart tracks the best fitness across generations.