Snake game for Farama Gymnasium
Project description
Snake game for Farama Gymnasium
This project is based on Snake game for OpenAI Gym by Ming Yu.
Additional changes include:
- changing observations to 2D image data
- fixing display settings code
- changing default parameters, including rewards, board size, and colors palette
Snake game for OpenAI Gym
Quick Start
import gym_snake_game
import gymnasium
# both work
env = gymnasium.make('Snake-v0', render_mode='human')
env = gym_snake_game.make('Snake-v0', render_mode='human')
env.reset()
# for human playing
env.play()
# for ai playing
while True:
obs, reward, done, truncated, info = env.step(env.action_space.sample())
if done:
break
env.close()
Available Options
import gym_snake_game
options = {
'fps': 60,
'max_step': 500,
'init_length': 4,
'food_reward': 2.0,
'dist_reward': None,
'living_bonus': 0.0,
'death_penalty': -1.0,
'width': 40,
'height': 40,
'block_size': 20,
'background_color': (255, 169, 89),
'food_color': (255, 90, 90),
'head_color': (197, 90, 255),
'body_color': (89, 172, 255),
}
env = gym_snake_game.make('Snake-v0', render_mode='human', **options)
Requirements
- Python >= 3.0
- Numpy >= 1.23.2
- Pygame >= 2.1.3
- Gymnasium >= 0.29.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gymnasium_snake_game-0.2.1.tar.gz.
File metadata
- Download URL: gymnasium_snake_game-0.2.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a414de2c5968acedd786b2ff34d71774e48e813654ec454f63874e4fbeb2468
|
|
| MD5 |
20a278dd8fe7435ac477b9def56839c3
|
|
| BLAKE2b-256 |
8c7a13cb153c0042a39c5a379c7f24c2c37f22a386a8afb28fa84239e17b819e
|
File details
Details for the file gymnasium_snake_game-0.2.1-py3-none-any.whl.
File metadata
- Download URL: gymnasium_snake_game-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3ea0822675ce837f46a1d01bed1f6eba6307ea5c8001a4ebc78df7c84a4ca1e
|
|
| MD5 |
c8034fde581c383391a6675e41c02800
|
|
| BLAKE2b-256 |
a85f0c1a4a9cabf231c664a4e1bbc46c081ae02afeb3973e4f8456432468ae18
|