The genetic algorithm NEAT (NeuroEvolution of Augmenting Topologies) has been implemented to find an optimal neural network, capable of playing a dinosaur jumping game to a high level. The game is based on that found within the Google Chrome browser. To access the Google game, internet connection must be disabled.
Once an optimal neural network has been found, an svg file will be exported showing a visualisation of the connections and weights of this network.
The goal of the game is for the dinosaur character to avoid oncoming obstacles by either jumping over them, or ducking to avoid them. The speed at which the character runs increases as the players score increments. The game is over when the character comes into contact with an object.
The NEAT algorithm initially creates a several randomised neural networks, from a series of specified game inputs and actions to be taken. The game inputs in this instance, consist of parameters such as the distance of the closest oncoming object. An example of an action, would be to jump over an object. It then determines the success of each of these networks by assessing the scores achieved. Following this, subsequent networks are produced that a mutated versions of the must successful networks from the previous generation.
- Python 3.7
Click the button below to run the program in Gitpod.
-
Clone the repository into a local directory by running
git clone https://github.com/michael-drury/DinoJump-AI
-
Install necessary libraries by running
pip3 install -r requirements.txt
- numpy
- pygame
- neat-python
- graphviz
- matplotlib
- Run the repository by running
python3 main.py
- Michael Drury: Main project
- Code Reclaimers:
visualise.py