This week you will start by modifying the text-based GA code from Tuesday to use real-valued genes instead of characters. Gene values should be between -9.0 and +9.0. You will need to modify:
DNA: constructor(), calcFitness(), mutate()
Population: isFinished()
These routines have been moved to the top of the javascript file to make them easier to find.
[0.0, 1.1, 2.2, 3.3, 4.4, 5.5]
Once that is working properly, change the fitness function so that it evaluates the effectiveness of a gene string when used as a vehicle controller in the Braitenberg TEST environment. To get this working, you will need to copy sections of code from the test environment, like simReset(), simStep(),...
, so that your fitness function runs a single trial of the Bot simulation and uses the bot.fitness
(number of pellets collected) after 2000 steps as the fitness measure. Before running a foraging trial you will need to copy the genes to be tested into bot.genome
and make sure to have called bot.setController('genetic');
. The Bot code has been provided for you as a library
gaBot.js.
You will not have to modify the Bot code itself.
Once you are able to successfully evolve effective genetic controllers (fitness values > 125), return to the TEST environment and follow the instructions there to complete the homework assignment.
Fitness vs generation: