hsahovic / poke-env

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

Available moves in wrong slot after ally switch and ally faint #437

Closed thaipokecard closed 1 year ago

thaipokecard commented 1 year ago

I have a situation where my team only has 2 Pokemon left. In the last turn, one of my Pokemon uses ally switch and its partner got knocked out. In the current, my only Pokemon wants to use a move but its available moves are in another slot. I'm not sure if this is a bug or whenever there is only one Pokemon in my team in double battle, available moves will always take the first slot.

here is the log of previous turn and printed variables of current turn:

>battle-gen9vgc2023regulatione-38673
|
|t:|1698115144
|move|p1b: Cresselia|Ally Switch|p1b: Cresselia
|swap|p1b: Cresselia|0|[from] move: Ally Switch
|move|p2b: Mr. Rager|Rage Powder|p2b: Mr. Rager
|-singleturn|p2b: Mr. Rager|move: Rage Powder
|move|p2a: Check|Make It Rain|p1a: Cresselia|[spread] p1a,p1b
|-damage|p1a: Cresselia|83/227
|-damage|p1b: Dragonite|0 fnt
|faint|p1b: Dragonite
|
|upkeep
|turn|9
[None, cresselia (pokemon object) [Active: True, Status: None]]
[[lunarblessing (Move object), trickroom (Move object), allyswitch (Move object), moonblast (Move object)], []]
thaipokecard commented 1 year ago

Another instance.

This is the turn before. My team has two Pokemon and there is no faint.

>battle-gen9vgc2023regulatione-38838
|
|t:|1698121126
|move|p2b: Impala|Fake Out||[still]
|-hint|Fake Out only works on your first turn out.
|-fail|p2b: Impala
|move|p1b: Cresselia|Ally Switch|p1b: Cresselia
|swap|p1b: Cresselia|0|[from] move: Ally Switch
|move|p1b: Iron Hands|Heavy Slam|p2b: Impala
|-resisted|p2b: Impala
|-damage|p2b: Impala|60/100
|
|upkeep
|turn|19

The current turn, Cresselia disappears from active pokemon list but its available moves are shown but in different slot.

[ironhands (pokemon object) [Active: True, Status: None], None]
[[allyswitch (Move object), moonblast (Move object)], [heavyslam (Move object), fakeout (Move object), drainpunch (Move object), wildcharge (Move object)]]
hsahovic commented 1 year ago

Thanks for opening this issue. I'll look into it now.

hsahovic commented 1 year ago

I was able to reproduce and will implement a fix today.

hsahovic commented 1 year ago

It took a bit longer to properly fix, but it should be good to go in the next poke-env release :)