Skip to content

feat: Tears of the Kingdom and Breath of the Wild record the player's route and replay it, as Ocarina of Time - #2402

Merged
ly05010419 merged 3 commits into
ly05010419:mainfrom
orcakhan:route-tape
Nov 26, 2026
Merged

ly05010419 merged 3 commits into
ly05010419:mainfrom
orcakhan:route-tape

Conversation

@orcakhan

Copy link
Copy Markdown
Contributor

What

Tears of the Kingdom and Breath of the Wild can record the route a player plays and replay it, as Ocarina of Time does (ca71d60). An A/B of two runtimes can then run on the same route, which a scripted walk could not do: one ran Link into a rock in Kakariko.

  • games/oot/runtime/input_tape.h moves to shared/runtime/input_tape.h. games/oot and games/totk link to it, as with the other shared files (shared/README.md row added).
  • games/totk/runtime/input.c pad_states hands the tape the merged state of the pad in use: keyboard, controller buttons and sticks, after the VR pitch lock.
  • TOTK_INPUT_RECORD=<file> records each change by frame. Frames count from the start, then from the world's first frame.
  • TOTK_INPUT_REPLAY=<file> plays the tape instead of the real input. On the Mac it closes the game when the route ends.
  • The OOT_ names still work. TOTK_INPUT_REPLAY_LIVE is added beside OOT_INPUT_REPLAY_LIVE.
  • When no variable is set, nothing changes: four getenvs once, then one uncontended lock per pad_states call.

Breath of the Wild needs the frame step pinned. Above 30 fps, 1.9.0 steps game time by each frame's measured length. A tape replayed by frames therefore drifted from the recorded path. With framestep 8.333 sent through TOTK_INPUT_FILE (at launch and again once the world is entered), both while recording and while replaying, replays follow the route. This is noted in the header and in the README row.

Checked

  • Breath of the Wild 1.9.0 on an M4 Pro, uncapped, with a route the user recorded (about 7,800 world frames). Six replays with the frame step pinned plus one with this branch's final runtime:
    • every replay entered the world on the same frame (5837), reached the tape's end and closed itself;
    • fps was 100.3–102.2;
    • the user watched a replay and it followed the route.
  • tests/test_totk_input_tape.py:
    • records and replays under the TOTK_ names;
    • the tape sits after every merge and inside the pad-in-use block (it fails with the call moved after the block);
    • both games link the one shared file.
  • tests/test_oot_input_tape.py now strips exported OOT_INPUT_* / TOTK_INPUT_*. Otherwise a shell holding a real TOTK_INPUT_RECORD would have its tape overwritten by the probe.
  • .github/run_source_tests.py core (2,404 tests, 31 skipped) and settings (8 tests, 3 skipped) pass with the Python 3.14 ui-pack environment. The skips were not investigated.
  • input.c builds with -Wall -Wextra -Werror for BotW, BotW 1.9.0 and TotK. An independent review also built it for V121, V143, BOTW160, DKB, Pokopia and the iPhoneOS SDK.
  • The independent review also checked:
    • symlink handling in build_app.py (sync_folder), games/oot/build.py and the Launcher's source archive;
    • lock order: always inputLock, then the tape's mutex.

Not in this PR (seen in review; these behaviours were already there before this change)

  • games/totk/Makefile probe-input, probe-input-file and probe-autoload already fail to link on main (7 undefined symbols). Whoever repairs them must also define dm_nvn_frame_count and mtl_world_frame.
  • Before the world, a replay replaces the whole state, so the title presses are the tape's, at frames counted from the start. If a build reaches the title later in frames, those presses miss and the game stays at the title.
  • Ocarina of Time's input.c still calls the tape after the pad-in-use block. It has the same multi-id exposure the TotK hook avoids here; it is left as it is.

🤖 Generated with Claude Code

orcakhan and others added 3 commits November 26, 2026 12:16
…oute and play it again, as Ocarina of Time

games/oot/runtime/input_tape.h (ca71d60) moves to shared/runtime/input_tape.h, linked from games/oot and games/totk.
TotK's pad_states hands the tape the merged controller state, as OoT's does. TOTK_INPUT_RECORD=<file> records each change
by frame (from the start, then from the world's first frame); TOTK_INPUT_REPLAY=<file> plays it instead of the real
input and closes the game when the route ends. The OOT_ names still work. For A/B runs on a route the user played: a
scripted walk ran Link into a rock in Kakariko.

Tests: tests/test_totk_input_tape.py (record and replay under the TOTK_ names; the tape sits after the controller merge;
one file for both games); tests/test_oot_input_tape.py unchanged and passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ned, as recorded

Breath of the Wild 1.9.0's real-time step follows each frame's measured length, so a tape replayed by frames drifted
from the recorded route (2026-11-26). With framestep 8.333 sent while recording and while replaying, six replays of one
route each reached its end on the same frames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test ignores an exported TOTK_ tape

From an independent review of this branch:
- games/totk/runtime/input.c calls input_tape inside the pad-in-use block. After it, a read of another controller id in
  the same frame added a line of zeros to the recording, and a replay (the frame's last line wins) handed the pad zeros.
- tests/test_oot_input_tape.py drops OOT_INPUT_* / TOTK_INPUT_* from the environment: the shared header reads the TOTK_
  names first, so an exported TOTK_INPUT_RECORD made the probe write its route over the user's tape.
- tests/test_totk_input_tape.py requires the tape after every merge (controller buttons and sticks, the VR pitch lock)
  and inside the pad-in-use block; with the call back after the block it fails.
- TOTK_INPUT_REPLAY_LIVE joins the TOTK_ names; the docs say a finished replay closes the game on the Mac only (the iOS
  frontend's close only logs).

Checked: a Breath of the Wild replay of the user's route with this runtime entered the world on the same frame (5837),
reached the tape's end and closed itself, at 101.8 fps as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ly05010419
ly05010419 merged commit afdda6f into ly05010419:main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants