-
Notifications
You must be signed in to change notification settings - Fork 64
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
Auto battle #4
Auto battle #4
Conversation
- Ports from old code: -- added getMovePower to calculate effective move power -- added isValidMove to determine validity of move -- added FindEffectiveMove to find the best move to use -- added BattleOpponent to handle battling opponents - New stuff: -- added handle_move_learning to deal with learning new moves -- added placeholder calculate_new_move_viability to be fleshed out later
# Conflicts: # modules/Menuing.py
- updated all instances of `select_battle_option` to `SelectBattleOption` - updated all instances of `log.info` to `console.print` - removed extraneous print statements
…splayedStringBattle`
# Conflicts: # modules/Stats.py
# Conflicts: # modules/Menuing.py # modules/Stats.py
# Conflicts: # config.yml # modules/Config.py # modules/Memory.py # modules/Stats.py
…bmgba (Linux users are probably gigabrain smart enough to figure it out)
Really sorry it's taking me so long to test and review this, but can we please remove all I just got this error |
modules/Stats.py
Outdated
replace_battler = not battle_won | ||
else: | ||
FleeBattle() | ||
replace_battler = replace_battler or not CheckLeadCanBattle() |
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.
┌───────────────────── Traceback (most recent call last) ─────────────────────┐
│ E:\Nextcloud\Projects\pokebot-gen3\pokebot.py:43 in MainLoop │
│ │
│ 40 │ │ try: │
│ 41 │ │ │ if GetGameState() == GameState.BATTLE: │
│ 42 │ │ │ │ if OpponentChanged(): │
│ > 43 │ │ │ │ │ EncounterPokemon(GetOpponent()) │
│ 44 │ │ │ │
│ 45 │ │ │ # If the game is still somewhere within the title screen │
│ 46 │ │ │ # with Prof. Birch) there is nothing the bot can do, so i │
│ │
│ ┌──────────────────────────────── locals ─────────────────────────────────┐ │
│ │ ModeSpin = <function ModeSpin at │ │
│ │ 0x0000028C033FE520> │ │
│ │ profile = Profile( │ │
│ │ │ rom=ROM( │ │
│ │ │ │ │ │
│ │ file=WindowsPath('E:/Nextcloud/Projec… │ │
│ │ - Emerald Version (USA, Europe).gba'), │ │
│ │ │ │ game_name='Pokémon Emerald │ │
│ │ (E)', │ │
│ │ │ │ game_title='POKEMON EMER', │ │
│ │ │ │ game_code='BPE', │ │
│ │ │ │ language=<ROMLanguage.English: │ │
│ │ 'E'>, │ │
│ │ │ │ maker_code='01', │ │
│ │ │ │ revision=0 │ │
│ │ │ ), │ │
│ │ │ │ │
│ │ path=WindowsPath('E:/Nextcloud/Projec… │ │
│ │ │ │ │
│ │ last_played=datetime.datetime(2023, │ │
│ │ 10, 10, 22, 52, 33, 11268) │ │
│ │ ) │ │
│ │ verified_that_game_has_started = True │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
│ E:\Nextcloud\Projects\pokebot-gen3\modules\Stats.py:674 in EncounterPokemon │
│ │
│ 671 │ │ │ replace_battler = not battle_won │
│ 672 │ │ else: │
│ 673 │ │ │ FleeBattle() │
│ > 674 │ │ replace_battler = replace_battler or not CheckLeadCanBattle() │
│ 675 │ │ if config['battle']['battle'] and config['battle']["replace_l │
│ 676 │ │ │ RotatePokemon() │
│ 677 │ │ if config['battle']["pickup"]: │
│ │
│ ┌──────────────────────── locals ────────────────────────┐ │
│ │ custom_found = False │ │
│ │ pokemon = { │ │
│ │ │ 'name': 'Oddish', │ │
│ │ │ 'id': 43, │ │
│ │ │ 'natID': 43, │ │
│ │ │ 'species': 43, │ │
│ │ │ 'pid': 85797318, │ │
│ │ │ 'nature': 'Bashful', │ │
│ │ │ 'language': 'E', │ │
│ │ │ 'shinyValue': 22537, │ │
│ │ │ 'shiny': False, │ │
│ │ │ 'ot': { │ │
│ │ │ │ 'tid': 17925, │ │
│ │ │ │ 'sid': 13015 │ │
│ │ │ }, │ │
│ │ │ ... +23 │ │
│ │ } │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
UnboundLocalError: cannot access local variable 'replace_battler' where it is
not associated with a value
Shutting down...
|
…ttle - added check to ensure `replace_battler` was only checked when battling is enabled
…her to print messages relating to switching a pokemon out - added CheckBattleCanHappen func to prevent bot from doing battle-related stuff if the party doesn't allow it, but also to enable the bot to battle if, say, the user heals at a PC after the bot wass just spinning around because it couldn't battle
…at I don't let temporary turn into permanent) checks to make sure the bot mode isn't manual so that users can regain control at any time by switching to manual mode - this is ugly and i don't like it but it fixes the issue quick so people can use it while i refactor this into a solution that uses fewer loops
…t doesn't display (since it's called like all the time)
Closing in favour of #117. |
This PR contains the changes needed to reimplement the automatic battling system. This also contains some handling for new move options-
stop
will stop execution and let the user pick, andcancel
will mash B until the overworld is reached unless the currently displayed text says "Stop learning {whatever the move is}?", in which case it will press A to exit the game's loop.