hsahovic / poke-env

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

How to fix "TypeError: PokemonType.damage_multiplier() missing 1 required keyword-only argument: 'type_chart'" #519

Open turibito opened 6 months ago

turibito commented 6 months ago

Tried to run rl with new gym wrapper code and it gives out the following error. Can you please tell me how to fix "PokemonType.damage_multiplier()".

2024-03-24 08:40:32,328 - SimpleRLPlayer 12 - ERROR - Unhandled exception raised while handling message: battle-gen8randombattle-12 player p2 RandomPlayer 12 169 teamsize p1 6 teamsize p2 6 gen 8 tier [Gen 8] Random Battle rule Species Clause: Limit one of each Pokémon rule HP Percentage Mod: HP is shown in percentages rule Sleep Clause Mod: Limit one foe put to sleep rule Illusion Level Mod: Illusion disguises the Pokémon's true level
t: 1711269632
start
switch p1a: Tapu Fini Tapu Fini, L77 234/234
switch p2a: Dugtrio Dugtrio-Alola, L82, M 100/100
-fieldstart move: Misty Terrain [from] ability: Misty Surge [of] p1a: Tapu Fini
turn 1
Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/poke_env/ps_client/ps_client.py", line 135, in _handle_message await self._handle_battle_message(split_messages) # type: ignore File "/usr/local/lib/python3.10/dist-packages/poke_env/player/player.py", line 346, in _handle_battle_message await self._handle_battle_request(battle) File "/usr/local/lib/python3.10/dist-packages/poke_env/player/player.py", line 370, in _handle_battle_request message = await message File "/usr/local/lib/python3.10/dist-packages/poke_env/player/openai_api.py", line 85, in _env_move battle_to_send = self._user_funcs.embed_battle(battle) File "", line 25, in embed_battle moves_dmg_multiplier[i] = move.type.damage_multiplier( TypeError: PokemonType.damage_multiplier() missing 1 required keyword-only argument: 'type_chart' ERROR:SimpleRLPlayer 12:Unhandled exception raised while handling message: battle-gen8randombattle-12 player p2 RandomPlayer 12 169 teamsize p1 6 teamsize p2 6 gen 8 tier [Gen 8] Random Battle rule Species Clause: Limit one of each Pokémon rule HP Percentage Mod: HP is shown in percentages rule Sleep Clause Mod: Limit one foe put to sleep rule Illusion Level Mod: Illusion disguises the Pokémon's true level
t: 1711269632
start
switch p1a: Tapu Fini Tapu Fini, L77 234/234
switch p2a: Dugtrio Dugtrio-Alola, L82, M 100/100
-fieldstart move: Misty Terrain [from] ability: Misty Surge [of] p1a: Tapu Fini
turn 1

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/poke_env/ps_client/ps_client.py", line 135, in _handle_message await self._handle_battle_message(split_messages) # type: ignore File "/usr/local/lib/python3.10/dist-packages/poke_env/player/player.py", line 346, in _handle_battle_message await self._handle_battle_request(battle) File "/usr/local/lib/python3.10/dist-packages/poke_env/player/player.py", line 370, in _handle_battle_request message = await message File "/usr/local/lib/python3.10/dist-packages/poke_env/player/openai_api.py", line 85, in _env_move battle_to_send = self._user_funcs.embed_battle(battle) File "", line 25, in embed_battle moves_dmg_multiplier[i] = move.type.damage_multiplier( TypeError: PokemonType.damage_multiplier() missing 1 required keyword-only argument: 'type_chart'

caymansimpson commented 4 months ago

You have to pass it a type chart for it to work. This code will help you. Is this a bug in poke-env or is this your code?

from poke_env.data import GenData type_chart = GenData(9).type_chart move.type.damage_multiplier(*target_mon.types, type_chart=type_chart)