Atari Environments#
Installation#
pip install shimmy[atari]
Usage#
import gymnasium as gym
env = gym.make("ALE/Pong-v5")
Class Description#
- class shimmy.atari_env.AtariEnv(game: str = 'pong', mode: int | None = None, difficulty: int | None = None, obs_type: str = 'rgb', frameskip: tuple[int, int] | int = 4, repeat_action_probability: float = 0.25, full_action_space: bool = False, max_num_frames_per_episode: int | None = None, render_mode: str | None = None)#
(A)rcade (L)earning (Gymnasium) (Env)ironment.
A Gymnasium wrapper around the Arcade Learning Environment (ALE).
- metadata: dict[str, Any] = {'obs_types': {'grayscale', 'ram', 'rgb'}, 'render_modes': ['human', 'rgb_array']}#
- action_space: spaces.Space[ActType]#
- observation_space: spaces.Space[ObsType]#
- seed(seed: int | None = None) tuple[int, int] #
Seeds both the internal numpy rng for stochastic frame skip and the ALE RNG.
This function must also initialize the ROM and set the corresponding mode and difficulty. seed may be called to initialize the environment during deserialization by Gymnasium so these side-effects must reside here.
- Parameters:
seed – int => Manually set the seed for RNG.
- Returns:
tuple[int, int] => (np seed, ALE seed)
- reset(*, seed: int | None = None, options: dict[str, Any] | None = None) tuple[np.ndarray, AtariEnvStepMetadata] #
Resets environment and returns initial observation.
- Parameters:
seed – The reset seed
options – The reset options
- Returns:
The reset observation and info
- step(action_ind: int) tuple[np.ndarray, float, bool, bool, AtariEnvStepMetadata] #
Perform one agent step, i.e., repeats action frameskip # of steps.
- Parameters:
action_ind – int => Action index to execute
- Returns:
Tuple[np.ndarray, float, bool, Dict[str, Any]] => observation, reward, terminal, metadata
Note: metadata contains the keys “lives” and “rgb” if render_mode == ‘rgb_array’.
- render() Any #
Renders the ALE environment.
- Returns:
If render_mode is “rgb_array”, returns the screen RGB view.
- get_keys_to_action() dict[tuple[int], ale_py.Action] #
Return keymapping -> actions for human play.
- Returns:
A dictionary of keys to actions.
- get_action_meanings() list[str] #
Return the meaning of each integer action.
- Returns:
A list of action meaning
- clone_state(include_rng: bool = False) ALEState #
Clone emulator state w/o system state.
Restoring this state will not give an identical environment. For complete cloning and restoring of the full state, see {clone,restore}_full_state().
- Parameters:
include_rng – If to include the rng in the cloned state
- Returns:
The cloned state
- restore_state(state: ALEState)#
Restore emulator state w/o system state.
- Parameters:
state – The state to restore
- clone_full_state() ALEState #
Deprecated method which would clone the emulator and system state.
- restore_full_state(state: ALEState)#
Restore emulator state w/ system state including pseudo-randomness.