hsahovic / poke-env

A python interface for training Reinforcement Learning bots to battle on pokemon showdown
https://poke-env.readthedocs.io/
MIT License
297 stars 103 forks source link

Error when game goes over 1000 turns #140

Closed attraylor closed 3 years ago

attraylor commented 3 years ago

2021-04-13 08:39:38,118 - SimpleRLPlayer - ERROR - Unhandled exception raised while handling message:

battle-gen8ou-2570019 t: 1618317578 switch p2a: Heatran Heatran, F 100/100 switch p1a: Landorus Landorus-Therian, M 115/382 brn -ability p1a: Landorus Intimidate boost -unboost p2a: Heatran atk 1
-heal p1a: Landorus 138/382 brn [from] item: Leftovers
-damage p1a: Landorus 115/382 brn [from] brn
upkeep
bigerror You will auto-tie if the battle doesn't end in 500 turns (on turn 1000).
-hint If you want to tie earlier, consider using /offertie.
turn 500
Traceback (most recent call last): File "poke-env/src/poke_env/player/player_network_interface.py", line 131, in _handle_message await self._handle_battle_message(split_messages) File "poke-env/src/poke_env/player/player.py", line 289, in _handle_battle_message battle._parse_message(split_message) File "poke-env/src/poke_env/environment/abstract_battle.py", line 425, in _parse_message raise NotImplementedError(split_message) NotImplementedError: ['', 'bigerror', "You will auto-tie if the battle doesn't end in 500 turns (on turn 1000)."] 2021-04-13 08:39:38,122 - Simple heuristic player - ERROR - Unhandled exception raised while handling message: battle-gen8ou-2570019 t: 1618317578 switch p2a: Heatran Heatran, F 386/386 switch p1a: Landorus Landorus-Therian, M 31/100 brn -ability p1a: Landorus Intimidate boost -unboost p2a: Heatran atk 1
-heal p1a: Landorus 37/100 brn [from] item: Leftovers
-damage p1a: Landorus 31/100 brn [from] brn
upkeep
bigerror You will auto-tie if the battle doesn't end in 500 turns (on turn 1000).
-hint If you want to tie earlier, consider using /offertie.
turn 500

Traceback (most recent call last): File "poke-env/src/poke_env/player/player_network_interface.py", line 131, in _handle_message await self._handle_battle_message(split_messages) File "poke-env/src/poke_env/player/player.py", line 289, in _handle_battle_message battle._parse_message(split_message) File "Pokemon/poke-env/src/poke_env/environment/abstract_battle.py", line 425, in _parse_message raise NotImplementedError(split_message) NotImplementedError: ['', 'bigerror', "You will auto-tie if the battle doesn't end in 500 turns (on turn 1000)."]

hsahovic commented 3 years ago

Hey Aaron,

Thanks for reporting this. I'll get a fix tonight.

hsahovic commented 3 years ago

This should be fixed by #141. I will release it in version 0.4.11 when #139 is merged too - in the meantime, you can pull for master or rebase your fork from it :)

Icemole commented 3 years ago

It is still happening, although not as the crash @attraylor mentioned. Instead, when it reaches turn 1000, it activates an "Endless Battle Clause":

Traceback (most recent call last):
  File "env/lib/python3.6/site-packages/poke_env/player/player_network_interface.py", line 131, in _handle_message
    await self._handle_battle_message(split_messages)
  File "env/lib/python3.6/site-packages/poke_env/player/player.py", line 300, in _handle_battle_message
    battle._parse_message(split_message)
  File "env/lib/python3.6/site-packages/poke_env/environment/abstract_battle.py", line 454, in _parse_message
    raise NotImplementedError(split_message)
NotImplementedError: ['', 'message', 'It is turn 1000. Endless Battle Clause activated!']

I am using version 0.4.11.

hsahovic commented 3 years ago

Hi @Icemole,

Thanks for reporting this. Pokemon-showdown recently changed some of it's API / protocol structure: I suspect that is what is causing this issue. I'll take a look at it and try to fix it asap :)

hsahovic commented 3 years ago

Hey @Icemole,

I was unable to reproduce it with 1500+ turn battles. Which version of poke-env are you using? If installed through pip, you can pip freeze to display your installed packages along with their versions.

Icemole commented 3 years ago

Hi, pip freeze shows poke-env==0.4.11. I think I should mention that me and my colleague are developing a 1st generation bot so that may be our issue; the error may have been solved in posterior generations. We are using such version because it is the one that solves the warning on 500 turns (it seems it was relatively easy to run into a Clefairy - Gengar matchup for instance), but the latest version doesn't allow us to use a player from the 1st generation because of a KeyError when accessing internal poke-env data (we know it's not officially supported, but we still wanted to train an agent for the 1st gen).

hsahovic commented 3 years ago

Interesting - I'll try to get things running with gen 1 then :)

hsahovic commented 3 years ago

@Icemole poke-env version 0.4.15 is out. It should let you run gen 1 / 2 / 3 battles (but log a warning) without too much trouble, using gen 4 objects (eg. Gen4Move, Gen4Battle, etc).

Regarding the Endless Battle Clause: message type messages should be logged (info level logging). As an aside, Battle.turn should let you deal with long-running battles as you see fit in your agents.

Please feel free to open an issue if you encounter any problem :) Gen 1 support is very basic right now, but if you have a specific need we can discuss it.