Skip to main content

Deterministic, fixed-point, high-throughput Breakout vector environment

Project description

breakout-turbo-env logo

🕹️ Blazing-fast, deterministic Breakout for Reinforcement Learning 🕹️

breakout-turbo-env is a Python library for running many deterministic Breakout games at once. It gives reinforcement-learning researchers and engineers reproducible transitions, policy-ready observations, and a Gymnasium vector-environment API. Install the package, create BreakoutVecEnv, and step every game with one NumPy action batch.

Fixed-point Rust physics owns game state and parallel stepping. Python exposes the Gymnasium lifecycle, rendering, snapshots, and branching helpers.

Install

Requires Python 3.11+.

pip install breakout-turbo-env

The core environment depends only on Gymnasium and NumPy. Install optional tools explicitly when needed:

pip install "breakout-turbo-env[play]"   # interactive Pygame player
pip install "breakout-turbo-env[train]"  # local PPO training with PyTorch

To work from source, install uv and a Rust toolchain, then run:

git clone https://github.com/tsilva/breakout-turbo-env.git
cd breakout-turbo-env
uv sync --extra dev --extra play --extra train
make develop-release

Import BreakoutVecEnv from the installed environment:

import numpy as np
from breakout_turbo_env import BreakoutVecEnv

env = BreakoutVecEnv(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})

env.close()

Commands

uv run --extra play breakout-turbo-env play    # open the interactive player
uv run --extra play breakout-turbo-env play --uncapped  # visible play without an FPS limit
uv run breakout-turbo-env benchmark            # measure the fixed 16-lane policy path
uv run pytest                                  # run Python contract and regression tests
cargo test --lib                               # run Rust library tests
uv run python train.py jerk                    # train a deterministic JERK action tape
uv run --extra train python train.py ppo       # train a PPO policy
uv run --extra play python play.py jerk        # replay the newest JERK policy
uv run --extra play python play.py ppo         # replay the newest PPO policy
make release                                   # validate, tag, and publish a release

For player, benchmark, training, and replay options, append --help to the corresponding command.

Notes

  • The standard observation batch is grayscale uint8, CHW, and defaults to (num_envs, 4, 84, 84). Actions are 0 (noop), 1 (left), and 2 (right). Rewards match Stable Retro's Breakout scenario: each reward is the score delta, using 7, 7, 4, 4, 1, 1 points from the top brick row to the bottom, with no life-loss penalty or board-clear bonus.
  • The environment is manual-reset only: after a terminal lane, call reset(options={"reset_mask": mask}) before stepping that lane again. Built-in layouts are full, checker, tunnel, and sparse.
  • render() returns the native 160×210 RGB frame geometry and Stella palette used by Stable Retro for Atari 2600 Breakout; training observations remain a separate processed 96×96 grayscale source stack. The interactive player accepts Left/Right or A/D, Space or R to reset, P to pause, and Escape to quit.
  • PyPI provides wheels for macOS 11+ on Apple silicon and glibc 2.28+ Linux on x86-64. Other platforms require a source build.
  • Training outputs live in runs/<algorithm>/<timestamp>/. JERK policies use policy.json; PPO policies use policy.npz.
  • make release requires a clean branch synchronized with its upstream. The release workflow builds and audits macOS arm64 and Linux x86_64 wheels before publishing to PyPI.

Architecture

breakout-turbo-env architecture

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

breakout_turbo_env-0.2.3-cp311-abi3-manylinux_2_28_x86_64.whl (292.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

breakout_turbo_env-0.2.3-cp311-abi3-macosx_11_0_arm64.whl (259.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file breakout_turbo_env-0.2.3-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for breakout_turbo_env-0.2.3-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6498ee9b80659fb66fbf404a80753cf10c7e37ccb680843ef21db384528b7aeb
MD5 4d6b3a00e238acbfe4b3a735c2369b3e
BLAKE2b-256 aee41e2915c63d2e9b7ebac3fc463b069caa4078d3e4239da3f20e61f538b467

See more details on using hashes here.

Provenance

The following attestation bundles were made for breakout_turbo_env-0.2.3-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on tsilva/breakout-turbo-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file breakout_turbo_env-0.2.3-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for breakout_turbo_env-0.2.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4347025eaf48fe26dade268de714afafa5afb8925c8c5d83601268cbc66c9ee
MD5 66ecca2d355cda2efa64ed478180a32e
BLAKE2b-256 a174183918e2f8213cd457fe62cdc7f1c3a1c54a17149bb02fe518b7af8b6b4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for breakout_turbo_env-0.2.3-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on tsilva/breakout-turbo-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page