8000 Battle System Update: Introduce Battle strategies, support Double and Safari battles by hanzi · Pull Request #366 · 40Cakes/pokebot-gen3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Battle System Update: Introduce Battle strategies, support Double and Safari battles #366

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

Closed
wants to merge 5 commits into from

Conversation

hanzi
Copy link
Collaborator
@hanzi hanzi commented Aug 27, 2024

Description

This updates the battle system to separate the menu-handling logic from the decision-making logic.

It introduces a new concept called 'BattleStrategy' that are objects with a set of functions that can make decisions given a certain battle state. (Here's the base class with all methods documented)

For example, the battle strategy's decide_turn(battle_state) method is called for each round of a battle to determine the next action (fight, item, run, ...)

Likewise, there are methods for deciding whether an evolution should be allowed or aborted, which existing move should be replaced if a new one is about to be learned, what to do after the lead Pokémon faints, etc.

Bot modes can specify their preferred battle strategy in the on_battle_started() method. That way, a bot mode can have much greater control over how the battle system behaves without the user having to modify the config files all the time. (And, for example the Nugget Bridge mode could have its own 'try to lose' battle strategy.)

As part of the battle system overhaul double battles are now supported, as are Safari encounters (in principle, the battle strategies still only switch to manual.)

Changes

  • The directory modules/battle_strategies/ contains available Battle Strategies and their interfaces. modules/battle_strategies/_interface.py contains the base BattleStrategy class which is heavily commented.
  • modules/battle_state.py contains a data class and helper functions to retrieve consolidated information about the current state of the battle, such as active Pokémon/opponents and various Pokémon-specific and arena-specific status conditions.
  • The other file starting with battle_ within modules/ contain the menuing logic, so that's mostly just what the old battle.py did with some enhancements and split up into several files.
  • Some changes to modules/data/... and modules/items.py relate to a new property of Item objects that indicate if and how an item can be used within battles.

Notes

So far, I have mostly just aimed for feature parity and not introduced any other battle strategies. So this PR does not make full use of the potential capabilities of the new battle system.

Checklist

  • Black Linter has been ran, using --line-length 120 argument
  • Wiki has been updated (if relevant)

@hanzi hanzi force-pushed the battle-system-overhaul branch 6 times, most recently from a9d86f8 to e213f59 Compare August 30, 2024 02:47
@hanzi hanzi force-pushed the battle-system-overhaul branch 2 times, most recently from 39a96ea to db597e9 Compare September 5, 2024 23:51
@hanzi hanzi force-pushed the battle-system-overhaul branch from db597e9 to 8e1e75f Compare September 16, 2024 20:33
@hanzi hanzi force-pushed the battle-system-overhaul branch from 8e1e75f to c68d2d4 Compare September 23, 2024 22:17
… Safari battles

This updates the battle system to separate the menu-handling logic from the decision-making logic.

It introduces a new concept called 'BattleStrategy' that are objects with a set of functions that can make decisions given a certain battle state.

For example, the battle strategy's `decide_turn(battle_state)` method is called for each round of a battle to determine the next action (fight, item, run, ...)

Likewise, there are methods for deciding whether an evolution should be allowed or aborted, which existing move should be replaced if a new one is about to be learned, what to do after the lead Pokémon faints, etc.

Bot modes can specify their preferred battle strategy in the `on_battle_started()` method. That way, a bot mode can have much greater control over how the battle system behaves without the user having to modify the config files all the time. (And, for example the Nugget Bridge mode could have its own 'try to lose' battle strategy.)

So far, I have mostly just aimed for feature parity and not introduced any other battle strategies.

As part of the battle system overhaul double battles are now supported, as are Safari encounters (in principle, the battle strategies still only switch to manual.)
@hanzi hanzi force-pushed the battle-system-overhaul branch from c68d2d4 to 0796f8a Compare September 24, 2024 12:20
@hanzi hanzi force-pushed the battle-system-overhaul branch from 0796f8a to f21744f Compare September 24, 2024 12:23
@hanzi hanzi closed this Sep 24, 2024
@hanzi hanzi deleted the battle-system-overhaul branch October 3, 2024 19:48
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
0