Skip to content

PokemonLZA AutoStory: the scene machine - #560

Draft
dayfine wants to merge 6 commits into
plza/upstream/p2-02from
plza/upstream/p2-03
Draft

dayfine wants to merge 6 commits into
plza/upstream/p2-02from
plza/upstream/p2-03

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #559

Adds the scene machine: the loop that presses through a story scene (text, choices, cards, fades, banners) until the player has control again, deciding on each look from the screen events, with a quiet time and a timeout that fail the step. The story game in #568 runs every scene step through it. Its tests, PokemonLZA::AutoStorySceneMachine, run it on event sequences against the built-in checkpoints and so come with the story game in #568.

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

API review (claude-sonnet-5-5) at 5682449: LGTM_with_nits

No correctness bugs found in the scene machine logic. The findings are design and readability: failure kinds recovered by parsing message text, parallel per-screen tables, an unexplained magic-number cluster, and a repetitive describe_look. There are also a few include and comment nits. The machine's tests only arrive in #568, so none of this is exercised in this PR.

  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:440 scene_failure() recovers the failure kind (timeout, unknown, stuck) by matching the prefix of the ScreenMachine's English failure text ("Did not finish", "The screen matches none"). Any rewording in CommonTools/ScreenMachine silently turns timeouts and unknown screens into "scene_stuck". This is a stringly-typed sentinel. Fix: Add a failure-kind enum to ScreenMachineResult (TIMEOUT, NO_MATCH, TOO_MANY_VISITS, STILL) set where the failure is produced, and switch on that here.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:80 Each SceneScreen is described in five parallel places: the enum, ALL_SCREENS, scene_screen_name(), scene_screen_terminal(), and max_visits()/max_still(). Adding a state means editing all of them, and a missed one compiles fine (the default: branches and ALL_SCREENS hide it). The header also says the enum is "in the order it tries them", but classify() decides the state, not ALL_SCREENS order. Fix: Use one constexpr table of rows {screen, name, terminal, max_visits, max_still} and build the ScreenStates from it. Drop the misleading order claim from the comment.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:330 Unexplained literals: the press timing 160ms, 240ms is repeated at four call sites in act() and press_banner_away(). The max_visits values 400 and 30 and the wait 2 * POLL have no stated reason. Fix: Add named constants such as A_PRESS_HOLD/A_PRESS_RELEASE and MAX_DIALOG_VISITS/MAX_CHOICE_VISITS, each with a why-comment (for example how many lines the longest talk has). Name the default wait too.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:275 describe_look() joins names with two spellings: std::format with a separator for the event table, then six copy-pasted text += text.empty() ? "x" : ", x" lines for the rest. Both the logic and the data are repeated. Fix: Put all names in one table of {label, predicate} (or a small append(text, name) helper) and loop over it, so there is a single join.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:245 track_since() mutates a non-const std::optional<WallClock>& output parameter, so the mutation is not obvious at the call sites in record(). Fix: Return the new value: m_party_bar_since = track_since(shows, when, m_party_bar_since);. Alternatively make it a small Since type with an update(bool, WallClock) method.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:48 A stray //, where comment line starts with a comma after a line wrap. The banner and fade comments also cite individual lab observations ("02.07 holds a ~25 s black", "01.03's MAIN MISSION 02 stayed past 10 s, where MAIN MISSION 01 went in ~3 s") instead of saying why the value was chosen. Fix: Rejoin the sentence and describe the game behavior ("the banner shows ~3 s, sometimes longer"). Keep scene IDs and run notes in the commit message.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.cpp:9 <map> is unused. std::function and std::pair/std::move are used without including <functional> and <utility>, and rely on transitive includes. Fix: Remove <map>. Add <functional> and <utility>.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine.h:140 The comments repeat constants as literals ("every 2 s", "up to 10 s", "3 times 1 s apart", "5 s") that live in the .cpp as BLIND_PRESS_EVERY, BANNER_GONE_WAIT, BANNER_PRESSES and AUTOSAVE_QUIET. They will drift when a constant changes. Fix: Refer to the behavior without the numbers, or point to the named constants.

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