Skip to main content

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")
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()
    observation, reward, done, 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


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.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

snake_gym_grid-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file snake_gym_grid-0.1.0.tar.gz.

File metadata

  • Download URL: snake_gym_grid-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for snake_gym_grid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d956a7d72bb668245a6290d3abdfda83d395fcb56819232d51e5cb16379af911
MD5 e08c6d094abfa4c5ee3c91f425c1e6d5
BLAKE2b-256 ad9ad55ed985112b5effe27cad3e27e2ab85023ec3d45674f2b4708204657eb8

See more details on using hashes here.

File details

Details for the file snake_gym_grid-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snake_gym_grid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d746236a040549e8ab3afe51f22b0f3437f257d2f9ddd905de64f0cbd0c6ae16
MD5 43f36d922616affae0dbc62ea62423e8
BLAKE2b-256 f5045766752a7766ef55784eaf4d8c115d69bcde3fab62cd9fca8bcfdb973a67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page