Skip to main content
env-SuperMarioBrosNes-turbo-emu icon

🚀 Blazing fast SuperMarioBros-Nes environment for Reinforcement Learning 🍄

env-SuperMarioBrosNes-turbo-emu is a specialized Python environment for reinforcement-learning researchers who need fast, reproducible Super Mario Bros NES rollouts. It combines native Gymnasium vector lanes with deterministic lane-local episode control, reusable saved and live state, configurable actions and observations, and opt-in semantic game data. Supply your own supported ROM, then play immediately or use the vector API from Python.

In the verified 0.6.4 benchmarks, backed by the immutable published evidence, it measured 15.42× to 17.27× the throughput of original Stable Retro across the matched vector shapes.

Quick start

Prebuilt wheels support Python >=3.9 on Apple-silicon macOS and x86-64 Linux. Install the CLI with uv and launch Level 1-1 with your local ROM:

uv tool install env-supermariobrosnes-turbo-emu
smb-turbo play --rom /absolute/path/to/SuperMarioBros.nes

Playback opens a local window and requires a discoverable SDL2 runtime. Use the arrow keys or A/D to move, X/J/Space to jump, Z/K/Shift to run, and Escape to quit.

To register the ROM once for later commands, use a Stable Retro-compatible data directory:

export RETRO_DATA_PATH="${XDG_DATA_HOME:-$HOME/.local/share}/retro"
smb-turbo import /absolute/path/to/SuperMarioBros.nes
smb-turbo play

ROM files are never included in this repository or its distributions.

What it provides

  • Native vector execution. One step() advances every lane through batched Rust emulation, preprocessing, rewards, termination, and infos. The step_async() interface and automatic or explicit num_threads control are available for vector runners.
  • Deterministic episode control. Every seeded lane owns its emulator and random state. Autoreset stays disabled, options["reset_mask"] resets only selected lanes, and noop_reset_max, sticky_action_prob, and reward_clip provide built-in training controls.
  • Reusable exact starts. Select saved starts per lane with state_indices, inspect active catalog entries, or capture live snapshots without advancing emulation. Portable snapshots move exact continuation state between compatible environment instances, processes, and hosts.
  • Exact action contracts. Use unrestricted or filtered button masks, Stable Retro-compatible 36-way Actions.DISCRETE, Actions.MULTI_DISCRETE, packaged named presets, or caller-supplied button tables with discoverable meanings.
  • Configurable visual data. Choose grayscale or RGB, frame skip, max-pooling, crop removal or masking, nearest/bilinear/area resize, frame stacking, and CHW or HWC layout. obs_copy controls ownership. Rendering is opt-in with render_mode="rgb_array"; otherwise render() and render_lane() return None, and get_images() returns one None entry per lane.
  • Research-ready game state. Raw progress signals, opt-in semantic player, enemy, and area data, info_filter, and immutable batched ram() snapshots expose only the state a downstream task requests.
  • Self-describing API. Immutable capabilities, signal_schema, action metadata, observation ownership, and snapshot-codec metadata let integrations inspect the environment contract instead of guessing it.
  • State-aware playback. Manual and framework-free action-run playback use exact state identifiers and automatically switch to matching canonical-level policies as Mario advances.

Compared with Stable Retro

Stable Retro is a general Gymnasium environment for many games and emulators. Turbo deliberately specializes its native vector execution, selective resets, state catalogs, portable snapshots, preprocessing, and semantic research data for Super Mario Bros NES while retaining compatible ROM discovery and action semantics where applicable. It is not a drop-in Stable Retro replacement.

Stable Retro remains the broader choice for multi-game and multi-emulator use, multiplayer, RAM observations, and BK2 movie recording. Turbo supports only the documented SMB mapper 0/NROM workload, one player, and image observations, with batched RAM available separately through ram(); it does not record BK2 movies.

Fidelity changes are tested directly against pinned original stable-retro==1.0.1, not only against the Turbo fork. The ROM-backed TurboBench parity profile covers all four World 1 start states, scalar and four-lane execution, observations, lossless native frames, rewards, episode boundaries, info, exact 2 KiB CPU RAM, lane resets, and snapshot continuation. Reproduction and release-receipt commands are in CONTRIBUTING.md.

Use from Python

Add the package to a uv-managed project:

uv add env-supermariobrosnes-turbo-emu
import gymnasium as gym

from env_supermariobrosnes_turbo_emu import (
    Actions,
    action_batch,
)

env = gym.make_vec(
    "env_supermariobrosnes_turbo_emu:EnvSuperMarioBrosNesTurboEmu-v0",
    game="SuperMarioBros-Nes-v0",
    state="Level1-1",
    rom_path="/absolute/path/to/SuperMarioBros.nes",
    num_envs=16,
    use_restricted_actions=Actions.ALL,
)

try:
    observations, infos = env.reset(seed=123)
    observations, rewards, terminated, truncated, infos = env.step(
        action_batch("right", env.num_envs)
    )

    done = terminated | truncated
    if done.any():
        observations, reset_infos = env.reset(
            options={"reset_mask": done.copy()},
        )
finally:
    env.close()

