Skip to content

Snake game environment integrated with OpenAI Gym. Proximal Policy Optimization (PPO) implementation for training. Visualization of training progress and agent performance. Easy to understand code.

License

Notifications You must be signed in to change notification settings

RsGoksel/Snake-Game_PPO-Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake-Game_PPO-Solution

Snake game environment integrated with OpenAI Gym. Proximal Policy Optimization (PPO) implementation for training. Visualization of training progress and agent performance. Easy to understand code.

What is PPO?

PPO stands for Proximal Policy Optimization. PPO uses a "proximal" objective function to ensure stable policy updates. It uses a clipping mechanism to prevent large policy updates, which makes training more stable.

image

Problem

The classic snake game was discussed for the PPO solution example as problem.

  • Reward: Reward was the distance between the apple and agent. The closer get to the apple, the more rewards get.
  • Observation Space: Observation array was "Snake_X, Snake_Y, Apple_X, Apple_Y, Euclid_Distance_Apple_to_Snake".
  • Action Space: Action space was discrete. Because the screen of game was tiled, and we have 4 directions for move.".

Usage

$ pip install -r requirements.txt
  • test.py : Testing for the environment. You can display how game screen is.
  • train.py : Trains the Agent for learning the game.
  • Agent.py : Snake agent's class.
  • env_PPO.py: Main game source code. You can alter the game if you want add some hardness to game.
  • Snake_PPO.ipynb : Comprehensive file that involves whole code and attributes.

For testing,

$ python test.py

For training,

$ python train.py

Also, you can alter the constant variables from Constants.py file Especially PPO hyperparameters.

AgentPlay

Agent

About

Snake game environment integrated with OpenAI Gym. Proximal Policy Optimization (PPO) implementation for training. Visualization of training progress and agent performance. Easy to understand code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published