Skip to content
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

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

Open
turibito opened this issue Mar 24, 2024 · 1 comment

Comments

@turibito
Copy link

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
Copy link
Contributor

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)

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

No branches or pull requests

2 participants