This is a genetic algorithm experiment. My goal was to simulate an autonomous car that could go around a dynamic track.
At first, a car is spawned with a neural network attached to it. This network is initialized with random weights and biases that will in turn cause the car to behave randomly. When the car dies i.e. hits the road borders, a new car is spawned with a slightly mutated version of the previous car's neural network. This mutation causes the new car to develop new behaviours. To speed up learning, I stored the previous best performing neural network and compared it to the current neural network by calculating the car's fitness. The fitness value determines how good the car is currently performing (see here for more details). If the current car dies before reaching a better fitness level than the previous best performing neural network, then the next car is spawned using the previous best neural network rather than the one from the car that just died. This process is repeated over and over again until an optimal neural network is found.
- Clone this repository using
git clone https://github.com/rashadaziz/autonomous-car.git
- Make sure you have Node.js installed.
- Open your terminal in the directory you cloned this repository in.
- Type
npm i
to install the project's dependencies. - Type
npm run dev
to run the project using (Vite)[https://vitejs.dev/] - Open
http://localhost:5173/
in your browser.
Credits to: https://github.com/gniziemazity and the creators of Paper.js