Skip to content

Neural network that learns through an evolutionary algorithm how to play the Chrome Dino Game.

License

Notifications You must be signed in to change notification settings

Scr1pting/Chrome-Dino-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neuroevolutionary Chrome Dino AI

GIF Showing Successful AI

This project uses an evolutionary algorithm that updates a neural network to master the Chrome Dino Game. The game is shown when a user is offline and when opening chrome://dino.

All parameters are set in src/ai/evo.py. Feel free to update them!

The pure game implementation is available at Scr1pting/Chrome-Dino-Game.

Neural Network

The neural network consists of the following four layers:

  • Input: Game speed, distance to the next obstacle, and that obstacle's height.
  • Hidden Layers: 2 hidden layers with 16 neurons each.
  • Output: Three values for jump, duck, or run. The action with the highest value is performed.

Evolution

The weights and biases of the neural network are updated by an evolutionary algorithm. The evolutionary algorithm has the following specifications:

  • Genome: Each genome represents the weights and biases of the neural network. Initially, they have random values. There are 100 genomes in total.
  • Fitness: A genome is fitter if the dino collected more points. The points correspond to the distance the dino traveled.
  • Selection: the fittest 10% are included in the next generation. By 100 genomes in total, that corresponds to 10 selected genomes. Each of the selected genomes therefore forms the basis for 10 genomes of the next generation.
  • Elitism: The selected genomes are included once in the next generation without changes. This means that a particularly fit genome is not lost due to a negative mutation.
  • Mutation: With a probability of 20%, a weight or bias of a genome is increased or decreased by a random value in the new generation.

Crossover (that two genomes are combined) was not implemented because it did not yield good results.

Run

Run python3 src/main.py to see the dino evolve.

Packages

The project uses Pygame for the implementation of the game and Numpy for the AI.

About

Neural network that learns through an evolutionary algorithm how to play the Chrome Dino Game.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages