-
Notifications
You must be signed in to change notification settings - Fork 112
[Enhancement] Add Snake Environment - Classic Single-Agent RL Game #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Enhancement] Add Snake Environment - Classic Single-Agent RL Game #202
Conversation
|
✅ Validation succeeded for Your env passes the vibe check. However, most environments should go straight to the hub, they will automatically be added to the official Env Hub collection on a nightly basis. Environments in the official specification repo are only meant to demonstrate usage of a specific spec feature for educational purposes. Re-run locally with:
You can deploy the environment to Hugging Face Spaces by running |
|
cc @init27 @HamidShojanazeri @Darktex (Since I cannot add a reviewer directly) |
|
Thanks for the great contribution @AlirezaShamsoshoara ! Can you deploy it to the hf hub with |
|
Thank you @burtenshaw for taking a look at this! Just ran the https://huggingface.co/spaces/Crashbandicoote2/snake_env
|
|
@AlirezaShamsoshoara great. Could you update |
|
@burtenshaw Thanks for the comment! Just rebased it and added the snake env to |

Add Snake Environment - Classic Single-Agent RL Game
Summary
This PR adds a new Snake Environment to OpenEnv, providing a classic snake game implementation based on marlenv's Snake-v1. The environment offers a clean, OpenEnv-compatible interface for reinforcement learning research and experimentation with a well-known game mechanic.
What's New
Core Environment (
src/envs/snake_env/)client.py): HTTP client for connecting to snake environment serversmodels.py): Type-safe action and observation modelsSnakeAction: Discrete actions (turn left/right or directional movement)SnakeObservation: Rich observations including grid state, score, and metadataserver/):Example Code
examples/snake_simple.py: Comprehensive example demonstrating:Infrastructure
Key Features
Gameplay
Configurability
Observations
Each step provides:
Deployment Options
SnakeEnv.from_docker_image()Example Usage
Files Changed
New Files
src/envs/snake_env/- Complete environment implementation__init__.py,client.py,models.pyserver/app.py,server/snake_environment.py,server/DockerfileREADME.md,pyproject.toml,openenv.yamlexamples/snake_simple.py- Interactive example with visualization (378 lines)Modified Files
.github/workflows/docker-build.yml- Added snake-env to build matrix.gitignore- Updated to exclude uv.lock files more broadlyTechnical Details
Dependencies
marlenv>=1.0.0- Core snake game implementationgym==0.24.1- Required by marlenvnumpy>=1.24.0- Grid and array operationsArchitecture
The implementation follows OpenEnv's standard pattern:
Reward Customization
Supports flexible reward shaping:
Testing
The example script demonstrates:
To test:
Future Enhancements
Potential additions for future PRs:
Credits
Based on marlenv by ML2 (KC-ML2)
Lines of Code: ~1,246 additions across 14 files
Documentation: Comprehensive README with examples and troubleshooting
CI/CD: Automated Docker builds integrated