Skip to content

PokemonLZA: lock-on bracket and party bar detectors - #555

Draft
dayfine wants to merge 9 commits into
plza/upstream/s2-11from
plza/upstream/p1-01
Draft

dayfine wants to merge 9 commits into
plza/upstream/s2-11from
plza/upstream/p1-01

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Depends on #545

Adds two PokemonLZA screen readers that the AutoStory catches need: the lock-on bracket around a targeted Pokemon (LockOnBracketDetector) and the party bar's species count (PartyBarDetector). Neither presses anything; both read one frame. They are first called by the Wild Zone 1 catches in #563 and #564. Tested by their image suites PokemonLZA::LockOnBracketDetector and PokemonLZA::PartyBarDetector on frames in CommandLineTests/PokemonLZA/ (the LockOnBracketDetector and PartyBarDetector folders are not on PokemonAutomation/CommandLineTests yet).

@dayfine

dayfine commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

API review (claude-sonnet-5-5) at 3991a6f: changes_requested

The unused logger and scope parameters in the PartyBar test will fail the MSVC /W4 /WX build. The new test suites also read images that are not on CommandLineTests yet, so they will probably fail in CI until the images land. The rest is style: magic numbers, the near/far identifiers, and a few comment and naming problems.

  • [bug] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_PartyBarDetector.cpp:161 run_on_images takes Logger& logger, CancellableScope& scope and uses neither. MSVC /W4 /WX reports C4100 (unreferenced formal parameter) and fails the build. The LockOn test in the same PR leaves these parameters unnamed. Fix: Leave the parameters unnamed: Logger&, CancellableScope&,.
  • [bug] SerialPrograms/Source/VideoGames/PokemonLZA/PokemonLZA_Tests.cpp:41 This registers add_tests_LockOnBracketDetector (and add_tests_PartyBarDetector below), which read images from PokemonLZA/LockOnBracketDetector/ and PokemonLZA/PartyBarDetector/. The PR description says these folders are not on PokemonAutomation/CommandLineTests yet. CI checks out that repo, so every one of these cases would likely fail until the images land. Fix: Merge the CommandLineTests images first, or hold this PR until they are on the branch CI uses. Do not register suites whose fixtures are missing.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_LockOnBracketDetector.cpp:65 near and far are used as identifiers here, in arc_pixels (line 77) and as a local bool near in the test. They are empty macros in Windows headers (minwindef.h). Any TU that pulls in windows.h turns these declarations into syntax errors. Fix: Rename them, for example near_offset/far_offset and is_near in the test.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_LockOnBracketDetector.cpp:181 read_arc embeds many unnamed thresholds: 36 rows, 0.4 width/height, 0.9 row coverage, 0.06 bow, 0.02 fit slack, and 2 and 6 thickness (which duplicate NEAR_SIDE and FAR_SIDE without saying they are the same quantity). The doc comment says what they are but they are not named. arcs_pair has the same problem with 0.7, 0.12, 1.4 and 2.3. Fix: Make named constexpr values next to MIN_CHANNEL (MIN_ARC_HEIGHT, MAX_ARC_ASPECT, MIN_ROW_COVERAGE, MIN_BOW, MIN_PAIR_HEIGHT_RATIO, ...), each with a short why-comment.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_PartyBarDetector.cpp:44 The HP color thresholds in is_hp_color (140, 60, 170, 150, 100, 110) are bare literals with no explanation of where they came from. Fix: Name them (HP_GREEN_MIN_G, HP_GREEN_MARGIN, ...), or add a comment saying what frames they were measured on and their margin.
  • [style] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_PartyBarDetector.cpp:60 The party size 6 is repeated in the constructor, make_overlays and detect, and again as the std::array size in the header. It is a magic number that can drift. Fix: Add constexpr size_t PARTY_SIZE = 6; in the header, size the arrays with it, and use it in all loops.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_PartyBarDetector.h:32 The constructor has default arguments and is callable with a single Color, so it acts as an implicit conversion from Color. Fix: Mark it explicit.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_LockOnBracketDetector.cpp:106 The field Arc::left means 'opens to the right, shaped like (', and the call sites read left.left. The name is ambiguous and confusing. Fix: Rename it to bows_left or is_open_paren. The same applies at arcs_pair.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_LockOnBracketDetector.cpp:45 The comment says 'The lowest the brackets' middle sits', but MIN_MIDDLE_Y is the highest position on screen the middle may have (smallest y share). It reads backwards. Fix: Reword it to: 'The highest on screen the brackets' middle may be, as a share of the screen's height'.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_LockOnBracketDetector.cpp:325 The comment says 'on the user's walk', which describes where the author recorded the frames and is irrelevant to the code. The 'console's' wording in the comments elsewhere has the same problem. Fix: State what the frames show (resolution and scene) and drop the story of where they came from.
  • [nit] SerialPrograms/Source/VideoGames/PokemonLZA/Inference/PokemonLZA_PartyBarDetector.cpp:132 All three cases expect filled_slots = 5 with the bar visible. There is no case with no bar on screen (expected 0) and no full or partly filled party, so counting is barely exercised. The image folder path is also a string literal here, while the LockOn test uses a FOLDER constant. Fix: Add frames for a full party, a smaller party and no bar, and use a FOLDER constant as in the LockOn suite.

…ew fixes

The lock-on and party-bar suites read frames not on CommandLineTests yet;
they now skip when an image is missing (PendingFixtureTest) instead of
failing. The party-bar test leaves its unused parameters unnamed (MSVC
C4100), near/far become near_offset/far_offset (Windows macros),
PartyBarDetector takes PARTY_SIZE and an explicit constructor, and two
comments say what the code and frames are.
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