Drag the background!

Step 5. Genetic Algorithm

This program implements a Genetic Algorithm search to try to write a line of text.

Video

World

GA (Finnegans Wake)
Genetic Algorithm to write the first line of Finnegans Wake.

Notes

  • This program uses GA search to try to write the first line of Finnegans Wake.
  • This would be literally impossible to do by random search. But it happens in 1 minute with GA search.


Credits

  • This is a hugely modified port of "NOC_9_01_GA_Shakespeare_simplified" from AI course by Daniel Shiffman.
  • It actually started with the Processing version and converted it to JavaScript and P5.
  • In fact there is a P5 version.
  • Either way, many modifications have been made.
  • See his videos parts 9.1 and 9.2 and 9.3 and 9.4.

Exercise

Clone and Edit the World.
  1. Change the speed. See the "frameRate" line.
  2. Search for shorter and longer strings.
  3. Edit other constants. See what happens.
  4. Turn the debug info on and off to see how it works.

  5. Radically change population size, to 1 and to 10000. What happens? What is the best value?
  6. Radically change mutation rate, to 0 and to 1. What happens? What is the best value?
  7. Radically change POWERBASE, to 1 and to 1000. What happens? What is the best value?

  8. Instead of always doing crossover, have a probability of crossover. Make 2 children at a time. If no crossover, we get clones of the 2 parents. Edit the code and test it.

  9. Make probability of mutation start high and decline. Same with crossover. Does this help?

  10. Change to a much bigger problem. e.g. A large paragraph of text. Can you still get the GA to solve it?

The background is a program, showing the JavaScript graphics used on this site.
The globes light up when you log in.
 
Font:

Users retain ownership of user content.

Platforms      Stats      The name      Terms and conditions

Call for partners      Contact

Call for partners!
Ancient Brain is looking for a partner to co-write a JavaScript or Python coding book for schools, to be used worldwide. This would be a course for students in learning to code from scratch. The book and course will be integrated into the Ancient Brain site. This is an opportunity for someone looking to develop a course and textbook to partner with a site to promote it. Read more.