Skip to content

Experimental API

This module contains unstable APIs that may change or be removed without prior notice. SimulatteEnv is an abstract base class (ABC) that wraps a Simulatte simulation as a Gymnasium Env, enabling reinforcement-learning training loops. Subclasses implement six abstract methods (setup, get_observation, apply_action, compute_reward, is_terminated, is_truncated); the base class handles the reset/step/close lifecycle and state guards. Two optional hooks — teardown() and get_info() — are also available. See the Reinforcement Learning guide and the Gymnasium wrapper tutorial for worked examples.

SimulatteEnv

Bases: Env, ABC

Base class for wrapping simulations as Gymnasium environments.

Subclass this and implement the six abstract methods to define your simulation's observation space, action space, setup, reward, and termination logic. The base class handles Gymnasium lifecycle orchestration, state tracking, and resource cleanup.

Two optional hooks are available: - teardown(): clean up simulation resources between episodes. - get_info(): return step metadata after all computations.

Subclasses must set observation_space and action_space in __init__ before calling reset().

_done class-attribute instance-attribute

_done: bool = False

_is_initialized class-attribute instance-attribute

_is_initialized: bool = False

apply_action abstractmethod

apply_action(action: Any) -> None

Apply the agent's action and advance the simulation to the next decision point.

close

close() -> None

compute_reward abstractmethod

compute_reward(action: Any) -> float

Compute the reward for the current step.

get_info

get_info() -> dict[str, Any]

Return the info dict for this step.

Called last in step(), after observation, reward, and termination have all been computed.

get_observation abstractmethod

get_observation() -> Any

Extract the current observation from the simulation state.

is_terminated abstractmethod

is_terminated() -> bool

Whether the episode ended naturally.

is_truncated abstractmethod

is_truncated() -> bool

Whether the episode was cut short.

reset

reset(
    *,
    seed: int | None = None,
    options: dict[str, Any] | None = None,
) -> tuple[Any, dict[str, Any]]

setup abstractmethod

setup(
    *, seed: int | None, options: dict[str, Any] | None
) -> None

Create and configure the simulation from scratch.

Called at the beginning of each episode. Must set up all simulation state needed for the episode.

For numpy-based randomness, prefer self.np_random — it is automatically seeded by Gymnasium and persists correctly across unseeded resets.

step

step(
    action: Any,
) -> tuple[Any, float, bool, bool, dict[str, Any]]

teardown

teardown() -> None

Clean up simulation resources from the previous episode.

Called before setup() on every reset() after the first, and from close().