Add minesweeper env and example #236
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new Minesweeper game environment to OpenEnv, providing a classic grid-based puzzle game for reinforcement learning agents. The environment challenges agents to reveal all non-mine cells without triggering any mines, using strategies based on number clues and flag placement.
Motivation
Minesweeper is a well-known logical puzzle that requires:
This environment is valuable for:
Changes
Core Implementation
reveal: Uncover a cell to see its valueflag: Place/remove flag on suspected mine locationsFeatures
Docker Support
openenv-baseimagebuild_docker.sh) for easy local developmentTesting
Documentation
CI/CD Integration
Files Changed
New Files (14 files, 1,552 insertions)
Environment Core:
src/envs/minesweeper_env/__init__.py- Module exports and public APIsrc/envs/minesweeper_env/client.py- HTTP client for remote environment accesssrc/envs/minesweeper_env/models.py- Pydantic models for actions, observations, and statesrc/envs/minesweeper_env/openenv.yaml- Environment metadata and configurationsrc/envs/minesweeper_env/pyproject.toml- Package dependencies and build configurationServer Implementation:
src/envs/minesweeper_env/server/__init__.py- Server module exportssrc/envs/minesweeper_env/server/app.py- FastAPI application and HTTP endpointssrc/envs/minesweeper_env/server/minesweeper_environment.py- Core game logic and environment implementationDocker & Build:
src/envs/minesweeper_env/server/Dockerfile- Multi-stage container image definitionsrc/envs/minesweeper_env/server/build_docker.sh- Build script for local developmentDocumentation & Examples:
src/envs/minesweeper_env/README.md- Comprehensive environment documentationexamples/minesweeper_agent.py- Example agent demonstrating environment usageTesting:
tests/envs/test_minesweeper_env.py- Test suite with 13 test casesModified Files (1 file)
CI/CD:
.github/workflows/docker-build.yml- Addedminesweeper-envto build matrix for automated Docker image buildingUsage Example
Testing
Run the test suite:
python tests/envs/test_minesweeper_env.pyBuild and run the Docker image: