In this lab you will be observing the evolution of a neural network brain to control a robot. The evolving robot, which is green, is situated in a simple enclosed world with an avoiding robot, which is red. The avoiding robot is running a fixed control program that moves it straight forward unless it senses an obstacle, and then it will turn away from the obstacle. If the avoiding robot is ever jammed against an obstacle, it will try random movements to free itself.
The behavior of the evolving robot is scored by a fitness function that is based on four components:
The evolving robot has a neural network brain that consists of three fully connected layers: input (size 6), hidden (size 4), and output (size 2). The activations on the input layer represent the current sensor values: the minimum value of all of the front sonars, the minimum value of all of the back sonars, the range to the nearest red object, and the location of the nearest red object. The activations on the output layer represent the translation and rotation speed of the robot's next movement.
You will be using a genetic algorithm to find appropriate weights for the neural network brain of the evolving robot. For this particular experiment, the genetic algorithm consists of a population of 10 possible sets of weights for this brain. Initially these weights will be given random values. On each generation, each set of weights will be tested on the evolving robot for 250 time steps using the fitness measure described above. The weights that receive the best fitness scores will tend to be selected for inclusion in the next generation. Selected weights may also undergo crossover and mutation. This evolutionary process will continue for 5 generations.
python GAFindBlob.py &This will put the robots into a starting configuration, load a new set of weights onto the evolving robot (colored green), and start both robots running. After 250 steps, you will see a printed message showing the fitness score for that particular set of weights. Then the next set of weights will be tested in the same way. After the entire population has been tested, you will see a printed message summarizing the generation just completed. In the initial generations, many of the weights will result in very poor behavior. The evolving robot may immediately crash into a wall and never move again. However, as the process continues, you should begin to see more interesting behaviors emerge.
Done evolving at generation 5You should type:
xgraph test.avg test.best
python TestWeights.py test-gen1.wts &Once you've seen enough, type endpyrobot to stop. To try a different set of weights just replace the "1" in the above command with the appropriate number. Sometimes it may take up to 30 seconds for the computer to release the ports you'll need to reconnect to the simulator. If you see a message Waiting on PyrobotSimulator, just type endpyrobot and wait a few more seconds before trying again.
Email me your summary of the experiment.