Skip to content

Add day/night detection and weather detection to za benchsit#1177

Open
Developer-Butters wants to merge 14 commits intoPokemonAutomation:mainfrom
Developer-Butters:add-day-night-to-za-bench
Open

Add day/night detection and weather detection to za benchsit#1177
Developer-Butters wants to merge 14 commits intoPokemonAutomation:mainfrom
Developer-Butters:add-day-night-to-za-bench

Conversation

@Developer-Butters
Copy link
Copy Markdown
Contributor

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.

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.
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.
@Developer-Butters Developer-Butters force-pushed the add-day-night-to-za-bench branch from 76e02de to b3837b5 Compare April 15, 2026 22:00
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

@Developer-Butters Developer-Butters marked this pull request as draft April 15, 2026 22:10
refined the detector and removed some debugging tools
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

@Developer-Butters
Copy link
Copy Markdown
Contributor Author

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.

@Developer-Butters Developer-Butters marked this pull request as ready for review April 16, 2026 21:33
@Mysticial
Copy link
Copy Markdown
Collaborator

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
@Developer-Butters
Copy link
Copy Markdown
Contributor Author

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

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.
LockMode::LOCK_WHILE_RUNNING,
GroupOption::EnableMode::DEFAULT_DISABLED
)
, FILTER_MODE(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to DAY_FILTER_MODE.

{0, "day", "Day"},
{1, "night", "Night"},
},
LockMode::LOCK_WHILE_RUNNING,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is being accessed atomically, you can unlock it.

{4, "foggy", "Foggy"},
{5, "rainbow", "Rainbow"},
},
LockMode::LOCK_WHILE_RUNNING,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be unlocked.

)
, WEATHER_FILTER_MODE(
"Weather filter",
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

// movement
if (duration > Milliseconds::zero()){
if (WALK_DIRECTION.current_value() == 0){ // forward

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding newlines everywhere when it's only a 1 line change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what adding 150ms does here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it corrects for any accidental movement on the way to the bench. I can remove it here and elsewhere.

@Mysticial
Copy link
Copy Markdown
Collaborator

Mysticial commented Apr 18, 2026

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.

@Developer-Butters
Copy link
Copy Markdown
Contributor Author

Developer-Butters commented Apr 19, 2026

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.

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.

2 participants