Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.