popgym.wrappers.previous_action
Module Contents
Classes
Wrapper that adds the last action to the observation. |
Attributes
- popgym.wrappers.previous_action.PREV_ACTION = 'prev_action'
- class popgym.wrappers.previous_action.PreviousAction(env: popgym.core.env.POPGymEnv, null_action: gymnasium.core.ActType | None = None)
Bases:
popgym.core.wrapper.POPGymWrapperWrapper that adds the last action to the observation.
- Args:
env: The environment null_action: Optional null action that is returned when resetting the
environment. If not provided, the null action will be 0 (int or vector) if it is in the action space, or the lowest action possible.
- Returns:
A gym environment
- static add_act_space_to_obs_space(observation_space: gymnasium.spaces.Space, action_space: gymnasium.spaces.Space) gymnasium.spaces.Space
Returns a modified observation space to account for the last action. Args:
observation_space: Original observation space action_space: Action space
- Returns:
The new observation space
- static add_act_to_obs(observation_space: gymnasium.spaces.Space, obs: gymnasium.core.ObsType, action: gymnasium.core.ActType) gymnasium.core.ObsType
Static method that adds the action to the observation. Args:
observation_space: Original observation space of the environment. obs: The observation. action: The action.
- Returns:
Modified observation.
- static get_null_action(action_space: gymnasium.spaces.Space) gymnasium.core.ActType
Static method that generates a null action based on the action space. Args:
action_space: The action space.
- Returns:
The null action.