Using artificial neural networks and genetic algorithm to train bot to play Chrome Dino game.
Each dino in the population has 2 neural networks:
-
Neural network responsible for avoiding cactuses - 5 inputs, 8 hidden and 2 output neurons. Inputs to this neural network are:
- Horizontal distance to the next obstacle
- Height of the next obstacle
- Width of the next obstacle
- Dino's y position
- Game speed
Net has 2 outputs - Dino will jump if the first output is greater than the second.
-
Neural network responsible for avoiding the birds - 6 inputs, 10 hidden and 3 output neurons. Inputs to this neural network are:
- Horizontal distance to the next obstacle
- Height of the next obstacle
- Width of the next obstacle
- Obstacle's y position
- Dino's y position
- Game speed
Net has 3 outputs - jump, duck, nothing.
- Population size: 100
- Elitism: 0.2
- Random behaviour: 0.2
- Mutation rate: 0.1
- Mutation standard deviation: 0.5
- Number of children: 1
Each neural network flattens to one-dimensional array of weights. First elements of the array are the weights connecting input layer with the first hidden layer and so on.
Child firstly takes all the weights from one of its parents. For every weight of the child's network, there is a 50% chance for it to be replaced with the corresponding weight of the second parent's network.
Selection algorithm used is Pool selection.
- Weight of the line indicates how strong the net weight is
- Blue means weight is positive
- Red means weight is negative
Java Processing 3.5.4: https://processing.org/
This program is free.
You can redistribute it and/or change it under the terms of GNU General Public License version 3.0 (GPLv3).
You can find a copy of the license in the repository.