Using neural networks and a genetic algorithm, I made this project that simulates evolution. First of all, all the weights of the neural networks are completely random. Fitness is calculated by how far the car travelled, and how fast it goes. Fitness is used to decide which car did the best, so it's 'genes' are passed on to its 'offspring' with slight mutations (depending on the mutation rate). The way the actual neural network works is 3 distances and the current speed of the car are fed into it as input. Each input is multiplied by a weight and added up. This then goes through a sigmoid squashing function to squash it down. This makes one neuron. This happens many times as it is passed through the layers of the neural network. There are 3 inputs, one hidden layer with 5 nodes, and 3 outputs which control the car. I find it incredible how the cars know nothing about the track or what their aim is and are just fed a bunch of numbers, but are still able to (in some cases) learn to navigate around the track.
Thanks to all the videos I've watched on YouTube that have helped me develop my understanding on exactly how neural networks work and how the genetic algorithm works! IF THE CARS DO NOT LEARN/EVOLVE PROPERLY: .Try experimenting with changing the 'mutation rate' variable using the slider. .Change the number of cars (using slider). .Start again (sometimes the cars that start off just aren't that good for evolution)