Skip to content

lit_sb3.wrappers.atari.atari_wrapper

source module lit_sb3.wrappers.atari.atari_wrapper

Classes

source class AtariWrapper(env: gym.Env, noop_max: int = 30, frame_skip: int = 4, screen_size: int = 84, terminal_on_life_loss: bool = True, clip_reward: bool = True, action_repeat_probability: float = 0.0)

Bases : gym.Wrapper[np.ndarray, int, np.ndarray, int]

Atari 2600 preprocessings.

Specifically:

  • Noop reset: obtain initial state by taking random number of no-ops on reset.
  • Frame skipping: 4 by default
  • Max-pooling: most recent two observations
  • Termination signal when a life is lost.
  • Resize to a square image: 84x84 by default
  • Grayscale observation
  • Clip reward to {-1, 0, 1}
  • Sticky actions: disabled by default

See https://danieltakeshi.github.io/2016/11/25/frame-skipping-and-preprocessing-for-deep-q-networks-on-atari-2600-games/ for a visual explanation.

.. warning:: Use this wrapper only with Atari v4 without frame skip: env_id = "*NoFrameskip-v4".

Parameters

  • env : gym.Env — Environment to wrap

  • noop_max : int — Max number of no-ops

  • frame_skip : int — Frequency at which the agent experiences the game. This correspond to repeating the action frame_skip times.

  • screen_size : int — Resize Atari frame

  • terminal_on_life_loss : bool — If True, then step() returns terminated=True whenever a life is lost.

  • clip_reward : bool — If True (default), the reward is clip to {-1, 0, 1} depending on its sign.

  • action_repeat_probability : float — Probability of repeating the last action

Attributes

  • metadata : dict[str, Any] — attr:Env :attr:metadata.

  • render_mode : str | None — attr:Env :attr:render_mode.

  • spec : EnvSpec | None — attr:Env :attr:spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

  • action_space : spaces.Space[ActType] | spaces.Space[WrapperActType] — attr:Env :attr:action_space unless overwritten then the wrapper :attr:action_space is used.

  • observation_space : spaces.Space[ObsType] | spaces.Space[WrapperObsType] — attr:Env :attr:observation_space unless overwritten then the wrapper :attr:observation_space is used.

  • unwrapped : Env[ObsType, ActType] — Returns the base environment of the wrapper.

  • np_random_seed : int | None — attr:np_random_seed.

  • np_random : np.random.Generator — attr:Env :attr:np_random attribute.