I spend a while learning about Reinforcement Learning and Deep Q-Learning.
I implemented a SnakeGym openai environment and trained a DQN agent to play the game.
The agent was able to play the game with after 1.3 Million training episodes (took 12 hours to train and still is not optimal). For the future I will look into implementing asynchrounous training algorithms.
Run pip install -e snake
to register the environment.
Use agent.py
as reference to register a different type of environment.
Run python DQN.py
to restart training the DQN Agent.
Run python agent.py
to showcase the training
0 = UP
1 = DOWN
2 = LEFT
3 = RIGHT
DQN.py contains a Deep Q-Learning Solution to an agent that learns through a Convolutional Neural Network.
Keras-rl2 is required to start training. Check this Repository for more info.
DQN.py saves the trained model at certain checkpoints (every 100000 Steps).
If you want to test the already trained model then just run agent.py.