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.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.5.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file snake_gym_grid-0.0.5.tar.gz
.
File metadata
- Download URL: snake_gym_grid-0.0.5.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 | c7955459c90abb7796bb9623acddf20ffc6e0c7f12c637ab1267a713667fda0e |
|
MD5 | cbf33fc2b11d9f46f4993c23cc378d5d |
|
BLAKE2b-256 | 30dfd56da73e75b771b1c6e0ca0089c17a3d10052fb18e42ff2589547aba0e5f |
File details
Details for the file snake_gym_grid-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: snake_gym_grid-0.0.5-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 | 945a76396a80816014dfa6f6870db4c3fe03fe77b949c160eb0c24f4472495ac |
|
MD5 | 32688b54aedf38845fb2e10ee2f1f861 |
|
BLAKE2b-256 | 9b87931d4dde7b645b24ca6bd91fbebc469a283aa398c7414251b6887a3f1936 |