Skip to content

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

Draft
dayfine wants to merge 466 commits into
autostory/story-range-optionsfrom
autostory/sv-retry-core
Draft

dayfine wants to merge 466 commits into
autostory/story-range-optionsfrom
autostory/sv-retry-core

Conversation

@dayfine

@dayfine dayfine commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Depends on #325 (base autostory/story-range-options); the diff shows only 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 11, 2026 21:38
Conflict in PokemonFRLG_Tests.cpp's registration list: kept main's sorted list and added this branch's BagDetector, BattleMoveSelectionArrow and AutoStoryScreenEvents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Conflict in SourceFiles.cmake: kept both file lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Pokemon_StoryBackend.h forward-declared Pokemon::ScreenEvents, which shadowed
the engine's ScreenEvents in namespace Pokemon. The bridge now has its own
header that includes Pokemon_ScreenEventTypes.h, so the backend header needs
neither, and the engine tests write a bare ScreenEvents again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Same fix as 74e5b90 on frlg/stage8-rocktunnel; the BDSP line got the
test from f360dd3 without it, so its Ubuntu build failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
(cherry picked from commit 2b4544d)
…e messages name expected and actual (#402 review)

FRLG's Bicycle taps 40 ms at one per 100 ms, its walk 66 ms with a 700 ms
release, so the step tap moves from MoveMechanics onto Gait. Every scalar
gets a default, and the test reports which gait and which value failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
A defaulted operator<=> (x, then y) lets planners keep tiles and places
built from them in ordered sets with std::less instead of hand-written
comparators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…exes, orders MapPlace (#408 review)

The rvalue constructor is deleted, map() throws InternalProgramError past
the last map, and MapPlace gets a defaulted <=> over TilePos's. The test
art matches the maps, the Lake to Route edge has two cases, and stale map
indexes have their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Shared plumbing for seam 3's sim goldens: a golden's path beside its
test, its text, the first differing line, and a check that rewrites the
file when PA_UPDATE_SIM_GOLDENS is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… for the sims

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
dayfine and others added 30 commits November 14, 2026 14:06
A reload after that save would land mid-checkpoint while the retry runs
from step 1. The engine now records the save and ends the checkpoint's
attempts there.
…text

A test pins that the engine's SAVE step saves nothing in a testing run;
StoryStepExecutor::run says a game off the engine must gate it itself.
The step reader accepts once_per_save. The Save and Verify Mode texts
say when After verification saves.
Declared poses reach the run as the event layer's pose; a zone's spot and
heading are not carried until a game has a position reader.
… value

INTEGER_ROWS stays: FRLG's foe_threats and BDSP's avoid args use it.
A user's run skips dev-only rows, so the row a reload follows there must
autosave as well.
story_failure_class_info() throws for a class with no row in its place,
and a test checks every class has one.
Covers the first frame's rises, rose/fell edges, the capacity drop and
describe().
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
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.
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