hsahovic / poke-env

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

Multiple battle formats for a single agent? #287

Open Phiarlan opened 2 years ago

Phiarlan commented 2 years ago

Hello! I've been toying with this environment over the past few days and I really like what I've been able to achieve with this repo so far! One thing that's been a stumbling block for me (and doesn't seem to be mentioned in the docs?) is that I can't seem to set an agent to accept challenges for multiple formats (for instance, allowing it to accept a challenge for either "gen8randombattle" or "gen8ou").

I have attempted to specify different types that the battle_format parameter can accept. For instance, battle_format: List[str] = ["gen8randombattle", "gen8ou"] or battle_format: List[str] = None and then placing in the actual init function:

if battle_format is None
           self._format = ["gen8randombattle", "gen8ou"]
else:
           self._format = battle_format

Nothing I have done seems to have worked, however. With any of my changes, the bot can connect to Showdown, but it never accepts any challenges I send it. It will only accept challenges if it is a single string that gets passed to battle_format.

How can I make the agent accept any format that it is challenged to?

Thank you in advance!

hsahovic commented 2 years ago

Hey @Phiarlan! This is currently not implemented, but would be doable. For your use case, what would be a good way to deal with teams per format?

Phiarlan commented 2 years ago

Hi, thank you so much for the quick response!

I'm a newbie when it comes to using Python, so I'm afraid my suggestions will be a little less concrete. If there were a way to assign formats to an agent, whereupon it would accept challenges from any of those formats listed, that would be great! Perhaps splitting battle_format into two separate parameters (one for accepting challenges which could do a multitude of formats, and one for sending challenges, so that you can train a specific format rather than worry about extra steps on other formats)?

As for teams, I'm not sure what would be a cost-effective solution. My first thought is setting a bunch of conditionals

if format = "gen8ou":
   team = Gen8OUTeambuilder

Or something to that effect. That could lead to lengthy files and/or slow runtime, though. I know Showdown organizes the different teams in folders (so you can filter to a specific format in a specific generation) - something similar to that could probably work.

As a sidenote, I've noticed some issues when swapping a bot from a random battle format to a team-based format. After setting my agent to just "gen8randombattle," I got an error every time about how the format did not allow predetermined teams... despite me erasing any and all references to the OU team I used for testing. Perhaps it's a parsing issue?

Thank you again for the quick answer!

Phiarlan commented 2 years ago

Hey, @hsahovic! Just wanted to see how things were going on this enhancement. If things have been busy, that's fine - take your time! I just wanted to make sure it wasn't forgotten about.