Gym Wrappers

Additional Gym Wrappers to enhance Gym environments.


class sb3_contrib.common.wrappers.TimeFeatureWrapper(env, max_steps=1000, test_mode=False)[source]

Add remaining, normalized time to observation space for fixed length episodes. See and


Only gym.spaces.Box and gym.spaces.Dict (gym.GoalEnv) 1D observation spaces are supported for now.

  • env (Env) – Gym env to wrap.

  • max_steps (int) – Max number of steps of an episode if it is not wrapped in a TimeLimit object.

  • test_mode (bool) – In test mode, the time feature is constant, equal to zero. This allow to check that the agent did not overfit this feature, learning a deterministic pre-defined sequence of actions.


Resets the environment with kwargs.

Return type

Union[Tuple, Dict[str, Any], ndarray, int]


Steps through the environment with action.

Return type

Tuple[Union[Tuple, Dict[str, Any], ndarray, int], float, bool, Dict]