An implementation on Snake game with grid display
Project description
snake-gym
This package is my own implementation on Snake game with Gym integration.
Usage
import gym
import snake_gym_grid
env = gym.make("snake-gym-10x20-v0", new_step_api=True, render_mode="human")
env.reset()
done = False # whether the snake dies
"""
action ranges from 0 to 3.
0 - LEFT
1 - RIGHT
2 - UP
3 - DOWN
"""
action = ...
observation = env.reset()
while not done:
env.render()
# I just use truncate because it's recommended by Gym
# However, you may not need it
# It signifies whether the game is running for more than 100000 steps
observation, reward, done, truncate, info = env.step(action)
env.close()
Output at each time step
- observation: Pixel image of the game
- reward: 1.0 when a food is eaten 0.0 otherwise
- done: whether the snake dies
- truncate: whether the game is running for more than 100000 time steps
- info: an empty dictionary for now
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
snake_gym_grid-0.0.4.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file snake_gym_grid-0.0.4.tar.gz
.
File metadata
- Download URL: snake_gym_grid-0.0.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72157a10fd6c8237b755f3b1767a01ba743255efc39bacd004b3558061c90fa2 |
|
MD5 | fce1bc51386a1602ff4f9facc4ff1964 |
|
BLAKE2b-256 | 53a6d4c1c1aaa03df8e76c7508eb0f6c0a7b9ec07a8a88798c86231dc682879b |
File details
Details for the file snake_gym_grid-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: snake_gym_grid-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32f6ab851df0076712294df93a4f252712c29808b53c1416982076c263af8ec8 |
|
MD5 | 1776d60beda390ae163b8167c2f2337c |
|
BLAKE2b-256 | da6f4fcfb6cb6442673963243996a5e9d0b74a8dc5b647db4ff6d769335f0ed0 |