A Fuller Exploration of the System
- Now we're going to change the code to look for the smallest
set of digits (all 0s).
- You need to do two things.
- The first is to change WORST_VALUE at the top. You can just
change the comments so that the big number (all 9s +1 is worst).
- The second is to change firstIsBetter. Note that there is a warning
(a yellow bit on the right) by firstIsBetterSmall. Change
firstIsBetter to firstIsBetterLarge and firstIsBetterSmall to
firstIsBetter. (The yellow bit should now be on firstIsBetterLarge
the uncalled function.)
- Now if you run it, you should move toward 0.
- It may not get there. You can run it longer and it will.
- However, it's all based on randomness, and each time you run it, you
get the same random numbers. You can change the seed, right below
WORST_VALUE, to get a different set.
- You can also play with POPULATION_SIZE, PARENTS_BREEDING, MUTATION_RATE
and of course GENERATIONS_TO_RUN to explore. You can even
change GENES_IN_MEMBER.
- Finally, you can also change it to search for particular digit strings.
- In evaluateMember, switch the comments so that you're calling
evaluateMemberDistanceFromSearch instead of evaluateMemberSum.
- You can also change the searchValue string. (If you pick a number
closer to 0 than 90, you need to change WORST_VALUE too.)