Skip to content

weather detector refactor - #1319

Draft
Developer-Butters wants to merge 4 commits into
PokemonAutomation:mainfrom
Developer-Butters:WeatherDetectorRefactor
Draft

weather detector refactor#1319
Developer-Butters wants to merge 4 commits into
PokemonAutomation:mainfrom
Developer-Butters:WeatherDetectorRefactor

Conversation

@Developer-Butters

Copy link
Copy Markdown
Contributor

This pull request refactors and improves the weather icon detection logic for Pokémon LZA. The main change is a switch from a hard-coded template info table to using waterfill template matching. This should improve robustness. The test program is also updated to exercise and debug the new detection logic.

Weather Icon Detection Refactor and Improvements:

  • Replaced the static WeatherTemplateInfo table and related logic with a matcher-based approach using WaterfillTemplateMatcher and a new WeatherFullMatcher class, allowing for more flexible and robust template matching for each weather type.
  • Introduced supplemental_template_checks to handle additional region-of-interest template checks for specific weather types, improving detection accuracy and making it easier to add or modify checks.
  • Updated the WeatherIconDetector class to use the new matcher-based approach, removing unnecessary members and simplifying overlay logic.

Test Program and Integration Updates:

  • Updated the test program (TestProgramSwitch.cpp) to include the new weather detector and added a debug routine for visualizing and testing weather icon detection. [
    Code Cleanup:

  • Removed unused includes and the obsolete WeatherTemplateInfo struct from headers, reflecting the new detection approach.

@jw098

jw098 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

FYI. There is a merge conflict here.

@Developer-Butters
Developer-Butters force-pushed the WeatherDetectorRefactor branch 2 times, most recently from d25b9c9 to e6d9d70 Compare July 30, 2026 00:57
@Mysticial

Copy link
Copy Markdown
Collaborator

Can you rebase? We recently added new test infra which we will need to add tests for this to.

I just pushed the PLZA test skeleton to master. Once you rebase, you'll be able to add tests for this weather detector.

Basically you'll want to add the weather detector test here: https://github.com/PokemonAutomation/Arduino-Source/blob/main/SerialPrograms/Source/PokemonLZA/PokemonLZA_Tests.cpp#L17

Here is an example of what the new test structure looks like: https://github.com/PokemonAutomation/Arduino-Source/blob/main/SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.cpp#L477-L518

So you'll need to make that, then list the 30-some test files that you merged to the CommandLineTests repo. That way these can be automatically run with the rest of the other tests.

@Developer-Butters
Developer-Butters force-pushed the WeatherDetectorRefactor branch from e6d9d70 to f5afb33 Compare August 3, 2026 00:26
@Developer-Butters

Developer-Butters commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Can you rebase? We recently added new test infra which we will need to add tests for this to.

I just pushed the PLZA test skeleton to master. Once you rebase, you'll be able to add tests for this weather detector.

Basically you'll want to add the weather detector test here: https://github.com/PokemonAutomation/Arduino-Source/blob/main/SerialPrograms/Source/PokemonLZA/PokemonLZA_Tests.cpp#L17

Here is an example of what the new test structure looks like: https://github.com/PokemonAutomation/Arduino-Source/blob/main/SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.cpp#L477-L518

So you'll need to make that, then list the 30-some test files that you merged to the CommandLineTests repo. That way these can be automatically run with the rest of the other tests.

I've completed this now. I also made some changes to naming of the weather map screenshots.

@jw098

jw098 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Tests are failing. Maybe try rebasing onto main.

@Developer-Butters
Developer-Butters marked this pull request as draft August 4, 2026 17:39
@Developer-Butters
Developer-Butters marked this pull request as ready for review August 4, 2026 17:39
@Mysticial
Mysticial force-pushed the WeatherDetectorRefactor branch from 63dbe67 to cf2066d Compare August 8, 2026 04:58
@Mysticial

Copy link
Copy Markdown
Collaborator

I just rebased and tried to test this, but it's failing on missing resources.

Unable to open file.
File: C:/Users/Hikari/Desktop/PA-Repository/Public/build/RelWithDebInfo/Resources/PokemonLZA/Weather/clear_full.png

@Developer-Butters

Copy link
Copy Markdown
Contributor Author

I just rebased and tried to test this, but it's failing on missing resources.

Unable to open file.
File: C:/Users/Hikari/Desktop/PA-Repository/Public/build/RelWithDebInfo/Resources/PokemonLZA/Weather/clear_full.png

There is a pending PR on the packages repo that likely needs to be accepted for this to be resolved.

@Mysticial

Mysticial commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

That PR is empty though. Looks like jw wants you to adjust the templates.

@Developer-Butters

Copy link
Copy Markdown
Contributor Author

That PR is empty though. Looks like jw wants you to adjust the templates.

I thought i did that earlier this week. Not sure what happened to the commit. I'll fix it in the morning.

@Mysticial
Mysticial force-pushed the WeatherDetectorRefactor branch from cf2066d to 4f81ad0 Compare August 8, 2026 21:25
@Mysticial

Copy link
Copy Markdown
Collaborator

I merged+pulled the new resourced, then rebased this PR.

I fixed a few places in the test where you called TEST_RESULT_COMPONENT_EQUAL instead of TEST_RESULT_COMPONENT_EQUAL_STR. If you call the former, the test returns pass even though it fails.

Of the 36 tests, 24 are passing, 12 are failing because the detector detected either no weather icon, or it detected multiple of them.

FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_zoomed_1_True.jpg [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_zoomed_2_True.jpg [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rain_hyperspace_wild_zone_True.png [Rain] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_wild_zone_1_True.png [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rainbow_True.png [Rainbow] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/french_clear_wild_zone_20_2_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/french_clear_place_centrale_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_overview_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_1_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_1_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_2_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_2_True.png [Clear]

Examples:

Failed: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_1_True.png [Clear], Message: Error: run:419 num detected weather types result is 0 but should be 1.
Failed: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rainbow_True.png [Rainbow], Message: Error: run:419 num detected weather types result is 2 but should be 1.

So we're getting close!

@Developer-Butters

Copy link
Copy Markdown
Contributor Author

I merged+pulled the new resourced, then rebased this PR.

I fixed a few places in the test where you called TEST_RESULT_COMPONENT_EQUAL instead of TEST_RESULT_COMPONENT_EQUAL_STR. If you call the former, the test returns pass even though it fails.

Of the 36 tests, 24 are passing, 12 are failing because the detector detected either no weather icon, or it detected multiple of them.

FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_zoomed_1_True.jpg [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_zoomed_2_True.jpg [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rain_hyperspace_wild_zone_True.png [Rain] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/sunny_wild_zone_1_True.png [Sunny] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rainbow_True.png [Rainbow] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/french_clear_wild_zone_20_2_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/french_clear_place_centrale_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_overview_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_1_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_1_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_2_True.png [Clear] FAILED: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_2_True.png [Clear]

Examples:

Failed: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/clear_dark_1_True.png [Clear], Message: Error: run:419 num detected weather types result is 0 but should be 1.
Failed: PokemonPLZA::WeatherIconDetector - PokemonLZA/WeatherDetector/rainbow_True.png [Rainbow], Message: Error: run:419 num detected weather types result is 2 but should be 1.

So we're getting close!

I made some changes to the code by running stuff through the test program. and i bet, since i was calling the wrong test function in the tests, those changes were bad. Ill go rework it.

@Developer-Butters
Developer-Butters marked this pull request as draft August 10, 2026 00:30
@Developer-Butters
Developer-Butters force-pushed the WeatherDetectorRefactor branch 2 times, most recently from 479680c to 4f81ad0 Compare August 10, 2026 00:33
Developer-Butters and others added 4 commits August 9, 2026 19:37
Refactored the weather detector to use waterfill instead of direct object comparison.
added new testing infrastructure and made some improvements to RMSDs of the weather detector based on the results of the new testing infrastructure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants