-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EV Training #591
base: main
Are you sure you want to change the base?
EV Training #591
Conversation
Add Wiki entry for EV train mode
Update WIKI
def on_battle_started(self, encounter: EncounterInfo | None) -> BattleAction | BattleStrategy | None: | ||
action = handle_encounter(encounter, enable_auto_battle=True) | ||
lead_pokemon = get_party()[0] | ||
# EV yield doubled with Macho Brace and Pokerus (this effect stacks) | ||
ev_multiplier = 1 | ||
if lead_pokemon.held_item is not None and lead_pokemon.held_item.name == "Macho Brace": | ||
ev_multiplier *= 2 | ||
if lead_pokemon.pokerus_status.days_remaining > 0: | ||
ev_multiplier *= 2 | ||
|
||
# Checks if opponent evs are desired | ||
good_yield = all( | ||
get_opponent().species.ev_yield[stat] * ev_multiplier + lead_pokemon.evs[stat] <= self._ev_targets[stat] | ||
for stat in _list_of_stats | ||
) | ||
# Fights if evs are desired and oppenent is not shiny meets a custom catch filter | ||
if good_yield and action is BattleAction.Fight: | ||
return NoRotateLeadDefaultBattleStrategy() | ||
elif action is BattleAction.Fight: | ||
return BattleAction.RunAway | ||
else: | ||
return action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, this would make the bot fight even shiny Pokémon, Custom Catch Filter matches, or the Roamers if they happen to give EVs that match the targets.
I think a
if encounter.is_of_interest:
return action
would do the trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that it does not fight custom catch filters. The logic could be clearer perhaps. If a custom catch filter is met, the action will not be fight. In that case it defaults (via the last else statement) to the default action.
If you like we could rewrite it for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that would be best. I'd say that's a general expectations when people use the bot, that no matter what mode you use the bot will never just lose a shiny by fighting it/running away.
The code snippet from my previous comment should be sufficient to fix this, if you put it right after the action = handle_encounter(...)
line.
encounter.is_of_interest
already checks all the things we want, such as whether an encounter is a shiny/CCF match/Roamer, but also that it's not on the block list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear - it does stop for custom catch filters. It works as expected.
However, we can follow your logic if it is clearer and easier to maintain.
Admittedly I haven't left it on long enough to see a shiny. But it will just return action
which (as I understand) will default to the normal way of handling an encounter.
Description
Implements EV training mode. Built using the level-grind mode as a base.
Changes
Mostly adding files for the mode. Otherwise adding references to the mode only.
Checklist
--line-length 120
argument