Table of Contents
In this project I have created a DQN agent to train in a snake game environment. The objective of the snake is to collide(eat) all the food that is placed randomly in the environment.
This project is built with the below given major frameworks and libraries. The code is primarily based on python. And the environment is created using Anaconda.
Simply clone the repo cd into the right directory and run agent using the below commands. Step-by-Step instructions given below. Simply change the directory and run agent.py
from the directory RL_car_game
. You will be able to see the agent training and getting better in minutes.
-
Clone the repository using
git clone https://github.com/sudharsan-007/RL-DQN-Snake-Game.git
-
cd into the directory RL-DQN-Snake-Game
cd RL-DQN-Snake-Game
-
Recommended: create a conda environment
# We require python>=3.7 conda create -n rl_snake_game python=3.7 numpy matplotlib conda activate rl_snake_game
-
Install pygame
pip install pygame pip install ipython pip install matplotlib
-
Install pyTorch (CPU verison). Please refer pytorch website to get right version for GPU.
# https://pytorch.org/get-started/locally/ conda install pytorch torchvision torchaudio cpuonly -c pytorch
-
If the above code does not work for you try this(skip this step 5 worked).
pip3 install torch torchvision torchaudio
-
Run
agent.py
from this directory and from inside this environmentpython agent.py
-
To run the environment without Reinforcement Agent and the agent controllable by WASD keys
python snake_game.py
Distributed under the MIT License. See LICENSE.txt
for more information.