Skip to content

Plays the game of Snake using Deep Q-learning, a type of reinforcement learning that utilizes a neural network instead of a traditional 2D matrix to make action decisions

Notifications You must be signed in to change notification settings

mtlynch3/deepQ_snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

deepQ_snake

To run: python3 snake.py

Made using pytorch and pygame.

The agent (snake) learns to play the game via Deep Q-learning. A type of reinforcement learning, a Q-learning agent will recieve awards from the environment (game) based on its actions. It will then use this reward to update its policy (how it makes decisions ie chooses the next move). The policy is a 2-layer neural network: the inputs are 11 boolean parameters, a hidden layer of size 256, and an output layer of size 3. The inputs to the network are: immediate danger straight ahead, to the left or right; the direction the snake is currently moving, up, down, left, or right; the direction of fruit in relation to the snakes position, above, below, left, or right. The network ouputs the probabilities of maximum reward for all 3 directions. The maximum of the 3 probabilities (the action that maximizes reward) is chosen.

About

Plays the game of Snake using Deep Q-learning, a type of reinforcement learning that utilizes a neural network instead of a traditional 2D matrix to make action decisions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages