AI Training Lab

Evolve a neural network to play a NES game. Rewards and the agent's senses are read straight from CPU RAM.

Waiting for ROM No ROM loaded
Emulator

Load a ROM and configure at least one reward rule.

0 active rewards 0 observations 8 / 8 AI buttons

Reward history

Best and mean reward per generation, last 120 generations.

Training setup

Everything here locks while training runs.

Experiment

Four workers create four independent NES/WASM instances. The browser can schedule them across separate logical CPU cores; web pages cannot pin a worker to a specific physical core.

Evolution

How the sweep works

Every run restores the selected start state before frame 1. Under trajectory memory sweep the first generation is 100% neural-network controlled. Later generations replay the previous champion for evenly spaced prefixes: with 100 runs that is 99%, 98%, …, 1%, 0%, then the candidate network takes over. During the replay prefix the candidate still receives every observation and updates recurrent memory; only its controller output is ignored.

Trajectory memory keeps the best complete controller path found so far and branches candidate recurrent networks from different points along it. Policy breeding scores only the reward earned after neural takeover, while champion selection still uses the complete run.

What the agent senses

The SMB sensor activates automatically only for a detected Super Mario Bros. ROM. It converts the collision tile buffer and active enemies into a Mario-centered local map, so holes and obstacles are meaningful inputs instead of raw tile IDs.

Controller outputs

Each enabled button is an independent neural output every frame, and enabled outputs can still combine freely in the same frame. “None” is always possible when no enabled output crosses its activation threshold. Disable buttons the game should never use — for example Start, once gameplay begins.

Replays and storage

Estimated replay storage: --

Saved profiles

Profiles, model weights, statistics, retained input replays and the optional ~2 MiB training checkpoint live in IndexedDB in this browser. ROM files are never copied into a profile.

Reset generation data Clears learned weights, trajectory memory, generation number, statistics and retained replays. Reward rules, observations, training settings and your checkpoint are kept.

Reward rules

What the trainer should make better or worse. Up to 10 rules.

OnLabelAddressTypeFeedback triggerTargetModeEveryStrengthWrapProgressEnd runValue
Test reward: 0.00
Load a ROM, start the game, then start Reward Test to verify your memory rules before training.
Writing a rule

Each rule reads one base address for consecutive bytes, or one explicit comma-separated address per byte. Binary 8/16/24/32-bit, packed BCD and byte-per-digit BCD values are all supported. Change rules, edge-triggered target and threshold rules, and continuous While-rules are available.

Continuous rewards can fire every N emulated frames or every N game-seconds, so training speed never changes the reward rate. Example for Super Mario Bros. full running speed: $0057, 8-bit signed, While = target → positive, target 24. Set Every to 1 game-sec for one reward per game-second at full speed, or 1 frame for a reward on every qualifying emulated frame.

Observations

The decoded RAM the agent sees. Reward values are included automatically.

0 / 2,048 inputsRanges are read directly from shared WASM CPU RAM.
Rows, ranges and limits

A row accepts a single typed value, explicit composite bytes, or a range such as $0000-$00FF. A range is split into non-overlapping values of the selected type; with 8-bit unsigned that observes every byte in the range. Up to 2,048 effective neural inputs across 64 rows.

Memory finder

Locate the address behind a score, timer or position.

No scan
No candidates yet.
How scanning works

Pick the width and type, take a RAM snapshot, then filter by change or type a known current value. The scanner searches contiguous candidates and understands packed BCD plus one-decimal-digit-per-byte values such as the Super Mario Bros. timer. CPU RAM values can be binary, packed BCD, or one decimal digit per byte, contiguous or assembled from explicit non-contiguous byte addresses — after discovery, a rule can be edited into a non-contiguous composite value when a game stores its bytes separately.

Replay archive

Controller masks, not video: one 8-button mask per frame, RLE compressed.

No generations saved
No replay data yet.

Older retained replays stay playable. Multi-run overlays and video export are the next replay milestone.