Skip to main content

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

Project description

breakout-turbo-env

breakout-turbo-env logo

breakout-turbo-env is a deterministic Breakout environment for reinforcement-learning experiments, policy training, and learned-emulator datasets. It is aimed at researchers and engineers who need many identical game lanes, reproducible transitions, and observations that match a fixed Gymnasium vector-environment contract. Install it from source, build the native extension, then use the Python API, the interactive player, or the benchmark command.

The public API is BreakoutVecEnv. Rust owns fixed-point physics, parallel lane stepping, indexed rendering, frame skip, frame stacking, and observation preprocessing; Python provides the Gymnasium lifecycle and state/branching helpers.

Install

Requirements: Python 3.11+, uv, and a Rust toolchain.

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

Use

import numpy as np
from breakout_turbo_env import BreakoutVecEnv

env = BreakoutVecEnv(
    num_envs=4096,
    num_threads=8,
    obs_resize=(84, 84),
    frame_skip=4,
    frame_stack=4,
    obs_copy="safe_view",
    info_filter="none",
)

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 default observation batch is grayscale uint8 in CHW order with shape (num_envs, 4, 84, 84). Actions are 0 (noop), 1 (left), and 2 (right).

Exact snapshots can be replayed or branched without mutating the live lanes:

states = env.get_state()
branches = env.branch(states[:128], actions=(0, 1, 2))

Play

uv run breakout-turbo-env play

Use Left/Right or A/D to move, Space or R to reset, P to pause, and Escape to quit. Choose a deterministic layout with --layout checker, --layout tunnel, or --layout sparse; --show-obs opens the four-frame processed observation stack in a second window.

Benchmark

uv run breakout-turbo-env benchmark

The benchmark uses 16 environments with grayscale area resize, CHW observations, frame skip 4, frame stack 4, safe-view buffers, disabled max-pooling, and manual resets. Use --steps, --warmup, --repeats, and --threads to change measurement length or CPU concurrency. Its console output follows the sibling SuperMarioBros-Nes-turbo benchmark shape: config=..., obs_shape=..., one run=... line per repeat, and a summary=... line with environment steps, emulated frames, and observation-buffer throughput.

On the development Apple Silicon host, the optimized 8-thread path sustains roughly 277,000 policy transitions/s (1.11 million native ticks/s) and 7.8 GB/s of processed observation output after warmup.

Commands

uv run pytest                         # run contract and regression tests
uv run breakout-turbo-env play --help      # list player options
uv run breakout-turbo-env benchmark --help # list benchmark options

Release

With the locked development environment installed, launch the repository-owned release flow:

make release

For a new PyPI project, this releases the current unused version. Afterwards it defaults to the next patch version; use scripts/release.py --part minor, --part major, or --to <version> for another release shape. The command requires a clean tree synchronized with its upstream, validates locally, creates the release commit when version files change, tags the release, and atomically pushes the branch and tag.

The tag triggers .github/workflows/release.yml, which builds and audits macOS arm64 and Linux x86_64 wheels, then publishes them to PyPI through trusted publishing. Manual workflow runs build and audit artifacts without publishing.

Notes

  • The environment is manual-reset only. AutoresetMode.DISABLED is the only accepted mode, and a terminal lane must be included in an explicit reset(options={"reset_mask": mask}) before its next step.
  • There is no hidden reset randomness. Built-in starts are full, checker, tunnel, and sparse; selected lanes can be reset while other lanes continue unchanged.
  • obs_layout="chw", grayscale observations, area resize, render_mode="rgb_array", and maxpool_last_two=False are fixed by the policy contract.
  • render() returns the raw 96×96 RGB game frame. Training observations are preprocessed grayscale uint8 frames and do not include the play window HUD.
  • The Rust extension is built in release mode by maturin; uv.lock pins the Python dependency resolution window.

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.1.0-cp311-abi3-manylinux_2_28_x86_64.whl (289.6 kB view details)

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

breakout_turbo_env-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (259.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for breakout_turbo_env-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a2f96bc06ab5e560b52b2fc8f4214751b0bcc1ed56792e3173494735f3b0cbf
MD5 a126da3aceb901e57277e345452df2af
BLAKE2b-256 531f21c17ceec29c3f79607060f86d8b0fbfeed0a74af5a3397818395cb6b649

See more details on using hashes here.

Provenance

The following attestation bundles were made for breakout_turbo_env-0.1.0-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.1.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for breakout_turbo_env-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5f811bc21d53339d245248b55ebd6e2020b5bcc6e45ca6edc1488f3d64b34a4
MD5 e665c56940afc9cb4e9d86961031b5b2
BLAKE2b-256 b6a9cfca06bc12ba3f31ddb72b845ac2f6da3a95164bd0a08a7c404d3d10294f

See more details on using hashes here.

Provenance

The following attestation bundles were made for breakout_turbo_env-0.1.0-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