typesafe-mario
Super Mario Bros.
Super Mario Bros. agent choosing actions from structured emulator state.
# TypeSafe Mario An experimental controller that lets TypeSafe's Jev model directly choose NES controller inputs for the original Super Mario Bros. The model does **not** receive screenshots. The harness translates emulator telemetry and RAM into compact, object-centric JSON containing Mario's motion, jump trajectory, upcoming enemies, terrain, measured response delay, recent-control results, and episode progress. Jev chooses one of the legal controller actions, the emulator advances several frames, and the loop repeats. The raw local tile grid remains available in debug logs and the UI, but is not duplicated in the model input. ## Architecture ```text NES emulator -> telemetry/RAM parser -> structured JSON -> Jev Choice -> controller input ``` The initial action set is intentionally small: - `noop` - `right` - `right_jump` - `right_run` - `right_run_jump` - `jump` - `left` ## Requirements - Python 3.13 or newer - A TypeSafe API key in `TYPESAFE_API_KEY` - A legal local setup for Super Mario Bros. This repository contains no Nintendo ROM or other copyrighted game data. You are responsible for ensuring that your emulator and game files are obtained and used lawfully. ## Setup ```powershell py -3.13 -m venv .venv .venv\Scripts\python -m pip install -e ".[mario,dev]" $env:TYPESAFE_API_KEY = "your-key" ``` Inspect the exact JSON and text that will be sent to TypeSafe without launching the game or calling the API: ```powershell .venv\Scripts\typesafe-mario state-demo ``` Run World 1-1 with Jev making a decision every eight emulator steps. The default display is a single recordable window with the live game and model telemetry: ```powershell .venv\Scripts\typesafe-mario play --env SuperMarioBros-1-1-v0 --frames-per-decision 8 ``` The dashboard shows the select