Skip to content

BBQ: check Central Plaza arrivals; a failed quest fly fails the attempt, not the program - #24

Closed
dayfine wants to merge 6 commits into
mainfrom
bbq/plaza-arrival-check
Closed

dayfine wants to merge 6 commits into
mainfrom
bbq/plaza-arrival-check

Conversation

@dayfine

@dayfine dayfine commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Depends on: nothing. Base main; the diff shows only this change. Independent of fork PR #20 (fly from anywhere), which reads the map's fly-point label; this PR reads the landing banner instead.

Part of PokemonAutomation/ComputerControl#263.

Problem

return_to_plaza() flies to the closest Pokecenter on the map, and when that fails the search falls back to zooming out and flying to the closest fly point, whatever it is. Nothing checked where the player landed. Every central_to_*() after that moves the map cursor by a fixed offset from Central Plaza, so it lands in empty space.

Lab run R3 (2026-10-22 08:17–08:25): Auto Battle's return found the Pokecenter icon 130 px off, got no "Fly" menu item, fell back, and landed near Chargestone. The next central_to_chargestone() timed out 3 × 2 min, and "Unable to fly to Chargestone Cavern!" ended the program.

Change

(a) Check the arrival. After landing, return_to_plaza() OCRs the place-name banner the game shows near the top of the screen ("Central Plaza" / 中心廣場), for up to 8 s. If the banner doesn't show Central Plaza, it returns again with the cursor overshoot it already used after a failed fly, up to 3 landings, and then throws. If the language has no known name (only English and Chinese (Traditional) are known so far) or has no OCR data, the check is skipped and a log line says so.

  • PlaceNameBannerReader (new): white-text OCR of the banner area, at two brightness thresholds.
  • PokemonSV_TerariumPlazaReturn (new): the pure parts, central_plaza_banner_to_check() and place_name_banner_matches(), plus the return-and-check loop return_to_plaza_checked(). The loop runs the game steps through PlazaReturnActions; Terarium.cpp has the console implementation.
  • return_to_plaza() now takes the game language. All BBQ callers pass BBQ_OPTIONS.LANGUAGE, so quest_wash_pokemon() now takes the BBQ options too.

(b) A failed quest fly fails the attempt, not the program. map_move_cursor_fly() throws TerariumFlyFailedException, a subclass of OperationFailedExceptionWithScreenshot, after its 3 tries. process_and_do_quest() catches only that type: it returns to Central Plaza (with the check), and then the existing board check counts the attempt as failed. NUM_RETRIES and the skip policy apply as before. Nothing else is caught: a shiny ProgramFinishedException, UserSetupError, and other operation failures still end the program. If the return itself fails its check 3 times, that error is fatal.

How to review

  1. PokemonSV_TerariumPlazaReturn.h/.cpp: the decisions and the loop.
  2. PokemonSV_Terarium.cpp: the old return_to_plaza() body is unchanged, renamed fly_toward_plaza() with laggy as a parameter. After it come the console actions and the new return_to_plaza(). The map_move_cursor_fly() throw changed type.
  3. PokemonSV_BlueberryQuests.cpp: in process_and_do_quest(), the quest switch is only re-indented into the try. Use GitHub's "Hide whitespace" (?w=1) to see that about 100 lines are unchanged. The other edits there and in BlueberryCatchPhoto.cpp only pass the language.
  4. PlaceNameBannerReader, then the tests.

Without whitespace changes, the diff is +674 / −20.

Tests

  • 31 native unit tests in PokemonSV_Tests.cpp (data-driven, designated initializers), all passing locally:
    • BBQPlazaBannerToCheck (5): names by language; no OCR data; unknown language.
    • BBQPlazaBannerMatch (21): exact names, spacing, noise, one or two misread characters, each other plaza (Chinese and English), and empty or punctuation-only reads.
    • BBQPlazaReturn (5, scripted fake): arrives first time; lands elsewhere, then arrives with the overshoot; banner missed; never arrives (fails after 3); nothing to check (no banner read).
  • The reader was run locally on two lab screenshots of landing at Central Plaza (Chinese (Traditional), different lighting). Both thresholds read 中心廣場 exactly. A Chargestone-area error screenshot read nothing. These images are not committed.
  • Not yet run live.

Live check needed

  • Each Central Plaza return logs landed at Central Plaza (banner "中心廣場"). It must never retry when the player is really at the plaza: a false retry costs about 30 s, and three in a row end the program.
  • A wrong landing is detected and fixed by the retry.
  • A quest fly failure logs Quest attempt failed: unable to fly, returns to the plaza, and the program continues.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

return_to_plaza() flies to the closest Pokecenter on the map, and that
search can fall back to any fly point. Nothing checked where the player
landed, so every central_to_*() offset afterwards could be applied from
the wrong place (lab R3, 2026-10-22: landed near Chargestone, then
"Unable to fly to Chargestone Cavern!" ended the program).

(a) After landing, return_to_plaza() OCRs the place-name banner the game
shows ("Central Plaza" / 中心廣場) for up to 8 s. If it doesn't show
Central Plaza, it returns again with the cursor overshoot, up to 3
landings, then throws. Languages without a known name or OCR data skip
the check and log it. The loop runs against an injectable
PlazaReturnActions, unit tested with a scripted fake.

(b) map_move_cursor_fly() now throws TerariumFlyFailedException (an
OperationFailedExceptionWithScreenshot). process_and_do_quest() catches
only that type, returns to Central Plaza (checked), and lets the board
check count the attempt as failed, so the existing retry limit applies.
Other exceptions (shiny ProgramFinishedException, UserSetupError, other
operation failures) pass through as before.

return_to_plaza() takes the game language, so quest_wash_pokemon() now
takes the BBQ options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Give PlazaReturnCase's `landings` a default member initializer (= {}), so
test cases that leave them out of a designated initializer compile on
the Windows Clang CI job.

That job builds with clang-cl /W4 /WX, which turns on
-Wmissing-designated-field-initializers: a designated initializer that
omits a field without a default member initializer is an error. Apple
clang's -Wextra does not enable that warning, so macOS builds miss it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 3 commits October 30, 2026 07:41
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine dayfine added farmer Farming programs game:sv Scarlet/Violet labels Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine

dayfine commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Superseded by consolidated Tree 3 PR #274.

@dayfine dayfine closed this Nov 9, 2026
@dayfine
dayfine deleted the bbq/plaza-arrival-check branch November 13, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

farmer Farming programs game:sv Scarlet/Violet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant