Type Chart causing a KeyError only containing a type as the error message
Hey there, I can't seem to get random battles to work with the bot because the type chart isn't working. This is the error message I get:
Message='ELECTRIC' Source=C:\Users\i4D4\Downloads\poke-env-master\poke-env-master\AItest.py StackTrace: File "C:\Users\i4D4\Downloads\poke-env-master\poke-env-master\AItest.py", line 61, in embed_battle (Current frame) moves_dmg_multiplier[i] = move.type.damage_multiplier( KeyError: 'ELECTRIC'
The type changes every time I run it because I'm running random battles.
This is the part of the code causing issues:
def embed_battle(self, battle: AbstractBattle) -> ObsType:
# -1 indicates that the move does not have a base power
# or is not available
moves_base_power = -np.ones(4)
moves_dmg_multiplier = np.ones(4)
for i, move in enumerate(battle.available_moves):
moves_base_power[i] = (
move.base_power / 100
) # Simple rescaling to facilitate learning
if move.type:
moves_dmg_multiplier[i] = move.type.damage_multiplier(
battle.opponent_active_pokemon.type_1,
battle.opponent_active_pokemon.type_2,
)
# We count how many pokemons have fainted in each team
fainted_mon_team = len([mon for mon in battle.team.values() if mon.fainted]) / 6
fainted_mon_opponent = (
len([mon for mon in battle.opponent_team.values() if mon.fainted]) / 6
)
...
```
move.type.damage_multiplier function need type chart, but move.type.damage_multiplier need not it, so I'm using
if move.type:
moves_dmg_multiplier[i] = battle.opponent_active_pokemon.damage_multiplier(move)
insted of
if move.type:
moves_dmg_multiplier[i] = move.type.damage_multiplier(
battle.opponent_active_pokemon.type_1,
battle.opponent_active_pokemon.type_2,
)
good luck.