gym_wrappers#


class ContinuousToDiscrete(env: Env, action_per_dim: int | list[int])[source]#

Gym environment wrapper to take discrete action in a continuous environment.

Parameters:
  • env (gym.Env) – gym environment with continuous action space.

  • action_per_dim – number of discrete actions in each dimension of the action space.

action(act: ndarray) ndarray[source]#

Returns a modified action before env.step() is called.

Args:

action: The original step() actions

Returns:

The modified actions

class MultiDiscreteToDiscrete(env: Env)[source]#

Gym environment wrapper to take discrete action in multidiscrete environment.

Parameters:

env (gym.Env) – gym environment with multidiscrete action space.

action(act: ndarray) ndarray[source]#

Returns a modified action before env.step() is called.

Args:

action: The original step() actions

Returns:

The modified actions

class TruncatedAsTerminated(env: Env)[source]#

A wrapper that set terminated = terminated or truncated for step().

It’s intended to use with gym.wrappers.TimeLimit.

Parameters:

env (gym.Env) – gym environment.

step(act: ndarray) tuple[Any, SupportsFloat, bool, bool, dict[str, Any]][source]#

Uses the step() of the env that can be overwritten to change the returned data.