Skip to content

snake-gym is implementation of the classic game snake that is made as an OpenAI gym environment

License

Notifications You must be signed in to change notification settings

Platun0v/snake-gym

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snake-gym

Description

snake-gym is implementation of the classic game snake that is made as an OpenAI gym environment

Dependencies

  • gym
  • numpy
  • torch

Installation

  1. Clone repository: $ git clone https://github.com/Platun0v/snake-gym.git
  2. cd into snake-gym and run: pip install -r requirements.txt

Using ready-made programs

Test network

To see pretrained snake run: python test.py

Parameters

  • load_path - path to neural network
  • render - render process
  • times - how many times to run
  • seed - seed
  • blocks - number of blocks on square grid
  • block_size - the size of block in pixels

Train network

To train snake run: python train.py

Parameters

  • save_path - path to save neural network
  • render - render process
  • episodes - how many times to run
  • seed - seed
  • blocks - number of blocks on square grid
  • block_size - the size of block in pixels

Using enviroment

import gym
import gym_snake

env = gym.make('Snake-v0')

for i in range(100):
    env.reset()
    for t in range(1000):
        env.render()
        state, reward, done, info = env.step(env.action_space.sample())
        if done:
            print('episode {} finished after {} timesteps'.format(i, t))
            break

https://habr.com/ru/post/465477/

About

snake-gym is implementation of the classic game snake that is made as an OpenAI gym environment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages