Skip to content

BDSP AutoStory v4: game actions, battles and their detectors - #148

Draft
dayfine wants to merge 95 commits into
bdsp/detectors-v4from
bdsp/actions-v4
Draft

dayfine wants to merge 95 commits into
bdsp/detectors-v4from
bdsp/actions-v4

Conversation

@dayfine

@dayfine dayfine commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Depends on #152 (base bdsp/detectors-v4); the diff shows only this PR's change.

The game actions the BDSP story steps use, as their own files with the detectors they read, kept to what the story needs.

  • Saving, the X menu (found by its bottom bar, past NEW tags), the Bag and Potions (Bag rows are read with a dictionary of the story's items in all nine game languages, matched by slug), the Pokemon Center (heals from inside the door; talk_to_nurse()), trainer and wild battles (running uses a menu check that holds for any party), the Options check, and the system keyboard.
  • The new game's intro: refuses to start from HOME, checks the game is BDSP, waits out the black boot, confirms the rival's name, reads arrowless dialogue, and ends only on the X menu; the player is "Kosmos" by default for lab runs.
  • About 1,200 lines are adapted from [WIP] BDSP Autostory PokemonAutomation/Arduino-Source#1717 by Developer-Butters and credited in each file.

Testing

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

dayfine and others added 4 commits November 1, 2026 13:59
What the BDSP story table's steps do in the game, without the story
itself: saving and the X menu (Actions), the Bag and Potions (Bag), the
Pokemon Center by its lit doorway (Center), trainer battles with the best
move (Battle), the Starly battle, catching and running from wild battles
(WildBattle), the Options the story needs (Settings), and a new game's
intro to the bedroom (NewGame), with the detectors they read: the battle
menu and move cursor, the X menu's cursor, the name list and the
Switch's keyboard.

Tests: the intro's decisions, and the lit doorway, Pokemon Center,
save card and School lamp screenshots.

Adapted in part from PokemonAutomation#1717 by Developer-Butters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…enu and X menu readers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…on#1717 in the X menu reader

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 8 commits November 1, 2026 14:46
The repo's control-flow formatting throughout; long functions split into
helpers that run the same statements in the same order; the move reading
moved to BattleMoves. Battle drops the parameters and branches no caller
used (a confirmed default target, move lists, no post-battle cleanup):
every battle takes the best move each turn, and fight_story_battle()
takes BattleFormat instead of a bool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
… BDSP, read arrowless dialogue

r1 (2026-11-01) started with no game running: closing it failed, HOME was
pressed again, its cursor moved to the first tile, and FireRed was
launched and played for 30 s. The intro now refuses to start with HOME in
front, and before a screen only BDSP shows (its dialogue box, the rival's
name list, its menu) presses A on unknown screens at most 20 times, then
fails as another game.

r2 stopped on Rowan's last line: a dialogue box without the "more" arrow,
which ShortDialogDetector needs, read as "other", and the background's
sparkles read as X changing the screen. The intro now reads such a box as
dialogue, and the probe compares only the box's area.

Tests: the intro's decisions with the new gate; the intro screens from
CommandLineTests (PokemonBDSP/AutoStory/IntroScreens), skipped without them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…t line, which a long line reaches

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
… then X; only the menu ends the intro

Screens the classifier misses no longer stop the intro: once the rival is
named, each unknown screen takes B (up to INTRO_B_BEFORE_X), then X checks
for the menu, up to INTRO_X_WITHOUT_MENU times. Dialogue takes B too. The
before/after comparison of the X probe is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…nctions and story_language()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…or the wrong-game guard

r3 spent the guard's 20 presses on BDSP's black boot (about 25 s after the
restart) and stopped. Now the intro waits for a screen that is not black
before it starts (up to INTRO_BOOT_LIMIT), black screens are their own
class that takes no press, and the guard counts INTRO_TIME_BEFORE_BDSP
from the first screen that is not black instead of presses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
r4 picked Barry, then B answered "Barry, is it?"'s Yes/No as No and the
list came back until the state machine's visit limit. Picking a preset now
leaves the name pending: dialog and unknown screens take A (Yes) until
INTRO_SCREENS_AFTER_RIVAL_PICK of them pass without the list, and the list
coming back is picked from again (up to 6 visits).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine dayfine added autostory AutoStory programs detector Screen detectors and readers game:bdsp Brilliant Diamond/Shining Pearl labels Nov 1, 2026
dayfine and others added 5 commits November 1, 2026 15:18
…X opening something from a still bedroom

r5 reached the bedroom, but a new game's X menu (BAG and OPTIONS with a NEW
tag) is not the full menu MenuDetector wants, and the intro pressed X
twelve times. XMenuDetector also takes the blue bar along the bottom, there
from the first menu on, for the intro and the Options steps. And when X
opens something no detector knows from a screen that held still, and B
puts it back, the player is in control too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…to bdsp/actions-v4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…elow a long first line; their screenshots in CommandLineTests

