Arcade Learning Environment (ale-py)

0.11.2 · active · verified Thu Apr 16

ale-py is the Python interface to the Arcade Learning Environment (ALE), a platform for AI research built on the Atari 2600 emulator Stella. It allows researchers to develop and test AI agents for Atari games, abstracting away emulation details. The library is currently at version 0.11.2, actively maintained by the Farama Foundation, and has a steady release cadence incorporating updates like Gymnasium integration and ROM packaging.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates both the direct Python interface of ALEInterface to interact with Atari games and its integration with the Gymnasium API. It shows how to load a ROM (now included in the package), reset the game, take an action, and retrieve observations. The Gymnasium example highlights environment registration and interaction.

import gymnasium as gym
import ale_py
from ale_py import ALEInterface, roms

# --- Direct ALEInterface usage ---
ale = ALEInterface()
# ROMs are now packaged within ale-py, access via roms.get_rom_path
ale.loadROM(roms.get_rom_path("breakout"))
ale.reset_game()
reward = ale.act(0) # Perform a 'noop' action
screen_obs = ale.getScreenRGB()
print(f"Direct ALE: Initial reward: {reward}, Screen shape: {screen_obs.shape}")
ale.close()

# --- Gymnasium integration ---
# Register ALE environments with Gymnasium
gym.register_envs(ale_py)

env = gym.make('ALE/Breakout-v5', render_mode='rgb_array')
obs, info = env.reset()
print(f"Gymnasium: Initial observation shape: {obs.shape}")

action = env.action_space.sample() # Take a random action
obs, reward, terminated, truncated, info = env.step(action)
print(f"Gymnasium: Step reward: {reward}, Terminated: {terminated}, Truncated: {truncated}")

env.close()

view raw JSON →