- Overview
- Features
- Motivation
- Project Description
- Installation
- Usage
- Screenshots
- Contributing
- Credits
- License
- Contact
- Learn More
Welcome to the Dino-AI-NEAT project! This project integrates the classic Chrome Dino game with NEAT (NeuroEvolution of Augmenting Topologies) AI using Python and Pygame. Witness the AI evolve and master the game, surpassing human capabilities in dodging obstacles.
- AI Framework: NEAT-Python
- Game Engine: Pygame
- Language: Python
- Dynamic AI Training: Utilizes the NEAT algorithm to train neural networks.
- Real-Time Visualization: Observe the AI's learning process and evolution live.
- User-Friendly Graphics: Engaging and smooth game graphics.
- Customizable Settings: Easily modify NEAT and game parameters for personalized experiments.
I was inspired by the classic Chrome Dino game and wanted to explore the capabilities of NEAT AI fun and engagingly.
This project was built to showcase the potential of AI in learning and mastering simple games, providing a visual and interactive way to understand AI evolution.
The project demonstrates how AI can learn and adapt to new challenges, which is fundamental in various real-world applications.
Throughout this project, I learned about integrating game development with AI, the intricacies of the NEAT algorithm, and how to visualize AI training processes.
Combining a beloved classic game with advanced AI techniques, real-time visualizations, and a customizable setup makes this project unique and educational.
This project integrates the Chrome Dino game with NEAT AI to evolve and train a neural network to play the game. The AI starts with random neural networks and evolves over generations. Each generation's performance is evaluated based on the distance traveled by the dino. The best-performing networks are selected to produce offspring for the next generation, gradually improving their ability to navigate the game.
Dino-AI-NEAT/
โโโโmodels
โโโโsrc
โโโโassets
โ โโโโBird
โ โโโโCactus
โ โโโโDino
โ โโโโOther
โโโโclasses
-
Clone the Repository:
git clone https://github.com/Techiral/Dino-AI-NEAT.git cd Dino-AI-NEAT
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Game:
python src/main.py
To play against the pre-trained AI, run these commands:
cd src
python game.py -d Normal
You can replace the -d
tag (difficulty) with the difficulty level you would like to play against. Available difficulties are Normal
, Hard
, and Impossible
. Each difficulty is trained by setting a fitness threshold of 147, 233, and 370, respectively.
To train a dinosaur, first edit the fitness_threshold
inside config.txt
in the src
folder to whatever fitness threshold you want to train to. Note that you will have to wait until this threshold is met and the program closes itself before being able to save this dinosaur to be used later. On closing, the program will save the dinosaur to the models
folder as dino_f{fitness_score}.pkl
.
After setting your fitness_threshold
, run:
cd src
python agent.py
The game itself is in train.py
, but the training starts from agent.py
which handles the initialization of NEAT, as well as saving the "winner".
We welcome contributions from the community! Here's how you can get involved:
- Fork the Project: Click the
Fork
button at the top-right of this page. - Create Your Feature Branch:
git checkout -b feature/AmazingFeature
- Commit Your Changes:
git commit -m 'Add some AmazingFeature'
- Push to the Branch:
git push origin feature/AmazingFeature
- Open a Pull Request: Navigate to your forked repository on GitHub and click the
New Pull Request
button.
- Techiral: GitHub
- Tutorials and References: NEAT-Python Documentation
This project is licensed under the MIT License. You are free to:
- Use: Use the code in any project.
- Modify: Make changes to the code.
- Distribute: Share the code with others.
- Commercial Use: Use the code in a commercial project.
Under the following terms:
- Attribution: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
For more details, see the LICENSE file.
Feel free to reach out for collaboration or questions!
- Watch the Full Tutorial: AI Learns How To Play The Chrome Dinosaur Game
- Read the Blog Post: Mastering Chrome Dino with AI