The intro's misses were the detectors' (r2, r5), so they are fixed there:
MenuDetector also looks at its white columns from below the "NEW" tags (a
new game's OPTIONS has one beside the third column), and
ShortDialogDetector takes the box's right end below the first line when a
long first line covers it. The AutoStory-only XMenuDetector and the
intro's own dialogue check go; the screenshots are registered per file
from CommandLineTests' PokemonBDSP/MenuDetector and DialogDetector, and
the AutoStory folder readers for them are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The MenuDetector and ShortDialogDetector changes now come from their own
PR; this PR keeps only the AutoStory side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine
dayfine changed the base branch from bdsp/walk-v4 to bdsp/detectors-v4 November 2, 2026 00:08
dayfine and others added 3 commits November 1, 2026 16:26
… NEW tags

A new game's main menu has a "NEW" tag above OPTIONS that breaks the top
of the third white column. MenuDetector already handles that with
skip_new_banner = true, so every menu check in the intro and the settings
checkpoint passes it, instead of MenuDetector itself changing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
MenuDetector keeps its old check (review on #152); the callers here pass
skip_new_banner instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 14 commits November 9, 2026 02:25
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

# Conflicts:
#	SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp
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_01AKYzhrMnPK61XHWEch4a6E
…code

Moves only, no logic change. NewGame.h keeps the intro's entry points;
its step decisions go to IntroSteps.h and the X/B control probe to
IntroProbe.h. Center.h keeps healing and going in; the lit doorway and
lamp reads go to LitDoorway.h. Bag.h keeps the item search; the pocket
and cursor reads go to BagScreen.h. String tables hold std::string, and
the system keyboard finds keys with std::string::find. The intro's
run_screen_machine() call takes the trace last, as the merged core does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
@dayfine
dayfine removed this pull request from stack #230 November 11, 2026 03:20
dayfine and others added 7 commits November 11, 2026 07:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
ScreenState gained matches_observation after matches; the intro's
positional initializers put act() there and no longer compiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
The Bag search read the cursor row with raw English Tesseract and compared
lowercased letters to "potion", so it failed on non-English games and on any
misread. Read the row with a SmallDictionaryMatcher over the story's items
(Potion, Antidote, Paralyze Heal, Awakening, Poke Ball, Repel, Super/Max
Repel, Escape Rope) in all nine game languages, using the story language,
and match by slug. The dictionary is in the *OCR.json form so it can move to
Packages later.

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
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
dayfine added a commit that referenced this pull request Nov 12, 2026
Brings in #148's bag item reader. Conflict in SourceFiles.cmake: kept this branch's list and added PokemonBDSP_AutoStory_BagItemReader.{cpp,h}.

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_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autostory AutoStory programs detector Screen detectors and readers game:bdsp Brilliant Diamond/Shining Pearl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant