This is a Reinforcement Learning project. In this project, Agent(snake) learns how to play the snake game1. The game board is 12×12. The snake moves in the 10×10 area and eats the food. Eating the food increases the length of the snake. The snake must learn how to eat the food without running into the screen border or itself.
The learning algorithm is DQN.
Preview Algorithm Network State Hyperparameters Results References Useful Resources
score = 49 | score = 48 |
score = 46 | score = 46 | score = 43 |
DQN Pseudo Code (https://storage.googleapis.com/deepmind-media/dqn/DQNNaturePaper.pdf) |
The frame of the game after t transitions. It is converted to a 12×12 np array.
Frame |
(12 × 12) Np array |
Based on the Assignment4 of the Artificial Intelligence (CS 440/ECE 448) course from University of Illinois at Urbana–Champaign, 8 features were extracted from the frame as below:
[Adjoining_wall_x, Adjoining_wall_y, food_dir_x, food_dir_y, Adjoining_body_top, Adjoining_body_bottom, Adjoining_body_left, Adjoining_body_right]4
Some initializations have been adopted from this paper and this site.
Train |
Test |
[1] Wikipedia - Snake (video game genre)
[2] https://www.diva-portal.org/smash/get/diva2:1342302/FULLTEXT01.pdf
[3] PyTorch - REINFORCEMENT LEARNING (DQN) TUTORIAL
AI learns to play SNAKE using Reinforcement Learning (Square Robots)
How to automate Snake using Reinforcement Learning (DeKay Arts)