Adapted from https://natureofcode.com/book/chapter-9-the-evolution-of-code/ which uses Processing.
There are optimizations for this (need more variability/improve heredity) such as:
- Use less ASCII characters.
- Crossover to give each gene 50% chance of coming from parentA and 50% chance of coming from parentB
- Replace calculated fitness scores with ordinals of scoring (their rank)
- When retrieving two parents for mating, ensure they are not the same parent