Training an AI to play the classic Snake Game!
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This project is about making a sophisticated AI that can play the classic Snake Game efficiently. The goal was not only to cultivate the AI's ability to survive in the game, but also to potentially maximize the score that it can achieve.
This section should list any major frameworks/libraries used to bootstrap your project.
Due to the project being constructed in Unity, you would need to have Unity and IDE support for Unity projects installed on your machine.
This is a list of things you need to use the software and how to install them.
Install the following software:
Perform the following steps to set up and run the project:
-
Clone the repo
git clone https://github.com/Pristar4/SnakeGame.git
-
Set up the virtual environment in the mk-agents folder under SnakeGame\ml-agents by running:
python -m venv ./venv
-
Activate your virtual enviroment:
.\venv\Scripts\activate
-
Install ML-agents:
python.exe -m pip install --upgrade pip
-
Install torch:
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
-
Install Tensorflow
pip install tensorflow
-
Install ml-agents-env
pip install -e ./ml-agents-envs
-
Install ml-agents
pip install -e ./ml-agents
-
install tensorboard
pip install tensorboard
-
Start the training by running:
mlagents-learn config/ppo/Snake.yaml --run-id=trainingRun01
-
start TensorBoard to monitor training:
tensorboard --logdir results
-
Enter the Play mode in the Unity editor in the AI scene under
SnakeGame\Assets\SnakeGame\_Levels\AI
Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.
For more examples, please refer to the Documentation
- Working Prototype
- Working ML-Agents implementation
- Refactor out of SnakeAgent as GameManger
- Player vs AI
- Support multiple Snakes
- Snake BattleRoyale / Match Handler
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- 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
Distributed under the MIT License. See LICENSE
for more information.
Felix Jung - [email protected]
Project Link: https://github.com/Pristar4/SnakeGame