nature-of-code / noc-examples-processing

Repository for example code from The Nature of Code book
MIT License
2.56k stars 950 forks source link

Shakespeare Genetic Algorithm: Question/Contribution #107

Open BartholemeuChamberlain opened 5 years ago

BartholemeuChamberlain commented 5 years ago

Contribution: A Java version of the Shakespeare Genetic Algorithm Challenge: https://github.com/BartholemeuChamberlain/Shakespeare-Genetic-Algorithm

I added a piece of functionality to the DNA's ability to retain correct answers, specifically in the Mutation function. After converting from the Processing language to Java, I noticed that the program was not evolving after thousands of generations. Debugging through the DNA code, I noticed that the Mutation function was doing its job TOO well. This function was replacing the correct answers that the system was guessing. So I added the functionality that would skip the correct characters and only mutate the wrong answers (still based on the mutation rate). After this change, the system was able to get the correct answer in approx. 80 generations

Question: Does this adjustment still follow proper Genetic Algorithm principles,? If not what adjustment should I have considered before this change?