Environment¶
GridEngineEnv adapts a world factory to Gymnasium. The default action space
has seven actions: up, down, left, right, use key, pick up, and wait.
Image observations contain an RGBA array plus structured info. Symbolic
observations are returned by setting observation_type="grid".
from grid_engine.env import Action, GridEngineEnv
from grid_engine.examples.maze import generate
env = GridEngineEnv(initial_state_fn=generate, width=7, height=7, seed=1)
obs, info = env.reset()
obs, reward, terminated, truncated, info = env.step(Action.RIGHT)
Bases: Env[ImageObservation | GridObservation, integer]
Gymnasium Env implementation for the Grid Engine.
Create a new environment instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
render_mode
|
str
|
"rgb_array" to return PIL image frames, "human" to open a window. |
'rgb_array'
|
render_resolution
|
int
|
Width (pixels) of rendered image (height derived). |
DEFAULT_RESOLUTION
|
render_image_map
|
ImageMap
|
Mapping of |
DEFAULT_IMAGE_MAP
|
initial_state_fn
|
Callable[..., World]
|
Callable returning an initial |
required |
**kwargs
|
Any
|
Forwarded to |
{}
|
grid_observation
property
¶
Return the current symbolic grid observation.
render(mode=None)
¶
Render the current state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str | None
|
"human" to display, "rgb_array" to return PIL image. Defaults to the instance's configured render mode. |
None
|
reset(*, seed=None, options=None)
¶
Start a new episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int | None
|
Override the procedural seed passed to the state factory. |
None
|
options
|
dict | None
|
Gymnasium options (unused). |
None
|
Returns:
| Type | Description |
|---|---|
tuple[ImageObservation | GridObservation, dict[str, object]]
|
Tuple[ImageObservation, dict]: ImageObservation dict and empty info dict per Gymnasium API. |
state_info()
¶
Return structured info sub-dict used in observations.
step(action)
¶
Apply one environment step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
int | integer | Action
|
Integer index (or |
required |
Returns:
| Type | Description |
|---|---|
tuple[ImageObservation | GridObservation, float, bool, bool, dict[str, object]]
|
Tuple[ImageObservation, float, bool, bool, dict]: |