# Snake game for Farama Gymnasium
This project is based on [Snake game for OpenAI Gym](https://github.com/NaLooo/Gym_Snake_Game) 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
![Python versions](https://img.shields.io/pypi/pyversions/gym-snake-game)
[![PyPI](https://img.shields.io/pypi/v/gym-snake-game)](https://pypi.org/project/gym-snake-game/)
[![License](https://img.shields.io/github/license/NaLooo/Gym_Snake_Game)](https://github.com/NaLooo/Gym_Snake_Game/blob/main/LICENSE)
![screenshot](/resource/screenshot.png)
## Quick Start
```python
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
```python
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
Raw data
{
"_id": null,
"home_page": "https://github.com/lychanl/Gymnasium_Snake_Game",
"name": "gymnasium-snake-game",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": "",
"keywords": "ai,rl,snake",
"author": "Jakub \u0141yskawa",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/8c/7a/13cb153c0042a39c5a379c7f24c2c37f22a386a8afb28fa84239e17b819e/gymnasium_snake_game-0.2.1.tar.gz",
"platform": "any",
"description": "# Snake game for Farama Gymnasium\n\nThis project is based on [Snake game for OpenAI Gym](https://github.com/NaLooo/Gym_Snake_Game) by Ming Yu.\n\nAdditional changes include:\n - changing observations to 2D image data\n - fixing display settings code\n - changing default parameters, including rewards, board size, and colors palette\n\n# Snake game for OpenAI Gym\n![Python versions](https://img.shields.io/pypi/pyversions/gym-snake-game)\n[![PyPI](https://img.shields.io/pypi/v/gym-snake-game)](https://pypi.org/project/gym-snake-game/)\n[![License](https://img.shields.io/github/license/NaLooo/Gym_Snake_Game)](https://github.com/NaLooo/Gym_Snake_Game/blob/main/LICENSE)\n\n![screenshot](/resource/screenshot.png)\n\n## Quick Start\n```python\nimport gym_snake_game\nimport gymnasium\n\n# both work\nenv = gymnasium.make('Snake-v0', render_mode='human')\nenv = gym_snake_game.make('Snake-v0', render_mode='human')\nenv.reset()\n\n# for human playing\nenv.play()\n\n# for ai playing\nwhile True:\n obs, reward, done, truncated, info = env.step(env.action_space.sample())\n if done:\n break\nenv.close()\n\n```\n## Available Options\n```python\nimport gym_snake_game\n\noptions = {\n 'fps': 60,\n 'max_step': 500,\n 'init_length': 4,\n 'food_reward': 2.0,\n 'dist_reward': None,\n 'living_bonus': 0.0,\n 'death_penalty': -1.0,\n 'width': 40,\n 'height': 40,\n 'block_size': 20,\n 'background_color': (255, 169, 89),\n 'food_color': (255, 90, 90),\n 'head_color': (197, 90, 255),\n 'body_color': (89, 172, 255),\n}\n\nenv = gym_snake_game.make('Snake-v0', render_mode='human', **options)\n\n```\n\n## Requirements\n\n- Python >= 3.0\n- Numpy >= 1.23.2\n- Pygame >= 2.1.3\n- Gymnasium >= 0.29.0\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Snake game for Farama Gymnasium",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/lychanl/Gymnasium_Snake_Game"
},
"split_keywords": [
"ai",
"rl",
"snake"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a85f0c1a4a9cabf231c664a4e1bbc46c081ae02afeb3973e4f8456432468ae18",
"md5": "c8034fde581c383391a6675e41c02800",
"sha256": "a3ea0822675ce837f46a1d01bed1f6eba6307ea5c8001a4ebc78df7c84a4ca1e"
},
"downloads": -1,
"filename": "gymnasium_snake_game-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c8034fde581c383391a6675e41c02800",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 7721,
"upload_time": "2024-03-18T13:54:30",
"upload_time_iso_8601": "2024-03-18T13:54:30.572550Z",
"url": "https://files.pythonhosted.org/packages/a8/5f/0c1a4a9cabf231c664a4e1bbc46c081ae02afeb3973e4f8456432468ae18/gymnasium_snake_game-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8c7a13cb153c0042a39c5a379c7f24c2c37f22a386a8afb28fa84239e17b819e",
"md5": "20a278dd8fe7435ac477b9def56839c3",
"sha256": "6a414de2c5968acedd786b2ff34d71774e48e813654ec454f63874e4fbeb2468"
},
"downloads": -1,
"filename": "gymnasium_snake_game-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "20a278dd8fe7435ac477b9def56839c3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 6783,
"upload_time": "2024-03-18T13:54:31",
"upload_time_iso_8601": "2024-03-18T13:54:31.911351Z",
"url": "https://files.pythonhosted.org/packages/8c/7a/13cb153c0042a39c5a379c7f24c2c37f22a386a8afb28fa84239e17b819e/gymnasium_snake_game-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-18 13:54:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lychanl",
"github_project": "Gymnasium_Snake_Game",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "gymnasium-snake-game"
}