TimeLimitWrapper

class maze.core.wrappers.time_limit_wrapper.TimeLimitWrapper(env: BaseEnv, max_episode_steps: int | None = None)

Wrapper to limit the environment step count, equivalent to gymnasium.wrappers.time_limit.

Additionally to the gym wrapper, this one supports adjusting the limit after construction.

Parameters:
  • env – The environment to wrap.

  • max_episode_steps – The maximum number of steps to take. If 0, the step limit is disabled.

clone_from(env: TimeLimitWrapper) None

(overrides SimulatedEnvMixin)

implementation of SimulatedEnvMixin.

close() None

(overrides BaseEnv)

forward call to the inner env

get_max_env_steps() int

Return the maximum env steps.

Returns:

the maximum env steps

get_observation_and_action_dicts(maze_state: Any | None, maze_action: Any | None, first_step_in_episode: bool) Tuple[Dict[int | str, Any] | None, Dict[int | str, Any] | None]

(overrides Wrapper)

This wrapper does not modify observations and actions.

reset() Any

(overrides BaseEnv)

Override BaseEnv.reset to reset the step count.

seed(seed: int) None

(overrides BaseEnv)

forward call to the inner env

set_max_episode_steps(max_episode_steps: int) None

Set the step limit.

Parameters:

max_episode_steps – The environment step() function sets the done flag if this step limit is reached. If 0, the step limit is disabled.

step(action: Any) Tuple[Any, Any, bool, Dict[Any, Any]]

(overrides BaseEnv)

Override BaseEnv.step and set done if the step limit is reached.