After following along with Josh Bongard’s evolutionary robotics course, I became interested in this experiment by Floreano and Mondada, 1996, where little Khepera robots are evolved to avoid walls while running through a track. I wanted to recreate its findings but within a 2D simulation so I could speed up the process. I chose to implement it with Box2D, as I have had much experience with it in the past.
The Kheperas sensors are represented as ray casts into the environment and return a signal depending on how close it is to an object. The signal is fed into a model of the simple neural network described in the paper, the output of which is fed to the wheels for drive. The weights of the neural network are controlled by each Khepera’s “genes”, so any combination of genes creates a unique controller for the Khepera. The track is created by taking the convex hull of a cluster of random points and expanding it along the normals to create track walls.
The simulation involves a number of Khepera entities are spawned randomly around the track with their genes randomized. They operate for a set amount of time, after which time the fittest are ranked based on the fitness function described in the paper and at least 2 are selected via a roulette wheel selection process. The selected become the parents for the next generation, with their genes mutated and crossed over. The process repeats until a neural controller is evolved that satisfies the fitness function.