Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d4niee/deepqlearning-snakegame
This project implements an AI that learns the Snake game through Deep Q-Learning. It uses Fast Forward and CNN-based training to learn the optimal game strategy and visualises the learning process.
https://github.com/d4niee/deepqlearning-snakegame
ai artificial-intelligence atari cnn deep-learning deep-q-learning deepmind dqn dqn-pytorch fast-forward matplotlib neural-network python pytorch retro snake snake-game
Last synced: about 1 month ago
JSON representation
This project implements an AI that learns the Snake game through Deep Q-Learning. It uses Fast Forward and CNN-based training to learn the optimal game strategy and visualises the learning process.
- Host: GitHub
- URL: https://github.com/d4niee/deepqlearning-snakegame
- Owner: d4niee
- License: apache-2.0
- Created: 2023-06-24T13:33:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-08T11:59:24.000Z (about 1 year ago)
- Last Synced: 2023-10-08T12:32:53.310Z (about 1 year ago)
- Topics: ai, artificial-intelligence, atari, cnn, deep-learning, deep-q-learning, deepmind, dqn, dqn-pytorch, fast-forward, matplotlib, neural-network, python, pytorch, retro, snake, snake-game
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Install Repo
1. Clone the repo.
2. Navigate to the folder.
3. Install poetry: pip install poetry
4. Enter "poetry install" in the powershell
5. "poetry shell"## Add new library
poetry add name## Components DQN
``Agent_DQN``: This is the main class representing the DQN agent. It contains methods for storing and retrieving experiences (memory), performing actions based on the current state (get_greedy_action), training the model with stored experiences (train_long_term_memory) and performing a training step based on the current experience (train_short_term_memory). It also contains a method to perform training sessions (training) and to play the game with the trained model (play).
``DQN``: This is the class that represents the DQN model. It is a Convolutional Neural Network (CNN) consisting of three Convolutional Layers and two Fully Connected Layers. The forward method performs a forward traversal through the network. There are also methods to initialise the weights of the model (weights_init), to save the model (save) and to load a saved model (load).
``SnakeGameAI``: This is the class that represents the Snake game. It contains methods to initialise the game (init), reset the game (reset), place food (place_food), perform a move (play_step), check if a collision has occurred (is_collision), and update the user interface (_update_ui).
``DQN_Trainer``: This is the class that manages the training of the DQN model. It contains a method to perform a training step (train_step) where the weights of the model are updated to minimise the difference between the predicted and target Q values.