Skip to content

BDSP Starter RNG: port #1366 and make the attempt loop callable - #438

Open
dayfine wants to merge 37 commits into
bdsp/autostory-v4from
bdsp/starter-rng-callable
Open

dayfine wants to merge 37 commits into
bdsp/autostory-v4from
bdsp/starter-rng-callable

Conversation

@dayfine

@dayfine dayfine commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Base: bdsp/autostory-v4 (#128)

Ports the BDSP Starter RNG program from upstream PR PokemonAutomation/Arduino-Source#1366 by @theastrogoth (the port tracks an earlier snapshot than that PR's current head 464ea9ba4: no bedroom fast-skip, blink-UI polling tweaks or recovery timeout yet) and extracts its reset/attempt loop into a helper that both the standalone StarterRng and BDSPAutoStory can call.

Changes

  1. Port of BDSP starter RNG manipulation PokemonAutomation/Arduino-Source#1366 (03bc3d446):
    • PokemonBDSP/Options/PokemonBDSP_RngFilter.{h,cpp} and PokemonBDSP/Programs/RngManipulation/PokemonBDSP_{RngAim,RngCalibration,RngExecution,RngTargets,RngTimeline,StarterNavigation,StarterRng,SummaryNavigation,TargetSelection}.{h,cpp}, on top of the merged Pokemon_BdspRng, PokemonBDSP_AdvanceClock, PokemonBDSP_BlinkScenes and PokemonBDSP_BlinkRecovery.
    • StarterRng_Descriptor registered in PokemonBDSP_Panels.cpp.
  2. Callable attempt loop (874c46143):
    • PokemonBDSP_StarterRngAttempts.{h,cpp}: StarterRngSettings (what the caller wants), StarterRngAttemptIO (displays, notifications, stats, callbacks), StarterRngRunResult and StarterRngOutcome (the loop's result), BdspStarterAttemptResult (one attempt), resolve_starter_rng_step() and run_starter_rng_attempts().
    • close_starter_summary() in PokemonBDSP_SummaryNavigation.{h,cpp}: presses B (up to 6 times, waiting for the X menu after each) and then X, to leave the Summary page on the overworld.
    • StarterRng::program() is now a thin wrapper around run_starter_rng_attempts().
  3. Review fix: set_default_shiny_row() (RngFilter) seeds the filter table with a shiny of any nature; the standalone program uses it, and a caller whose table is empty can seed the same row.

Testing

  • PokemonBDSP::StarterRng suites: per-starter tables and timings, bedroom skip buffer and landing math, aim offset and calibration bias, attempt loop outcome resolution, default filter row is shiny of any nature.
  • close_starter_summary() and the loop have not been run on a console in this PR.

dayfine and others added 12 commits November 12, 2026 10:50
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.
…ment, README counts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Port the remaining Starter RNG files from PokemonAutomation#1366 (by theastrogoth) onto the merged BDSP RNG infrastructure:
- BdspRngFilterRow / BdspRngFilterTable / BdspRngFilterSnapshot
- RngAim, RngCalibration, RngExecution, RngTargets, RngTimeline, TargetSelection
- StarterNavigation, SummaryNavigation, StarterRng

Adapt to the upstreamed BlinkRecovery, BlinkScenes, AdvanceClock, and SingleSwitchProgramDescriptor APIs, and register StarterRng in PokemonBDSP_Panels.
The README's prepare_parity.py command had no --publisher-revision, and the
script's default pin was older than the workflow's, so following the README
on the pinned checkout failed. The default now matches the workflow pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Extract the Starter RNG attempt and reset loop out of StarterRng::program() into PokemonBDSP_StarterRngAttempts (run_starter_rng_attempts / run_starter_rng_attempt / resolve_starter_rng_step), parameterized by StarterRngSettings and StarterRngAttemptIO and returning StarterRngRunResult. Add finish_battle_on_shiny and close_summary_after_read options (with close_starter_summary in SummaryNavigation) so AutoStory can continue directly from Lake Verity or Verity Lakefront, and add unit tests for per-starter tables, bedroom skip buffer/landing math, aim calibration, and attempt loop outcome transitions.
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: 651fbca

Verdict

APPROVED (LGTM_with_nits)

Base is bdsp/autostory-v4; independent of #437. The branch is three commits: the port (03bc3d446), the callable loop (874c46143) and a base merge. I compared against upstream PokemonAutomation#1366 head 464ea9ba4 (draft, read-only fetch).

Port faithfulness

  • Byte-identical to upstream after CRLF normalisation: RngAim, RngCalibration, RngExecution, RngTargets, TargetSelection, SummaryNavigation, RngFilter.h.
  • Reformatted only: RngFilter.cpp, where one-line if (...) return is braced per AGENTS.md.
  • Adapted: StarterRng.cpp gets PanelQualityStanding::OFFICIAL_BETA in the descriptor, the Descriptor alias, and the BlinkScenes.h include, to fit the merged APIs. The upstream RECOVERY_TIMEOUT_SECONDS and shared_ptr eye templates are dropped, and AdvanceClock moved to the existing header.
  • The port is of an earlier snapshot, not 464ea9ba4. Upstream has since added the bedroom fast-skip path, blink-UI polling tweaks and the recovery timeout. Say in the description which upstream commit the port tracks.
  • OFFICIAL_BETA is a promotion upstream has not made for a still-draft program. Use the same standing as the other BDSP RNG panels, or name it in the description.

Refactor behaviour (original run_attempt + program loop vs run_starter_rng_attempt(s)). Preserved for the standalone path (reset_first=false, finish_battle_on_shiny=false, close_summary_after_read=false):

  • Outcomes, stats increments (shiny does not count as a hit; the "passes the filter anyway" case counts a miss then Hit), the reset/go_home sequence, and "Unverifiable continues the loop" are the same.
  • The reset-limit exit is the same, with a new OUT_OF_RESETS result.
  • Behaviour that differs: FILTERS.make_snapshot() is now taken once per run, not once per attempt and once per bedroom skip. The table is UNLOCK_WHILE_RUNNING, so edits made while running used to apply to the next attempt and now do not. Keep per-attempt snapshots, or lock the table while running.
  • Behaviour that differs: the wanted predicate has three fallbacks (settings.wanted, then filters, then "any shiny"). The last is a silent default that matches nothing the caller configured. Require one of the first two.

Findings

  1. (medium) run_starter_rng_attempt is 372 lines (limit 50; the original was already long). It is the refactor's seam, so it should be split at the points the code already marks: bedroom skip, lake blink recovery, target selection, execute, verify. Code Health reports it as a blocking failure.
  2. (medium) The tests only cover the pure resolve_starter_rng_step. Nothing exercises the loop (reset limit, abandoned attempt, hit mid-run). A fake attempt callable would make this testable; as written, "behaviour-preserving" is argued, not tested.
  3. (medium) close_starter_summary is new, has no test, and the PR says nothing about trying it on the console. It presses B up to 6 times, waiting for MenuWatcher after each press, so a Party screen could be mistaken for the X menu. It then presses X and does not confirm the overworld. #439 depends on this ending on the Lakefront overworld. Its doc comment says "B, B, X" in one place and 3rd page, party, X menu in another.
  4. (low) The PR description names StarterRngAttemptSpec, StarterRngAttemptOutcome, StarterRngAttemptResult, StarterRngAttemptCallbacks and resolve_starter_rng_attempt_outcome(). The code has StarterRngSettings, StarterRngAttemptIO, StarterRngRunResult, BdspStarterAttemptResult and resolve_starter_rng_step(). Update the description.
  5. (low) StarterRngAttemptIO has five std::function callbacks (on_reset, on_miss, on_hit, on_shiny, on_error). Only on_reset is used by the caller in #439. Remove the others until needed. Raw nullable pointers plus the three fallback displays built per attempt would be simpler as references.
  6. (low) Two result structs (BdspStarterAttemptResult, StarterRngRunResult) and two outcome enums with near-identical names. The StarterRngSettings doc comment describes AutoStory behaviour inside a header the standalone program owns.
  7. (Code Health, advisory on fork PRs, 167 findings) Mostly the ported files: missing // namespace X closers and undocumented header symbols. Upstream's style differs, so decide whether to fix them here or leave the port verbatim and say so.

No Qt, std::thread, mutex or std::filesystem in the new code. Tests are registered in PokemonBDSP_Tests.cpp and the new files are in SourceFiles.cmake.

dayfine and others added 12 commits November 12, 2026 17:42
…n failure, unsettled shiny stops, program split
…and shiny settle, constants in StoryTable.cpp)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine

dayfine commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Review fixes pushed (tip b0bb884): Starter RNG default filter row (shiny, any nature) moved into set_default_shiny_row and tested, so an empty table cannot loop forever; PR description names fixed.

dayfine and others added 2 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
dayfine and others added 10 commits November 12, 2026 18:50
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
Folded leaf PR #445; tree equals the leaf tip.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Folded leaf PR #439; tree equals the leaf tip.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…ay and notification text

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
…de; its stop reports through the shared report

StoryHandoffs held two bools whose combination the plan decoded;
it holds the mode of the options now, as FRLG's program derives it.
The stop's log line, overlay line and notification text come from
Pokemon::report_rng_handoff_stop.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
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