Skip to content

BDSP AutoStory: run Starter RNG in 00.02 (option, off by default) - #439

Merged
dayfine merged 20 commits into
bdsp/starter-rng-callablefrom
bdsp/autostory-starter-rng
Nov 13, 2026
Merged

dayfine merged 20 commits into
bdsp/starter-rng-callablefrom
bdsp/autostory-starter-rng

Conversation

@dayfine

@dayfine dayfine commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Base: bdsp/starter-rng-callable (#438) (also merges bdsp/autostory-starter-rng-handoff #437)

Integrates the BDSP Starter RNG attempt loop (run_starter_rng_attempts() from #438, ported from PokemonAutomation/Arduino-Source#1366) directly into BDSP AutoStory checkpoint 00.02 (Lake Verity) as an opt-in option (RUN_STARTER_RNG, off by default).

How it fits into 00.02 (Lake Verity)

  • 00.02 starts at VerityLakefront (17, 14) facing north and saves at its start (saves_in = true, SAVE_AT_START).
  • When RUN_STARTER_RNG is enabled on a run covering 00.02:
    • plan_story_run() replaces 00.02's post-save steps (enter_lake_verity, starly_ambush, pick_starter, starly_battle, after_starly, leave_lake_verity) with a single starter_rng game action while keeping 00.02's start save at VerityLakefront (17, 14) intact.
    • If STOP_FOR_STARTER_RNG is also checked, RUN_STARTER_RNG takes precedence and continues past 00.01 into 00.02.
    • starter_rng invokes run_starter_rng_attempts() with:
      • start_point = StartPoint::LAKEFRONT
      • starter = bdsp_starter_for_choice(STARTER.current_value()) (Turtwig / Chimchar / Piplup)
      • player_model = 1 (matching 00.00's default cursor selection in play_new_game_intro())
      • finish_battle_on_shiny = true and close_summary_after_read = true
    • On either a filter HIT (after read_observed_pokemon() + close_starter_summary()) or a SHINY in battle (after clear_starter_battle() + open_menu() + closing the X menu), the player is left on the VerityLakefront (17, 14..15) overworld with the menu closed—matching the end of 00.02 so 00.03 (Lake -> Sandgem -> Mom) continues seamlessly.

Changes

  • PokemonBDSP_AutoStory.{h,cpp}:
    • Added RUN_STARTER_RNG (default false), STARTER_RNG_MAX_RESETS (default 20), STARTER_RNG_FILTERS (BdspRngFilterTable), NOTIFICATION_SHINY, and bdsp_starter_for_choice(StarterChoice).
  • PokemonBDSP_AutoStory_StoryTable.{h,cpp}:
    • Added STARTER_RNG_CHECKPOINT_ROW = "00.02", STARTER_RNG_ACTION = "starter_rng", and StoryHandoffs::run_starter_rng handling in plan_story_run().
  • PokemonBDSP_AutoStory_StoryExecutor.h & PokemonBDSP_AutoStory_Events_Lake.cpp:
    • Added StoryEnv::run_starter_rng callback and registered the "starter_rng" game action.
  • PokemonBDSP_StarterRngAttempts.cpp:
    • When finish_battle_on_shiny && close_summary_after_read, advances through the after_starly Lake Verity cutscene via open_menu() and closes the menu so shiny hits also end on VerityLakefront (17, 14..15).
  • PokemonBDSP_AutoStory_StoryTable_Tests.cpp & PokemonBDSP_AutoStory_StorySimulation_Tests.cpp:
    • Added unit and simulation tests for run_starter_rng step replacement, precedence over stop_for_starter_rng, and end-to-end simulation across 00.01 -> 00.03.

Tests

  • PokemonBDSP::StarterRng - aim offset and calibration bias
  • PokemonBDSP::StarterRng - bedroom skip buffer and landing math
  • PokemonBDSP::StarterRng - per-starter tables and timings
  • PokemonBDSP::StarterRng - attempt loop outcome resolution
  • PokemonBDSP::AutoStory - Story table: rows lint, variants known
  • PokemonBDSP::AutoStory - Story table: each row starts where the last one ends
  • PokemonBDSP::AutoStory - Starter RNG handoff: stops after 00.01 saved at the Verity Lakefront
  • PokemonBDSP::AutoStory - Simulation: start and end checkpoints

Adds a "Stop for Starter RNG" option (off by default) to BDSPAutoStory. When on, plan_story_run() stops after 00.01 saves at the Verity Lakefront (17, 14) facing north, where 00.02 and Starter RNG (PokemonAutomation#1366, Start point: Verity Lakefront) start. With it off, the table and run are unchanged.
Adds "Run Starter RNG in AutoStory" (off by default), "Starter RNG Maximum Resets", and "Starter RNG Stop Conditions" to BDSPAutoStory. When enabled, plan_story_run() replaces 00.02's Lake Verity steps (after 00.02's Verity Lakefront start save) with the starter_rng game action, which runs run_starter_rng_attempts() from VerityLakefront (17, 14) through the Starly battle and Rowan's scene, closes the menu on VerityLakefront (17, 14..15), and continues into 00.03.
…-rng-callable' into bdsp/autostory-starter-rng

@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: b6ec3bc

Verdict

NEEDS_REWORK (changes_needed)

Stack. Base is bdsp/starter-rng-callable (#438). The head also merges bdsp/autostory-starter-rng-handoff (#437), so the PR's diff (35 files) contains all of #437 and #438's content until they merge. I reviewed only what this branch adds on top of #437 and #438: the Lake events, AutoStory.{h,cpp}, StoryTable and its tests.

Off by default leaves the story unchanged. With both options false, plan_story_run() copies the rows unchanged, story.run_starter_rng is unset, and the program path is the same as #437's. Two side effects remain. NOTIFICATION_SHINY is added to NOTIFICATIONS unconditionally, which changes the user's notification settings and saved config even with the option off. STARTER_RNG_FILTERS.make_snapshot() runs on every run. Register the notification and take the snapshot only when RUN_STARTER_RNG is on, or note it in the description.

Blocking

  1. (high) STARTER_RNG_FILTERS has no default row. The standalone program seeds a "Shiny" row in its constructor; here the table is empty. BdspRngFilterSnapshot::get_action returns Discard for an empty table, so starter_wanted never matches, select_target finds nothing, every attempt is Abandoned, and with STARTER_RNG_MAX_RESETS = 0 (the default, "no limit") the program resets forever. Seed the same default row as the standalone, and refuse an empty table with a UserSetupError.
  2. (high) The shiny path leaves the game in the wrong place. finish_battle_on_shiny ends at "the start of the post-battle Lake Verity cutscene ... ready for AutoStory's after_starly step" (the header comment in #438's StarterRngAttempts.h). But with_starter_rng_step replaces all of 00.02's steps, including after_starly, with one starter_rng step whose pose_after is declared as Lakefront (17, 14..15). On a shiny hit, 00.03 therefore starts mid-cutscene, with a pose the story believes is already on the overworld. The non-shiny hit goes through open_menu and close_starter_summary, so it passes. Run the cutscene (keep after_starly) after a shiny, or make the shiny path wait for the overworld the way the non-shiny path does. A sim test covering the shiny path is also missing: Simulation only runs the starter_rng event as a stub.
  3. (high) settings.player_model = 1 is hard-coded. The standalone program has a PLAYER_MODEL option, and the lake and bedroom eye templates are chosen by model (lake_templates/model<N>.png). If the story's character is any other model, the blink watcher never finds the player and every attempt abandons at "never reached the lake blink position". Take the model from the story's character (or from an option), and say which model the new-game intro creates.

Other findings
4. (medium) The option interaction is undocumented. run_starter_rng silently overrides STOP_FOR_STARTER_RNG (&& !handoffs.run_starter_rng). Say so in both option labels, or reject setting both.
5. (medium) A failed Starter RNG returns outcome_failed("starter_rng_failed") from a 00.02 step. 00.02 is reload_and_retry, so the story's retry loop reloads the 00.02 save and reruns the whole Starter RNG up to the attempt limit, on top of the inner reset loop. starter_rng_aim (calibration) is kept across those retries, which is good, but resets_logged restarts at 1 on each. State this in the description or make the step fatal.
6. (medium) The AutoStory loop differs from the standalone program's: it passes ConsoleSettings::TOLERATE_SYSTEM_UPDATE_MENU_FAST through run_starter_rng_attempts's reset, while the story's own reload uses reset_game_from_home(..., true, 1000ms). Use one reset.
7. (low) BDSPAutoStory::program is 90 lines and the constructor 68 (limit 50, Code Health blocking). Move the run_starter_rng lambda into a named function (for example make_starter_rng_hook(...)) that returns the std::function. bdsp_starter_for_choice has an unreachable return after an exhaustive switch.
8. (low) starter_rng in Events_Lake.cpp takes the output parameter StoryExecutor& first (Code Health advisory); that is the signature all events share, so ignore this.
9. (low) StoryTable.h now has 9 namespace-scope symbols (limit 8) and two undocumented ones. Move the new row/action constants into the .cpp or a StoryHandoff.h.
10. (nit) Tests build messages with + instead of std::format.

No Qt, std::thread, mutex or std::filesystem in the new code; the listener is removed in the destructor.

Not verified: the console behaviour of close_starter_summary and the Starly battle after an RNG starter. A console run (hit and shiny) is needed before this merges.

@dayfine

dayfine commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Review fixes pushed: default shiny row seeded in the story options; player model comes from a story option; shiny notification only when its option is on; Run option takes precedence over Stop option explicitly (Stop is disabled while Run is on); Starter RNG failure is fatal for 00.02 (no row reload-retry on top of the reset loop); a failed post-shiny settle now stops instead of being swallowed; program()/constructor split; #437 and #438 merged in. Not changed: single reset path, shiny notification registration caveat. Red-first runs were not executed; tests added for each fix.

dayfine and others added 5 commits November 12, 2026 18:40
Pokemon_StoryRngHandoff.h holds what every game's RNG handoff shares: the
OFF/STOP/RUN mode, the result an RNG program's call ends in, and
run_rng_handoff(), which logs a success and throws on a failure so no row
retry reruns the reset loop. BDSP's Starter RNG hook now runs through it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Moved unchanged from bdsp/autostory-starter-rng (7a46b79), so that BDSP and FRLG
both build on it from the shared base.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
FRLG's loop also ends where the user takes over (target hit but not shiny,
attempts spent); that is a stop with a message, not an error. A shiny is a
continuation whose rows the game builds, so the seam carries no rows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine merged commit 9d96ad0 into bdsp/starter-rng-callable Nov 13, 2026
12 of 17 checks passed
@dayfine
dayfine deleted the bdsp/autostory-starter-rng branch November 13, 2026 03:30
@dayfine

dayfine commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Folded into #438 (merge 9d96ad0).

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