-
Notifications
You must be signed in to change notification settings - Fork 75
Add maze environment and example #106
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?
Conversation
|
Hi @VivekSil! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates a Maze game environment with the OpenEnv framework, providing both server-side and client-side implementations with Docker support.
- Implements MazeEnvironment wrapper that exposes the Maze game through OpenEnv's Environment interface
- Adds HTTP client and server infrastructure for remote maze environment interaction
- Includes example scripts demonstrating both automated and human-interactive maze solving
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| src/envs/maze_env/server/mazearray.py | Defines the maze layout as a numpy array |
| src/envs/maze_env/server/maze_environment.py | Wraps Maze game to implement OpenEnv Environment interface |
| src/envs/maze_env/server/maze.py | Core Maze implementation with coordinate system (col, row) |
| src/envs/maze_env/server/app.py | FastAPI application exposing maze environment over HTTP |
| src/envs/maze_env/server/init.py | Package exports for server components |
| src/envs/maze_env/server/Dockerfile | Container configuration for maze environment server |
| src/envs/maze_env/models.py | Data models for actions, observations, and state |
| src/envs/maze_env/client.py | HTTP client for connecting to maze environment server |
| src/envs/maze_env/init.py | Package exports for client components |
| src/envs/maze_env/README.md | Documentation for maze environment usage |
| examples/maze_simple.py | Example demonstrating automated maze navigation |
| examples/maze_human.py | Example demonstrating human-interactive maze solving |
| .github/workflows/docker-build.yml | Adds maze-env to CI/CD Docker build workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # build MazeObservation; convert numpy to list for JSON-serializable dataclass fields | ||
| pos_list = observation.tolist() if hasattr(observation, "tolist") else list(observation) | ||
| total_reward = 0 | ||
| legal_actions = self._compute_legal_actions(pos_list[0]) |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indexing when computing legal actions. The method expects a list [row, col] but pos_list[0] extracts only the first nested list from np.array([[col, row]]). Based on the Maze class documentation (line 54-58 in maze.py), the underlying Maze returns coordinates as (col, row), but the wrapper uses [row, col]. This should be pos_list[0] with the correct coordinate transformation applied.
| legal_actions = self._compute_legal_actions(pos_list[0]) | |
| # Swap [col, row] to [row, col] for legal actions computation | |
| legal_actions = self._compute_legal_actions([pos_list[0][1], pos_list[0][0]]) |
| ): | ||
| # Create underlying Maze instance (matches your working code) | ||
| self.env = Maze(maze=maze_array, start_cell=start_cell, exit_cell=exit_cell) | ||
| self.total_reward = 0 |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The total_reward is not reset in the reset() method (line 55-66), which means rewards accumulate across episodes. The reset() method should include 'self.total_reward = 0' to properly reset episode state.
src/envs/maze_env/server/app.py
Outdated
| # Get game configuration from environment variables | ||
|
|
||
| # Create the environment instance | ||
| env = MazeEnvironment(maze_array=maze,start_cell=(0,0),exit_cell=(7,7)) |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces after commas in function arguments. Should be: 'maze_array=maze, start_cell=(0, 0), exit_cell=(7, 7)' to follow PEP 8 style guidelines.
| env = MazeEnvironment(maze_array=maze,start_cell=(0,0),exit_cell=(7,7)) | |
| env = MazeEnvironment(maze_array=maze, start_cell=(0, 0), exit_cell=(7, 7)) |
src/envs/maze_env/server/__init__.py
Outdated
| from .maze import Maze, Status | ||
| from .maze_environment import MazeEnvironment | ||
|
|
||
| __all__ = ["Maze","MazeEnvironment","Status"] No newline at end of file |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces after commas in list. Should be: '["Maze", "MazeEnvironment", "Status"]' to follow PEP 8 style guidelines.
| __all__ = ["Maze","MazeEnvironment","Status"] | |
| __all__ = ["Maze", "MazeEnvironment", "Status"] |
| 5. Inspecting environment state | ||
|
|
||
| Usage: | ||
| python examples/maze_simple.py |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect usage documentation. This file is 'maze_human.py' but the docstring says 'python examples/maze_simple.py'. Should be 'python examples/maze_human.py'.
| python examples/maze_simple.py | |
| python examples/maze_human.py |
| via the OpenEnv Environment interface. | ||
| """ | ||
|
|
||
| from typing import Any, Dict, List, Tuple, Optional |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Any' is not used.
Import of 'Dict' is not used.
| from typing import Any, Dict, List, Tuple, Optional | |
| from typing import List, Tuple, Optional |
| """ | ||
|
|
||
| from typing import Any, Dict, List, Tuple, Optional | ||
| from core.env_server import Action, Environment, Observation |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Action' is not used.
Import of 'Observation' is not used.
| from core.env_server import Action, Environment, Observation | |
| from core.env_server import Environment |
|
|
||
| from typing import Any, Dict, List, Tuple, Optional | ||
| from core.env_server import Action, Environment, Observation | ||
| from .maze import Maze, Status |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Status' is not used.
| from .maze import Maze, Status | |
| from .maze import Maze |
src/envs/maze_env/models.py
Outdated
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from pydantic import Field |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Field' is not used.
| from pydantic import Field |
src/envs/maze_env/models.py
Outdated
|
|
||
| from dataclasses import dataclass, field | ||
| from pydantic import Field | ||
| from typing import Any, Dict, List, Optional, Tuple, Literal |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Any' is not used.
Import of 'Dict' is not used.
Import of 'Optional' is not used.
Import of 'Tuple' is not used.
Import of 'Literal' is not used.
| from typing import Any, Dict, List, Optional, Tuple, Literal | |
| from typing import List |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
1 similar comment
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
|
✅ Deployment succeeded for
Nice work! Wait for a code review and we're ready to go. You can iterate locally or validate fixes by running |
This PR will add Maze environment (#105)
Specifications:
Reward setting: