Assignment 5 - Genetic Algorithms

Lillian Ritchie and I teamed up to tweak the Nature of Code Simple Smart Rockets example. We had the idea to add gasoline grades to the rocket fuel which would control mutation rate, population number, and speed (via frameRate since there was no easy-access speed parameter). Here are links to the sketch and the code on Github.

With 87 grade, there are more rockets because gas is cheap, but the rockets do not run as well, with the mutation rate set to 0.5. Also the rockets run slower with a frameRate of 30. For 89 grade, the rockets are fewer in number to reflect the rising cost, but they run a little more efficiently with a mutation rate of 0.3 and are faster with a frameRate of 48. At 93 grade, the rockets numbers are at their lowest, but they run quite well with a mutation rate of 0.01 and a frameRate of 60.

We had to use the resetSketch() function from Dan’s video so that we could make new populations with the characteristics we desired. Changing the numbers on the fly would crash as it throws a wrench in the whole inheritability of each generation and splices and adds to arrays in a messy way. We also thought of having three separate populations and using the radio buttons to just show and hide them, but that seemed a bit overkill.