Skip to content

Pokemon.__init__ raises ValueError on gen-illegal moves in customgame formats #909

@ChazWinterYT

Description

@ChazWinterYT

When using a customgame format (e.g. gen3doublescustomgame), poke-env crashes during battle initialization if a Pokemon's moveset contains a move that exists in later generations but not in the format's generation. This is incorrect behavior for custom game formats, which are explicitly designed to bypass legality restrictions.

Steps to reproduce:

  • Use a customgame format, e.g. gen3doublescustomgame
  • Include a move introduced after the format's generation (e.g. Stealth Rock, introduced Gen 4) in a Pokémon's moveset
  • The Showdown server accepts the team and starts the battle without error
  • poke-env crashes in _create_battle before the first turn
File "pokemon_agent.py", line 326, in _create_battle
    battle.teampreview_team = [Pokemon(gen=gen, teambuilder=tb_mon) for tb_mon in self._team.team]
File "poke_env/battle/pokemon.py", line 139, in __init__
    self._update_from_teambuilder(teambuilder)
File "poke_env/battle/pokemon.py", line 758, in _update_from_teambuilder
    move = Move(Move.retrieve_id(move_str), gen=self.gen)
File "poke_env/battle/move.py", line 317, in entry
    raise ValueError("Unknown move: %s" % self._id)
ValueError: Unknown move: stealthrock

Cause:
gen is derived by poke-env itself via GenData.from_format(format).gen. For gen3doublescustomgame this produces gen=3. When constructing Pokemon from teambuilder data, Move(..., gen=3) is called for each move, and any move not present in Gen 3's data raises. The user has no opportunity to intervene. Both the gen inference and the crash are internal to poke-env.

The Showdown server accepted the move without complaint. The crash is poke-env editorializing on legality that the showdown server explicitly waived.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions