Skip to content

FRLG AutoStory: settle and Center visit on the shared seam-5 code - #551

Draft
dayfine wants to merge 67 commits into
frlg/seam4-adoptfrom
frlg/seam5-adopt
Draft

dayfine wants to merge 67 commits into
frlg/seam4-adoptfrom
frlg/seam5-adopt

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Depends on #521, #546. Base frlg/seam4-adopt; #546 (autostory/center-settle) is merged in (merge 3b2950e), so until #521's base has nav/shared's commits the diff also shows #546 and its parents. This PR's own change is the three commits after the merge.

FRLG AutoStory moves onto seam 5's shared settle loop and Center visit (#546's adoption list, step-5 design note decisions 1-6; BDSP's is #549).

  • wait_for_quiet_overworld runs run_settle with the DOOR rule, a look every 400 ms (BETWEEN_STEPS_LOOK) and the caller's cap (10 s after a battle). It still only watches: no presses, and a battle still showing is waited out.
  • FrlgScreenObserver and the sim report a screen with no box, fade or battle as QUIET_OVERWORLD (PLAYER_CAN_MOVE + PLAYER_STILL), which lets the shared loop end on FRLG.
  • center_enter/center_exit call enter_center/leave_center through a console CenterVisitIO. The walks are the same room legs as before. heal_in_center is now heal() (upstream heal_at_pokecenter + healed_by_nurse, no new nurse code), and shows_pokemon_center_floor is place(). A HEAL with no Center floor, or an exit that stays inside, returns heal_enter/heal_exit instead of throwing.
  • The row sim runs the same visit (SimCenterVisit) for the Center steps and for HEAL, which used to be a stub. The nurse is not played.
  • FRLG keeps its three steps, so its Center settle is a no-op: wait_out_warp in the room legs already waits out each door's fade and then AFTER_WARP. The whole-row LATE_FADE and SLOW_FADE_IN sweeps now also cover the Center doors and HEAL, through the visit.

Testing

  • New AutoStoryRooms - Center fails cases: a heal with no Center floor (12.03) and an exit whose door shows black but leaves the player inside. Both were red before this change: the HEAL stub passed, and the exit failed only on its end pose. The seven Center: cases now heal between the two doors.
  • ScreenEvents, FlyLanding and StepInterrupts test fixtures use QUIET_OVERWORLD for the quiet overworld.
  • All FRLG AutoStory and Overworld files pass a local syntax-only compile (clang, no warnings). Code health: 0 failures. Fork Draft CI runs the suites. No console run.

dayfine and others added 30 commits November 13, 2026 20:57
Code Health's test-case rule wants each UnitTest built from one case
struct of name, input and expectation, with the name outside the input.
Move every case's name from its Input to the case itself, nest the
RngHandoff input and expectation structs, and give the first-save,
captured-transition and move-mechanics cases explicit names (the same
test names as before). Assertions and test bodies are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
An Outcome may carry its StoryFailureClass (outcome_failed's third
argument, for a game's own failure names); failure_class_of() falls back
to the shared list's class for the name. The engine's failure lines
([Event], [Checkpoint], [Step], [Segment], [Verify]) end with
"(class=<id>)" when the class is known, and an OperationFailedException
that leaves an event is logged as class=operation_failed.

Pokemon_StoryFaultSweep: a game gives its sweep as data (rows, an
injector per sim fault, the known-failing list); the engine makes one
test per class and row, named "<row>, <class id>", judges it, and checks
the known-failing list names only its tests.

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

# Conflicts:
#	SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryEngine_Tests.cpp
… run

The shared wire cases at PokemonSimulation 866613f (and its main) still use
the old pose (certainty/where) and per-kind step fields; since the #312
review the native reader reads steps as an action plus typed args, so every
kind case without args failed. The Python reader still checks those cases;
the native codec is covered by its own CTest cases.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
… on #312, ScreenEvents case names

Conflicts: ScreenEvents_Tests.cpp takes #313's case struct (name outside the input); the story-data README keeps this branch's reader-only text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…known (#312 review)

checkpoint_end_pose() stopped looking back only at LEGS, so a STEP after a route kept the route's target as the end and the tile check failed a run that worked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
AutoStory: story step types and engine (split from #122, layer 1 of 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
CommonTools: screen events for autonomous programs.

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

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

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

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

Conflict: the engine-runs test table takes the engine's case shape (name outside the input); the breakpoint rows are written in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
AutoStory: one story engine over a backend, save mode from checkpoint metadata.
dayfine and others added 29 commits November 14, 2026 14:43
… 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.
run_settle() is one settle loop over TalkOver for every game, with the
rule for each SettleKind (talk, after a warp, door) in one table. The
door rule (1 s of the player still, 2.5 s calm, a look every 200 ms)
comes from the BDSP tree as TalkOverRule's quiet and still fields and
the PLAYER_STILL screen event.

run_center_visit() is the shared order of a Center visit: in, settle,
check inside, heal, out, settle (door or after warp), check outside.
Games give the walks, reads and nurse through CenterVisitIO.
Door times private to the settle table, SettleEnd::Result nested, the
IO last in run_settle() and the visit functions.
…lg/seam5-adopt

# Conflicts:
#	SerialPrograms/Source/Pokemon/AutoStory/Data/Pokemon_StoryStepJson.cpp
#	SerialPrograms/Source/Pokemon/AutoStory/Data/Pokemon_StoryStepJson_Tests.cpp
#	SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp
#	SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp
#	SerialPrograms/Source/Pokemon/Navigation/Pokemon_MapData_Tests.cpp
A heal with no Center floor must fail before the nurse (12.03, console B
2026-11-13 04:16), and a Center exit whose door shows its black but
leaves the player inside must fail as still inside. The in-and-out
case for each Center now heals between the two.
wait_for_quiet_overworld runs Pokemon::run_settle with the DOOR rule, a
look every BETWEEN_STEPS_LOOK and the caller's cap; it only watches, as
before. FrlgScreenObserver (and the sim's events) report a screen with no
box, fade or battle as QUIET_OVERWORLD (PLAYER_CAN_MOVE + PLAYER_STILL),
so the shared loop ends on FRLG. The center_enter and center_exit steps
run Pokemon::enter_center / leave_center through ConsoleCenterVisit; the
HEAL step is heal_at_nurse(): the Center's floor as place(), then
upstream's heal_at_pokecenter and healed_by_nurse as heal(). A missing
floor or an exit that stays inside now returns heal_enter / heal_exit.
The row sim runs the same visit (SimCenterVisit) for the Center steps and
HEAL, the nurse not played.
center_step() returns nothing for a step that is not a Center's, so
Events.cpp stays within its line allowance; each CenterHeal.h function
has its own comment.
The sim has no map of Celadon's or Saffron's Center, so their center_enter
steps are stubbed and the player stays in town; the heal after them now
checks for a Center floor and failed 08.03, 14.04b and 16.06's cases.
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