🕹️ Blazing-fast, deterministic Breakout for Reinforcement Learning 🕹️
env-BreakoutAtari2600-turbo-native is a Python library for reinforcement-learning researchers
and engineers who need many reproducible Breakout games behind one Gymnasium
vector-environment API. Add it to a uv project from PyPI, create
BreakoutVecEnv, and step every lane with one NumPy action batch.
Fixed-point Rust physics owns game state and parallel stepping. Python exposes manual reset, policy-ready observations, native rendering, exact snapshots, and side-effect-free action branching.
Install
Requires Python 3.11+ on Apple-silicon macOS 11+ or x86-64 Linux with glibc 2.28+.
Install uv, then add the library to your project:
uv add env-breakoutatari2600-turbo-native
Choose the corresponding requirement instead when you need an optional tool:
uv add "env-breakoutatari2600-turbo-native[play]" # interactive Pygame player
To work from source, also install a Rust toolchain, then run:
git clone https://github.com/tsilva/env-BreakoutAtari2600-turbo-native.git
cd env-BreakoutAtari2600-turbo-native
uv sync --frozen --extra dev --extra play
make develop-release
Use
import gymnasium as gym
import numpy as np
env = gym.make_vec(
"breakout_turbo_env:Breakout-Turbo-v0",
game="Breakout-Atari2600-v0",
num_envs=4096,
num_threads=8,
)
obs, infos = env.reset()
obs, rewards, terminated, truncated, infos = env.step(
np.zeros(env.num_envs, dtype=np.uint8)
)
done = terminated | truncated
if done.any():
obs, reset_infos = env.reset(options={"reset_mask": done})
The module-qualified ID imports the package and registers the factory. This ID
is vector-only and requires an explicit game; BreakoutVecEnv remains
available for direct use.
Train with GradLab
Training recipes and implementations live in GradLab, keeping this repository focused on the environment. Run a published recipe from any directory without installing GradLab or cloning either repository.
For the default high-throughput PPO recipe:
uvx gradlab@0.1.1 train Breakout-Atari2600-v0/ppo
For PPO with learning-rate decay and KL-based update stopping:
uvx gradlab@0.1.1 train Breakout-Atari2600-v0/ppo-stable-updates
Breakout Turbo is ROM-free, so neither command needs a ROM path or registration.
GradLab shows live progress, writes a playable final_model.zip below ./runs,
and prints the matching version-pinned uvx ... play command when training
finishes or is stopped safely. Local runs disable W&B and checkpoint evaluation
by default, so they cannot establish acceptance or promotion. These are
full-cap research recipes rather than short timed demos.
Turbo Vector API v2
BreakoutVecEnv implements the strict Turbo Vector API v2:
metadata["turbo_api_version"]is2,metadata["transition_transport"]is"numpy", andmetadata["render_modes"]advertisesrgb_array.- Immutable
capabilitiesandsignal_schemadeclarations describe supported features and the dtype, shape, and reset/step availability of every signal. buttons,action_mode,action_preset,action_table,action_meanings, andaction_table_hashexpose the resolved action semantics without provider-specific probing.state_catalogis an immutable ordered tuple. Callers select reset states with anint32state_indicesarray and inspect the read-only active indices withactive_state_indices(); state sampling and lane routing remain caller-owned.observation_ownershipandobservation_buffer_depthdeclare the exact lifetime of returned observations. Rendering is opt-in: withrender_mode="rgb_array",render_lane(index)renders one lane,get_images()renders all lanes, andrender()renders lane zero. With the defaultrender_mode=None, the first two methods returnNoneandget_images()returns oneNoneentry per lane.
Interesting live positions can be archived without advancing the game and restored into any lane of the same environment:
capture_mask = np.zeros(env.num_envs, dtype=np.bool_)
capture_mask[0] = True
captured = env.capture_snapshots(capture_mask)
restore_mask = np.zeros(env.num_envs, dtype=np.bool_)
restore_mask[3] = True
starts = [None] * env.num_envs
starts[3] = captured[0]
obs, infos = env.reset(
options={"reset_mask": restore_mask, "snapshots": starts},
)
env.close()
Importing the package also preserves the Stable Retro-compatible
Breakout-Atari2600-v0 vector ID. The complete lifecycle, configuration,
snapshot, and branching contract is in the
environment documentation.
Stable-Baselines3 users can wrap the already-vectorized environment with the optional, explicitly auto-resetting adapter described in the environment documentation. SB3 remains a separate install and is not part of the core dependency set.
Commands
uv run --frozen --extra play breakout-turbo-env play # open the player
uv run --frozen --extra play breakout-turbo-env play --uncapped
uv run --frozen breakout-turbo-env benchmark # benchmark the policy path
uv run --frozen python scripts/compare_stable_retro.py # run live differential checks
uv run --frozen ruff check . # lint Python
uv run --frozen pytest -m "not stable_retro" # run regular Python tests
cargo test --locked --lib # run Rust tests
make test-stable-retro # require live cartridge parity
make test-semantic-oracle # compare to original Stable Retro authority
Append --help to the player or benchmark command for its options.
Notes
- Native actions are
0noop,1FIRE,2right, and3left. The default policy observation is grayscaleuint8, CHW, and shaped(num_envs, 4, 84, 84). - Rewards are score deltas using Atari row scoring. There is no life-loss or board-clear shaping. The cartridge presents two walls: the first refills after the next paddle return, the second ends at score 864 without another refill, and only losing all five lives terminates the episode.
- Autoreset is disabled. Reset terminated lanes explicitly with a Boolean
reset_mask; unselected lanes remain byte-exact. noop_reset_max=Nsamples1..Nseeded raw-frame noops for each static reset, matching the conventional Atari reset distribution. FIRE is not issued automatically:use_fire_resetremains unavailable and the policy must start each serve.- The canonical
Startstate targets Stable Retro's native 160×210 Atari Breakout frame, lifecycle, physics, raster, rewards, collision behavior, and public trajectory values. In particular,ball_yuses the Atari RAM convention where zero means the serve is waiting for FIRE. Opt into raw frames withrender_mode="rgb_array";render()then returns lane zero's canonical Stella RGB frame whilerender_lane(index)selects any lane, separately from policy observations. Original Stable Retro's BGR-labeled RGB565 frame transport is normalized only at this human-facing boundary. - Live validation requires a separately obtained lawful ROM. The TurboBench
semantic oracle pins original
stable-retro==1.0.1as the authority; the siblingstable-retro-turbodifferential remains a secondary regression check. No ROM, save state, or recorded reference frame is distributed by this project. - Only Apple-silicon macOS and x86-64 Linux are supported. See support, benchmarking, and release validation for exact boundaries.
- The project is a
0.xcommunity preview. Public changes are recorded in the changelog. Serializedget_state()snapshots are portable only within the same package version and compatible configuration; live snapshot handles are session-local and intentionally not pickleable.
Architecture
License
MIT. See third-party notices for Atari, Stable Retro, ROM, and trademark boundaries.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file env_breakoutatari2600_turbo_native-0.5.7.tar.gz.
File metadata
- Download URL: env_breakoutatari2600_turbo_native-0.5.7.tar.gz
- Upload date:
- Size: 10.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76fd11b2afc8bc5441b6975ed30575b4f6792fa8c1b3599b20873a9be9ced66e
|
|
| MD5 |
f298b81b5b27a15276dda1fa6126ba04
|
|
| BLAKE2b-256 |
df5281185f71731191c32307ac9a7f136764a3966b321a91d912a8068edadd7c
|
Provenance
The following attestation bundles were made for env_breakoutatari2600_turbo_native-0.5.7.tar.gz:
Publisher:
release.yml on tsilva/env-BreakoutAtari2600-turbo-native
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
env_breakoutatari2600_turbo_native-0.5.7.tar.gz -
Subject digest:
76fd11b2afc8bc5441b6975ed30575b4f6792fa8c1b3599b20873a9be9ced66e - Sigstore transparency entry: 2531279708
- Sigstore integration time:
-
Permalink:
tsilva/env-BreakoutAtari2600-turbo-native@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 331.8 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fe9a521ef37f43d6167d795df041bbfac0b7db1c067919061e7b019dbe600aa
|
|
| MD5 |
544ddf03e9e0e28afd784857a2d2258d
|
|
| BLAKE2b-256 |
bd3685ab680c9c2efc6b0316e3217872d22c91ec8971ad39aa17ba277067db66
|
Provenance
The following attestation bundles were made for env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on tsilva/env-BreakoutAtari2600-turbo-native
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
9fe9a521ef37f43d6167d795df041bbfac0b7db1c067919061e7b019dbe600aa - Sigstore transparency entry: 2531279840
- Sigstore integration time:
-
Permalink:
tsilva/env-BreakoutAtari2600-turbo-native@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 293.3 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dee641f7cf2714d19298cfb0edd5f2aad3e096de1f2a0822241936a0a2fe8b8
|
|
| MD5 |
10e57fb1b4f74c8a8bb2867b40a3a299
|
|
| BLAKE2b-256 |
5760692172b8a7a936c3ddd9e213f5620d4090fad895ea2034e2264c57474601
|
Provenance
The following attestation bundles were made for env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on tsilva/env-BreakoutAtari2600-turbo-native
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
env_breakoutatari2600_turbo_native-0.5.7-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
1dee641f7cf2714d19298cfb0edd5f2aad3e096de1f2a0822241936a0a2fe8b8 - Sigstore transparency entry: 2531279932
- Sigstore integration time:
-
Permalink:
tsilva/env-BreakoutAtari2600-turbo-native@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec2dc80f5d38c307e257af50f6bf60ad38e0be9e -
Trigger Event:
workflow_dispatch
-
Statement type: