Skip to content

Reinforcement Learning AI model that can be trained to master the snake game (WIP)

Notifications You must be signed in to change notification settings

dtellz/ai-beats-snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Learns To Play Snake! Reinforcement Learning With PyTorch and Pygame

In this Python Reinforcement Learning Project I build an AI and then teach it to play Snake! I build everything using Pygame and PyTorch.

Key steps:

  • Implement the Snake game.
  • Implement the Agent that controls the game.
  • Implement the neural network to predict the moves and train it.

After 500+ games on V1

After 1000+ games on V1

Model haven't beat its own record but it gets better averaged results every game

TODO:

  • Avoid the AI to trap itself
  • Don't let her get in a loop for too long
  • Increase game speed to increase training speed

Dependencies

I have used Anaconda to create the python env

conda create -n pygame_env python=3.7

I used pyGame to create the game environment

pip install pygame

I used pyTorch to create the model

pip install torch torchvision

Extra deps:

pip install matplotlib ipython

About

Reinforcement Learning AI model that can be trained to master the snake game (WIP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages