hsahovic / poke-env

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

VGC support -- remembering an opponent's team #522

Open caymansimpson opened 2 months ago

caymansimpson commented 2 months ago

Right now, once you enter a battle out of teampreview, there is no way to restore information about what possible mons an opponent had and what could be in back. Having a function in Battle object that remembers the opponent's teampreview team would be helpful! Any thoughts on the naming?

hsahovic commented 2 months ago

In theory, this should already be implemented. Have you checked that this is not the case in the current release? If it is indeed missing, I think this should just be stored in opponent_team.

caymansimpson commented 2 months ago

Just confirmed that this is not how this works. If I print out the following in the first turn of VGC (gen9vgc2024regg): print("My team: \t" + str(battle.team)) print("Oppponent team:\t" + str(battle.opponent_team)) # only what we know

I get: My team: {'p1: Furret': furret (pokemon object) [Active: False, Status: None], 'p1: Incineroar': incineroar (pokemon object) [Active: False, Status: None], 'p1: Raging Bolt': ragingbolt (pokemon object) [Active: True, Status: None], 'p1: Dragonite': dragonite (pokemon object) [Active: True, Status: None], 'p1: Entei': entei (pokemon object) [Active: False, Status: None], 'p1: Tornadus': tornadus (pokemon object) [Active: False, Status: None]} Oppponent team: {'p2: Raging Bolt': ragingbolt (pokemon object) [Active: True, Status: None], 'p2: Ogerpon': ogerponhearthflame (pokemon object) [Active: True, Status: None]}

From your comment in Issue #521, it seems you'd rather have the behavior being:

  1. The 4 pokemon you send out is stored in "team"
  2. Teampreview opponent mons are stored in "opponent_team"

So two clarifications for you that would help me move forward:

  1. They seem maybe inconsistent? Like I would expect them to either both represent teampreview teams or what we know of teams sent in battle. Just want to confirm the behavior you'd prefer!
  2. Do you have a preference for what the other variables are named? e.g. team/opponent_team to represent the 4 mons picked, and teampreview_team/opponent_teampreview_team to represent the possibilities (eg all 6 mons)
hsahovic commented 2 months ago

Ok - I'll get back to you on this one; I need to take a look at what exactly is currently happening.

caymansimpson commented 1 month ago

Are you still working on this? If not, if you have opinions on what the naming conventions are, I can implement.

hsahovic commented 1 month ago

In theory, this should already be implemented. Have you checked that this is not the case in the current release? If it is indeed missing, I think this should just be stored in opponent_team.

I now understand why I thought this was already implemented: there is a private _teampreview_opponent_team property doing exactly what you want. It is not officially maintained yet, but you can use it. I'll add official support for it in the next release.

caymansimpson commented 1 month ago

The addition of battle.teampreview_opponent_team as a property of battle would be great! The only thing I think is missing is storing the information of the team that we chose to send to battle. Right now, the battle.team attribute holds all 6 mons, but in VGC, only the four we choose matter. When AI will embed the state of the battle, we should be able to know which of the four mons we chose. So there are three options, I think:

  1. We update battle.team to only return teams that are returned from teampreview. I think in this case, it would also be great to have a battle.teampreview_team for all 6 of the player's mons as well (à la battle.teampreview_opponent_team), since this information will be helpful for the AI to learn how to "trick" opponents by bluffing potential mons in back
  2. We have a separate field like battle.sent_team that tells us which pokemon we send to battle
  3. We don't do anything at all, and just have AIs store/recall this information outside of poke_env

Wdyt?