Add day/night detection and weather detection to za benchsit#1177
Add day/night detection and weather detection to za benchsit#1177Developer-Butters wants to merge 14 commits intoPokemonAutomation:mainfrom
Conversation
Created a day/night detection program that looks for the crecent moon on the minimap. added logic to bench sit to allow the user to only run forward during specifically day/night and specific weather patterns.
updated the window formatting and locked the filters while running because I don't want them to break somehow.
updated the detector to detect the color change on the left side of the main map. the color is dependent on the day night cycle. updated bench sit to use both weather and day/night detection to improve shiny farming rates of different pokemon.
my initial commits had a memory issue. these changes fix that.
…ource into add_day_night_ot_becnh_sit
Copied and pasted the original benchsit programs to the local repo to try to fix formatting. will confirm with diff on github. updated the detector to more clearly define day vs night added to the open menu portion of the detection functions a push left all the way so that the detector accurately detects the color of the border and doesn't get a false positive day or night. made the detector square persistent for testing purposes.
…ource into add_day_night_ot_becnh_sit
76e02de to
b3837b5
Compare
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. |
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. |
refined the detector and removed some debugging tools
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. |
…ource into add_day_night_ot_becnh_sit
|
I ran the program for about 8 hours and didn't get the QT creator crash I had been getting before, so I believe this is ready for review. |
|
This doesn't seem to work. I tested this with day time only and it ran on both day and night. 2026-04-18.08-51-11.mov |
Switch detection from luminance calibration of dark map edge to color- ratio sampling of zoomed-in terrain with icons hidden. Uses normalized blue-channel ratio for consistent classification across capture cards. Removes calibration logic and improves reliability across map locations.
corrected .h file from previous commit
I've made some changes in this most recent commit set. I'm letting it run for a bit to see if it works for me. |
Skip map checks when Run Forward Duration is 0 or no filters are enabled.
…-bench' into add_day_night_ot_becnh_sit
| LockMode::LOCK_WHILE_RUNNING, | ||
| GroupOption::EnableMode::DEFAULT_DISABLED | ||
| ) | ||
| , FILTER_MODE( |
There was a problem hiding this comment.
Rename this to DAY_FILTER_MODE.
| {0, "day", "Day"}, | ||
| {1, "night", "Night"}, | ||
| }, | ||
| LockMode::LOCK_WHILE_RUNNING, |
There was a problem hiding this comment.
Since this is being accessed atomically, you can unlock it.
| {4, "foggy", "Foggy"}, | ||
| {5, "rainbow", "Rainbow"}, | ||
| }, | ||
| LockMode::LOCK_WHILE_RUNNING, |
There was a problem hiding this comment.
This can also be unlocked.
| ) | ||
| , WEATHER_FILTER_MODE( | ||
| "Weather filter", | ||
| { |
There was a problem hiding this comment.
Formatting here is inconsistent with everything else. Indentation is always 4 spaces. Closing braces always indent back 4 to align with where it opened if it opened on a new line.
| return true; | ||
| } | ||
| DayNightState current_state = m_day_night_detector->state(); | ||
| if (current_state == DayNightState::NIGHT) { |
| // movement | ||
| if (duration > Milliseconds::zero()){ | ||
| if (WALK_DIRECTION.current_value() == 0){ // forward | ||
|
|
There was a problem hiding this comment.
Why are you removing comments?
| // run back | ||
| pbf_move_left_joystick(context, {0, -1}, duration + 750ms, 0ms); | ||
|
|
||
| pbf_move_left_joystick(context, {0, -1}, duration + 1000ms, 0ms); |
There was a problem hiding this comment.
Why are you adding newlines everywhere when it's only a 1 line change?
There was a problem hiding this comment.
it reads easier to me. will remove the extra spaces.
| run_back_until_found_bench(env, context); | ||
| }else if (WALK_DIRECTION.current_value() == 1){ // left | ||
| } | ||
|
|
| pbf_move_left_joystick(context, {0, -1}, duration, 0ms); | ||
| pbf_move_left_joystick(context, {+1, 0}, 100ms, 0ms); | ||
|
|
||
| pbf_move_left_joystick(context, {0, -1}, duration + 150ms, 0ms); |
There was a problem hiding this comment.
Can you explain what adding 150ms does here?
There was a problem hiding this comment.
it corrects for any accidental movement on the way to the bench. I can remove it here and elsewhere.
|
Now at least the day/night detection works. (I haven't checked the weather yet.) But my main concern now is how long it takes to open/check the map. You're adding 6 seconds to open the map. This is done on every day night cycle. So for every day/night pair, you add 12 seconds of overhead. This means that any run duration less than 6 seconds will actually be slower by filtering. The majority of the use cases for walking forward are less than that. IOW, the day/night detection needs to be a lot faster for this to be useful. Weather is a different story though. I haven't run the numbers on that to see whether it makes sense. If the map detection can't be sped up, you'll need do something else. For day/night, it's easy since they always alternate between day/night. Do the detection at the beginning and remember what the parity it. Then only recheck maybe every 100 bench sits to make sure you didn't miss one and end up on the wrong parity. For weather detection, that one is tricker. I haven't thought about that one yet. But at the very least, there is a path forward for day/night only if you want to split that out into a separate PR. |
I've restored the comments that were erroneously removed locally. I've also updated the formatting locally. I hear you on the added time from the map open, and I'm adding a user defined periodic check similar to your periodic save. I'll run a test of it. I also hear you on the weather thing. I was thinking it would be useful for pokemon like Goomy. But I think you're right the additional time it adds and the fact there are other, more effective ways available to shiny hunt these pokemon may not make the addition worth it. I have two thoughts: I can remove it entirely or I can add a disclaimer that this will greatly increase the amount of time it takes for you to use the program. I lean towards the former because it's such an edge case it probably would never be used. |
This PR adds a new Day/Night detector for Pokémon Legends: Z-A and integrates it into the Bench Sit shiny hunting program. I also added weather detection from the weather finder.
The detector samples color data directly from the main map to determine if the cycle is day or night.
The Bench Sit program now allows the user to define specific weather and time conditions before the character runs forward. this should allow the user to more effectively shiny hunt specific Pokemon like Lucario.