The module-qualified ID imports the package and registers the factory. This ID is vector-only and requires an explicit game; the native EnvSuperMarioBrosNesTurboEmuVecEnv constructor remains available for direct use. It implements Turbo Vector API v2 with NumPy transitions, shared 84x84 grayscale CHW defaults, immutable capability and signal declarations, and disabled-by-default rendering.

See API.md for the complete action, observation, state, snapshot, rendering, playback, and research-info contracts.

Train with GradLab

Training implementations and recipes live in GradLab, outside this environment repository. Run either published, version-pinned recipe from any directory with your local ROM.

Short PPO demonstration:

uvx gradlab@0.1.1 train SuperMarioBros-Nes-v0/Level1-1/turbo-demo --rom /absolute/path/to/SuperMarioBros.nes

Go-Explore trajectory discovery capped at 20 million transitions:

uvx gradlab@0.1.1 train SuperMarioBros-Nes-v0/Level1-1/go-explore-jerk-20m --rom /absolute/path/to/SuperMarioBros.nes

GradLab downloads the pinned runtime on first use, verifies the ROM in place, shows live progress, and writes a playable final_model.zip below ./runs. The PPO demonstration runs 98,304 steps across 16 environments and takes roughly two minutes on the calibrated M1 Pro; timing varies by hardware. When a run finishes or stops safely, GradLab prints its version-pinned playback command.

Commands

smb-turbo import /path/to/roms       # register the supported ROM
smb-turbo play                       # play Level1-1 manually or with its policy
smb-turbo play Level2-1 --fps max    # choose an exact state and run uncapped

For source builds, tests, and contribution commands, see CONTRIBUTING.md.

Benchmarks

BENCHMARKS.md contains the exact workloads, results, machine profile, and reproduction commands. The current result is preserved in the immutable Hugging Face v0.6.4 tag, including the exact verified bundle. Install the public TurboBench 1.0.2 verifier with:

uv tool install --refresh --force \
  --exclude-newer-package turbobench-cli=2026-08-13T15:41:56Z \
  turbobench-cli==1.0.2

Notes

  • Scope: This is specialized for SuperMarioBros-Nes-v0 on mapper 0/NROM; it is not a general NES emulator or Stable Retro replacement.
  • ROM identity: The canonical ROM SHA-256 is f61548fdf1670cffefcc4f0b7bdcdd9eaba0c226e3b74f8666071496988248de.
  • ROM discovery: RETRO_DATA_PATH, rom_path=, and smb-turbo play --rom are supported. Imported ROMs use <RETRO_DATA_PATH>/stable/SuperMarioBros-Nes-v0/rom.nes.
  • Playback: smb-turbo play and play.py use exact state identifiers, default to Level1-1, and automatically select matching action-run policies as canonical levels change.
  • Affiliation: This unofficial research project is not affiliated with or endorsed by Nintendo. See NOTICE.md.

Architecture

env-SuperMarioBrosNes-turbo-emu architecture diagram

See ARCHITECTURE.md for the native component boundaries and verification hooks.

License

Code is licensed under the MIT License. Third-party names, marks, and user-supplied content are excluded; see NOTICE.md.

Download files

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

Source Distribution

env_supermariobrosnes_turbo_emu-0.7.2.tar.gz (21.0 MB view details)

Uploaded Source

Built Distributions

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

env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-manylinux_2_28_x86_64.whl (534.6 kB view details)

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

env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-macosx_14_0_arm64.whl (489.9 kB view details)

Uploaded CPython 3.9+macOS 14.0+ ARM64

File details

Details for the file env_supermariobrosnes_turbo_emu-0.7.2.tar.gz.

File metadata

File hashes

Hashes for env_supermariobrosnes_turbo_emu-0.7.2.tar.gz
Algorithm Hash digest
SHA256 6a2cf49ef35cc495fea665d2163ca7e0da6940db241a1fcc6cea7a8569284068
MD5 0fc357dab5d435557f3d2d7ee3e039d1
BLAKE2b-256 ae2c0880d66692fab95d2415c0082ed4b5dcdfd9f2f69939bbc7f44651577ecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_supermariobrosnes_turbo_emu-0.7.2.tar.gz:

Publisher: release.yml on tsilva/env-SuperMarioBrosNes-turbo-emu

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

File details

Details for the file env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9453a59238a0a3a624ab623c3954e26a93eb8c6de68e54dcee06afe33b9f493e
MD5 2ac3d2a7dcb9ee22eb76b253956dde56
BLAKE2b-256 460cca27da4645f1fd845b4a3dac4be620a0183701902d9124d168b987e266b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on tsilva/env-SuperMarioBrosNes-turbo-emu

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

File details

Details for the file env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 94816d5f00ae202216ad66318b726bc5a98dcfa279431113e5d5458eb3f8b126
MD5 c3343a718e20d1fa2c80e01ae85dbc73
BLAKE2b-256 aa709222151546087a3c219870fb6f9be76f2a5989261bd5e08b95aaa9b42518

See more details on using hashes here.

Provenance

The following attestation bundles were made for env_supermariobrosnes_turbo_emu-0.7.2-cp39-abi3-macosx_14_0_arm64.whl:

Publisher: release.yml on tsilva/env-SuperMarioBrosNes-turbo-emu

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

Release history Release notifications | RSS feed

0.7.3

3 files

This release

0.7.2 This release

3 files

0.7.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page