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=True)
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.3.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file snake_gym_grid-0.0.3.tar.gz
.
File metadata
- Download URL: snake_gym_grid-0.0.3.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 | 51f05c412de94ae8d9a4c3895028da880575bd1a7fac0bb0f4daf619da0c5f30 |
|
MD5 | ff1cb1f2d546601ff78395dfbd9efe4d |
|
BLAKE2b-256 | b8285c05122be55ab754a5a00c23d2388e469f8017ffba49600cb27bd0b8df2f |
File details
Details for the file snake_gym_grid-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: snake_gym_grid-0.0.3-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 | 5ccdf84ffd1d4f4e0798ce534ceaff922fc2e22441caeb54a18068a3f0a7da44 |
|
MD5 | 7f59e2514dd901574c52a3b82bf8af9f |
|
BLAKE2b-256 | 8a6624311c930798f2f269d8f53cf4769e84d6fd0d2bd8177fe54e7a70cda952 |