The AI model
Register a class
Coding course II
Coding for kids
Step 5. Genetic Algorithm
This program implements a
search to try to write a line of text.
GA (Finnegans Wake)
Genetic Algorithm to write the first line of Finnegans Wake.
Clone and Edit
This program uses GA search to try to write the first line of
This would be literally impossible to do by random search. But it happens in 1 minute with GA search.
This is a hugely modified port of "NOC_9_01_GA_Shakespeare_simplified" from
by Daniel Shiffman.
It actually started with the
In fact there is a
Either way, many modifications have been made.
See his videos parts
Clone and Edit the World.
Change the speed. See the "frameRate" line.
Search for shorter and longer strings.
Edit other constants. See what happens.
Turn the debug info on and off to see how it works.
Radically change population size, to 1 and to 10000. What happens? What is the best value?
Radically change mutation rate, to 0 and to 1. What happens? What is the best value?
Radically change POWERBASE, to 1 and to 1000. What happens? What is the best value?
Instead of always doing crossover, have a
of crossover. Make 2 children at a time. If no crossover, we get clones of the 2 parents. Edit the code and test it.
Make probability of mutation
start high and decline
. Same with crossover. Does this help?
Change to a much bigger problem. e.g. A large paragraph of text. Can you still get the GA to solve it?
Next: Step 6 of 9
Tweet this step: