It is a simple architecture of 4 layers of neurons.
-
First Layer has 10 input parameters.
-
Distance from top wall.
-
Distance from top-right wall.
-
Distance from right wall.
-
Distance from bottom-right wall.
-
Distance from bottom wall.
-
Distance from bottom-left wall.
-
Distance from left wall.
-
Distance from top-left wall.
-
Distance from the destination.
-
Angle towards the distance.
-
-
Second Layer is a 10 node hidden layer.
-
Third layer is also a 10 layer hidden layer.
-
The final output layer consists fo 4 nodes. Each signifying the urge to move in one direction.
-
Move Top
-
Move Right
-
Move Bttom
-
Move Left
-
Each layer is connected to all the nodes from previous layer with some weight and biases.
This model uses Sigmoid activation function for all layers.
Cost of the bot is measured by calculating distance from next checkpoint. This model tries to maximize the points. after each checkpoint it adds 10000 points.
This system is simplest form of neural network. Thus I have not implemented any backpropagation for learning. Thus it relies on ramdom luck for minimizing cost.
Every weights and biases changes on each generation. Each generation generates 500 bots. among last 500 generation, 100 best performing bots weight and biases are tweeked by small value at random thus random learning. There is an small chance of some bots being offspring of one of lower 400 bots.
Requirements of this project are listed in requirements.txt. To install all requirements execute following code.
pip install -r requirements.txt
To Train, clone this repo and execute following commmands
python main.py
I have trained for about 3 hours to 200 generations. But best run was from generation 139. because it is a random chance, learning peaked after 139 generations. Till this generation I could train to pass 1st checkpoint. This model could not find weights for passing 2nd checkpoint whatsoever.
Result of Start of Training in generation2
Result of crossing 1st big obstacle generation 52
Result of crossing 1st Checkpoint in generation 139