Skip to content

antoineBarbez/DeepSnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepSnake

A simple implementation of Deep Q-learning for playing the famous Snake game.

Training

To train your own agent to play on a 10x10 grid:

import dqn.agent as agent

dqn_agent = agent.DQNAgent(grid_size=10)
dqn_agent.train(save_name="my_model")

At the end of the training, the model will be saved in ./dqn/trained_models/.

Note that this code uses the default configuration but you can modify any of the learning parameters of the train() function, e.g., num_steps, batch_size, learning_rate etc...

Playing

To watch a pre-trained agent playing the game:

import dqn.agent as agent
import game.snake_game as game 

dqn_agent = agent.DQNAgent(grid_size=10)
dqn_agent.load_model("dqn-10x10x2")

snake_game = game.SnakeGame(grid_size=10)
snake_game.play(dqn_agent)

You can also play the game on your own using the keyboard arrows:

import game.snake_game as game

snake_game = game.SnakeGame(grid_size=10)
snake_game.play()

About

Deep Reinforcement Learning applied to the Snake game

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages