Skip to content

Pokemon AutoStory: share SV's checkpoint retry loop - #391

Draft
dayfine wants to merge 549 commits into
switch/system-keyboardfrom
autostory/sv-retry-core
Draft

dayfine wants to merge 549 commits into
switch/system-keyboardfrom
autostory/sv-retry-core

Conversation

@dayfine

@dayfine dayfine commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Depends on #62 (base switch/system-keyboard); folds in #45 (shared run report) and #325 (checkpoint range options, superseded upstream by #572), so the diff shows those and this change.

Every AutoStory had its own checkpoint retry loop: SV's checkpoint_reattempt_loop and its tutorial twin, the story segments (#114) and the story engine (#332). This adds the one shared loop, run_checkpoint_attempts() in Pokemon_CheckpointAttempts.h: an attempt passes, fails, or fails in a way another attempt would repeat, the game's reset may fail, and the loop writes the shared pass line. Pokemon_CheckpointRetry.h is SV's policy on top of it (run_checkpoint_with_retries(), where a failed attempt throws, and record_checkpoint_saved()), with SV's counts unchanged (102 attempts, report on the 11th failure); SV's AutoStoryStats stays in SV (#45), so these take the one counter they add to, and SV passes stats.m_reset / stats.m_checkpoint; SV's lines become the shared start, attempt, reset and pass lines, named by SV's own checkpoint text through #45's display text ("Checkpoint:: 004 - 02 ...: attempt 2/102"). #114 and #332 merge this and run their loops through it. Tested with the Pokemon::CheckpointRetry suite (SV policy and shared loop cases) and all Pokemon:: suites in test mode, which pass.

dayfine and others added 30 commits November 12, 2026 07:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…tory-options

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…ts links Pokemon_Direction.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…-map-tests links Pokemon_Direction.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ests links Pokemon_Direction.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…inks Pokemon_Direction.cpp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ment, README counts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…shared expect_equal, frame-name parsing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 25 commits November 14, 2026 15:04
AutoStory: review fixes on the shared engine (#312, #313, #332, #474, #479)
…again

StoryDataTests takes the path of a pokesim-story-wire-cases/2 file, reads
each case with the native pose, step and checkpoint readers and checks the
accept/reject and the record read. The workflow pins PokemonSimulation
4e023f3 (#104, cases in the action-plus-args form) and runs it on all three
platforms.
Answers the #312 review: the Switch FireRed/LeafGreen are the GBA releases
reissued, one version per language with no in-game option, so all six
languages stay (as in upstream's FRLG programs). Gen 8-9 games have one
Spanish, so one "es". Code that reads text takes the language option.
…e fails loudly

The standalone main moves to devtools/story-data-tests/StoryDataMain.cpp so program source no longer includes a devtools header; other argument counts print usage and exit 2. The wire-case reader reads a case's own fields outside the try, so a malformed case file throws instead of reading as a rejection. Also plain statements for the verified fields and explicit includes.
Fix shared AutoStory engine review nits
Story data codec: run the shared wire cases natively again
A watch that ends in wall time reads a window full of dropped frames as
"not seen". FrameCoverage records the capture times of the frames a
watcher was handed and finds the largest gap in the window; judge_watch()
returns SEEN, NOT_SEEN (frames cover the window) or UNKNOWN (a gap longer
than max_gap). CoveredWatcher wraps any VisualInferenceCallback and can
stop on the first frame captured at a deadline; run_watched() and
watch_for() end a window in frame time, bounded by a wall-clock cap.
Game languages: FRLG keeps six languages, one Spanish (#312 review)
Review of #114 (dropped frames):
- A hold watcher fires a hold after the screen shows, so a screen that
  shows in the window's last hold fired only after the watch stopped.
  CoveredWatcher now keeps watching until a frame captured `tail` after
  the window's end, still bounded by the wall-clock cap.
- largest_gap rounds up to whole ms, so a gap a fraction over max_gap is
  UNKNOWN, not NOT_SEEN.
- Frames captured before the window opened are not handed to the wrapped
  watcher, so a fire on one is not SEEN.
- The window's end is a constructor argument (watch_for) or set by
  end_at() between sessions (run_watched), documented as such.
- WatchLimits carries max_gap, tail, cap and the poll period; run_watched
  checks only fired(); <cstddef> for size_t.
StoryCheckpoint::postconditions gets = {} so designated initializers that
leave it out build on Windows Clang (-Wmissing-designated-field-initializers).
The eight AutoStory test tables now hold each case's name next to its input
and expectation, as code health's test-case rule asks; the step JSON tests
pass the name to the readers as the parse source.
Windows Clang errors on designated initializers that skip a field
(-Wmissing-designated-field-initializers). A syntax check of every .cpp
nav/shared touches, with the Compiler.h pragma disabled, found only these.
Pokemon navigation: the shared core for AutoStory
…sed, Resets)

SV keeps AutoStoryStats and its saved keys (Checkpoint, Segment, Reset);
the story engines get their own stats type whose names say what they count.
StoryRunCounts.segments becomes runs; record_story_counts and
finish_story_run add a run, each passed checkpoint and each reset to
StoryRunStats (Runs, Checkpoints Passed, Resets). SV's AutoStoryStats
is unchanged.
… autostory/sv-retry-core

Pokemon_CheckpointRetry takes the one counter it adds to (SV passes
stats.m_reset / stats.m_checkpoint) instead of SV's stats struct.
@dayfine
dayfine changed the base branch from autostory/story-range-options to switch/system-keyboard November 17, 2026 16:44
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.

1 participant