Skip to content

AutoStory: shared settle loop and Pokemon Center visit - #546

Merged
dayfine merged 8 commits into
nav/sharedfrom
autostory/center-settle
Nov 15, 2026
Merged

dayfine merged 8 commits into
nav/sharedfrom
autostory/center-settle

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Base: nav/shared (3df87aa). No parent PRs; the diff shows only this change.

Seam 5, shared part: one settle loop and one Pokemon Center visit for every game (design note 2026-11-15-step5-design.md, decisions 1-6 as recommended).

  • Pokemon_Settle: run_settle(rule, label, SettleIO&) is BDSP's talk_over() loop with the console behind SettleIO (look, press, flee a battle, log). settle_rule(SettleKind) is the one table: TALK, AFTER_WARP, and DOOR (1 s of the player still, 2.5 s calm, a look every 200 ms, from the BDSP tree's door rule, c771fb6). Timeouts return the same three failure texts as talk_over().
  • The door rule needs two things in the shared judge: TalkOverRule gets quiet and still fields (defaults keep today's behaviour), and ScreenEvent::PLAYER_STILL is added.
  • Pokemon_CenterVisit: run_center_visit(label, CenterVisitIO&) = enter_center() (walk in, line up by sight if no fade and not inside, DOOR settle, fail heal_enter if the reads say outside), the nurse, leave_center() (walk out, DOOR settle after a fade or AFTER_WARP without one, fail heal_exit if still inside). heal_enter maps to pose_lost and heal_exit to warp_no_op.
  • Pokemon_CenterVisit: CenterVisitIO::settle returns SettleEnd, and a settle that does not end QUIET fails the visit (heal_enter/heal_exit) with its text. line_up_and_walk_in() returns WarpSeen; a lineup that saw no fade settles AFTER_WARP, as the way out does. UNKNOWN passes both place checks.
  • StoryLaunch: StoryLaunchPolicy::overworld_after_load (BDSP). After the launch closed the game or saw its title, an overworld counts only after a title press on a look read as the title and then the load's black (FADE_BLACK), with no title since; until then an overworld look is the attract movie and takes the title press. The black must come within load_black_looks looks of the title press, so a dropped press on an idle title followed by the movie's black is not the load. From console B 2026-11-15: 03:42 (the attract movie settled as the overworld) and 04:21 (the press on the movie went back to the title through a black, and that black counted as the load).
  • Neither game uses the settle loop or the Center visit yet.

Next steps (follow-up PRs, not in this one):

  • BDSP: StoryStepIO::settle and talk_over() call run_settle; drop TalkOverRule::door and BDSP's SettleKind; ConsoleStory::heal and run_into_center become a BdspCenterVisit : CenterVisitIO (enter_lit_door, talk_to_nurse, run_into_door, pokemon_center_inside as place()); the sim's SimExecutor::heal runs the same visit; a red sim case for walking to the nurse during the fade-in.
  • FRLG: wait_for_quiet_overworld calls run_settle(DOOR) with FRLG's look (400 ms) and cap (10 s), and its observer reports quiet as PLAYER_CAN_MOVE + PLAYER_STILL; center_enter/center_exit steps call enter_center/leave_center, and heal_in_center (upstream heal_at_pokecenter + healed_by_nurse) is heal(), with shows_pokemon_center_floor as place(); RowSim's HEAL stub runs the visit; red sim cases for the 12.03 no-floor heal and a Center exit that stays inside.
  • Both: LATE_FADE / SLOW_FADE_IN on the Center visit in the fault sweeps.

Testing

  • New suites Pokemon::Settle (rule table, run_settle on a scripted screen) and Pokemon::CenterVisit (fake IO: call order, both guards, settle timeouts, lineup without a fade), two new rows in Pokemon::StoryFailureClasses, and six new Pokemon::StoryLaunch cases for the load rule (03:42, 04:21, a title after a black, a late black after a dropped title press, a kept overworld). The launcher was checked on console B. Settle, CenterVisit and SceneJudges suites pass locally; Fork Draft CI runs the rest.

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.
…the policy asks

BDSP's title plays an attract movie, a town with people walking, that
reads as the overworld; on console B (2026-11-15 03:42) the launch
settled on it before the title took a press. A policy with
overworld_after_load answers such a look with the title press and counts
the overworld only after a title press and then the load's black.
Console B, 2026-11-15 04:21 (BDSP, Japanese): ZL on the title's attract
movie went back to the title through a black, and that black counted as
the load; the title, read as the overworld, then settled. With
overworld_after_load, a press on an overworld look no longer arms the
load, and a title showing again clears a black seen before it.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: 4264e19

Scope: #546's own diff against nav/shared (settle loop, Center visit, TalkOverRule quiet/still, PLAYER_STILL, StoryLaunchPolicy::overworld_after_load and the title-press rule). CI green. The launcher was verified on console B, so I did not re-check it here.

Required

  1. CenterVisitIO::settle returns void, so a failed settle doesn't reach the visit's Outcome (Pokemon_CenterVisit.h, Pokemon_CenterVisit.cpp). run_settle returns SettleEnd with TIMED_OUT and BATTLE plus a failure text (e.g. "no fade or banner within 120 s ... (map mismatch)"). The visit throws all of that away. leave_center's comment says the AFTER_WARP settle "fails when none shows". With this interface, that only happens if each game's IO throws, and the header doesn't say it must. The BDSP/FRLG/sim implementations in the follow-ups could easily just log and carry on, and then the place() read is the only guard left (it passes on UNKNOWN). Fix: have settle() return SettleEnd, and turn a non-QUIET end into outcome_failed(...) with its text in enter_center/leave_center. Add a CenterVisit case for a settle that times out. If throwing is the intended contract, the header has to say so instead.
  2. The PR description doesn't mention the launch change. Commits a96728c and 4264e19 add StoryLaunchPolicy::overworld_after_load, the m_title_pressed/m_load_seen rule and five StoryLaunch cases. The description and its Testing section only cover settle and Center visit. Add a bullet for it, including the console B 03:42/04:21 cases, and list StoryLaunch among the suites.

Should fix

  1. enter_center after line_up_and_walk_in() uses a DOOR settle with warp = false (Pokemon_CenterVisit.cpp). line_up_and_walk_in() returns void, so the visit can't tell whether the fade has happened yet. DOOR without a warp requirement ends after 1 s of PLAYER_STILL + PLAYER_CAN_MOVE. If the walk returns while the player stands on the mat before the fade starts, the settle can end outside, and the visit then fails heal_enter (RELOAD) for a door that would have worked. leave_center already handles the same case by using AFTER_WARP when nothing was seen. Do the same here: return WarpSeen from line_up_and_walk_in(), and settle AFTER_WARP (or a DOOR rule with warp = true) when it saw nothing. The "no fade, but inside" branch can stay DOOR.

Question (not blocking)

  1. Launch: a dropped title press followed by a black. m_title_pressed stays true once set, so any FADE_BLACK after a title look sets m_load_seen. If BDSP's title goes to the attract movie through a black when it's left idle, this sequence passes as a load: title read and pressed, press dropped (e.g. during the title's intro animation), title fades to black, movie. The movie would then settle as the overworld, which is the 03:42 failure coming back. Do you know whether the title goes to the movie through a black? If it does, a red case TITLE, BLACK, OVERWORLD(movie) with no load would pin it down. One possible fix is to require the black to come within a few looks of the title press, or to clear m_title_pressed once the movie path presses.

Nits

  • Pokemon_CenterVisit.cpp run_center_visit: Outcome in can be const.
  • Pokemon_CenterVisit.h: UNKNOWN passes both guards (the test "unknown" case covers this). A one-line note on enter_center/leave_center saying so would help the follow-up authors.

Checked and fine: calling run_settle twice with since and then when is safe because TalkOver::look only sets m_quiet_since/m_calm_since when they're unset. The deadline is taken from the first look. The switch statements over SettleKind/CenterPlace return after the switch (no -Wswitch hole). Adding PLAYER_STILL as the last ScreenEvent keeps the static_assert and the name table in step, and no other switch over ScreenEvent exists. Tests follow name/input/expectation. SourceFiles.cmake and the test registration are complete.

Verdict

NEEDS_REWORK

…eup without a fade settles AFTER_WARP

CenterVisitIO::settle returns SettleEnd, and enter_center/leave_center fail
with its text on TIMED_OUT or BATTLE. line_up_and_walk_in returns WarpSeen;
with no fade seen the settle into the Center is AFTER_WARP, as on the way out.
Header notes that UNKNOWN passes both checks.
…e press

A dropped title press on an idle title, followed by the attract movie's
black, set the load seen and let the movie settle as the overworld.
StoryLaunchPolicy::load_black_looks bounds how many looks after the title
press the load's black may come.
@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 2 commits on top, tip 6ed6e05:

  1. CenterVisitIO::settle returns SettleEnd; a TIMED_OUT or BATTLE end fails enter_center/leave_center as heal_enter/heal_exit with the end's text. New CenterVisit cases for a timeout on each door.
  2. Description: new StoryLaunch bullet (03:42, 04:21) and the suite listed under Testing.
  3. line_up_and_walk_in() returns WarpSeen; with no fade seen the settle is AFTER_WARP. New case.
  4. The code did allow it: once m_title_pressed was set, any later black counted. A real load's black follows the press at once, while the movie needs the title left idle (a re-read title is pressed again, and the presses are capped), so the black now counts only within StoryLaunchPolicy::load_black_looks (default 10) looks of the title press. Red case: TITLE, three unread title looks, BLACK, OVERWORLD(movie) now takes the movie press instead of settling.
    Nits: const Outcome in; header notes UNKNOWN passes both checks.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed SHA: 6ed6e05

Scope: the two commits since my last review (c0265f0, 6ed6e05), checked against each item in #546 (review). CI is green at this SHA. Code health shows 0 failures (advisories only), and CRLF endings are kept.

Prior items

  1. Settle result reaches the Outcome: resolved. CenterVisitIO::settle now returns SettleEnd. settle_door() turns any end other than QUIET into outcome_failed(CENTER_NOT_ENTERED / CENTER_NOT_LEFT, end.text), and it does this before place() is read. The header states the contract. New cases cover a timeout on each door, and the expected call lists stop at the settle as they should.
  2. PR description: resolved. There is now a StoryLaunch bullet covering 03:42 and 04:21, and the Testing section lists the six StoryLaunch cases.
  3. Lineup without a fade: resolved. line_up_and_walk_in() returns WarpSeen. A lineup that saw nothing settles AFTER_WARP, and the "no fade, but inside" branch keeps DOOR. The how log line now includes what the lineup saw. The new case expects settle_warp.
  4. Dropped title press, then a black: resolved. The author's reply confirms the old code allowed this. A real load's black follows the press right away, so the fix counts a black only within load_black_looks looks of the press. A re-read title resets the counter to 0 and clears m_load_seen. A press on the movie does not reset it, which is correct. The red case (TITLE, 3x TITLE_UNREAD, BLACK, OVERWORLD with load_black_looks = 3) traces to stuck on title with the inputs listed. I also checked the 04:21 path: a movie press within the window goes back to the title through a black, and that title clears m_load_seen, so this doesn't regress.
  • Nits: const Outcome in is done. The header notes that UNKNOWN passes both checks.

Nits (non-blocking)

  • Pokemon_CenterVisit.cpp: settle_door() also runs the AFTER_WARP settle. A name like settle_after_door would describe both uses.
  • Pokemon_StoryLaunch.h load_black_looks: the window counts looks, not time. A look's length depends on what it pressed (poll vs a press's release). At the default of 10, that is about 5 s at poll. Adding that figure to the comment would help whoever tunes it for another game.

Verdict

APPROVED

@dayfine
dayfine marked this pull request as ready for review November 15, 2026 17:58
@dayfine
dayfine merged commit 2b4f6c1 into nav/shared Nov 15, 2026
16 checks 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.

1 participant