pokemon-showdown
pokemon-showdown copied to clipboard
`|request|` is sent before the user has all of the information about what has happened already
The documentation states
The protocol message to tell you that it's time for you to make a decision is:
|request|REQUEST
In practice, however, the message arrives after the user has already sent in their decision. This makes the |request|
message useless and, in the case of U-turn, impossible in general to know whether more information is coming and hasn't arrived yet. Here is a sample console output showing the problem:
<< >battle-gen4ou-1463597300
|player|p2|david stone2|169|
|teamsize|p1|2
|teamsize|p2|2
|gen|4
|tier|[Gen 4] OU
|rule|Sleep Clause Mod: Limit one foe put to sleep
|rule|Species Clause: Limit one of each Pokémon
|rule|OHKO Clause: OHKO moves are banned
|rule|Evasion Moves Clause: Evasion moves are banned
|rule|Endless Battle Clause: Forcing endless battles is banned
|rule|HP Percentage Mod: HP is shown in percentages
|
|t:|1638250626
|start
|switch|p1a: Scyther|Scyther, M|308/308
|switch|p2a: Caterpie|Caterpie, L28, M|100/100
|turn|1
>> battle-gen4ou-1463597300|/choose move 1|2
<< >battle-gen4ou-1463597300
|request|{"forceSwitch":[true],"side":{"name":"david stone","id":"p1","pokemon":[{"ident":"p1: Scyther","details":"Scyther, M","condition":"308/308","active":true,"stats":{"atk":256,"def":196,"spa":146,"spd":196,"spe":246},"moves":["uturn"],"baseAbility":"swarm","item":"","pokeball":"pokeball"},{"ident":"p1: Cloyster","details":"Cloyster, F","condition":"241/241","active":false,"stats":{"atk":209,"def":396,"spa":206,"spd":126,"spe":176},"moves":["blizzard"],"baseAbility":"shellarmor","item":"","pokeball":"pokeball"}]},"noCancel":true,"rqid":4}
<< >battle-gen4ou-1463597300
|
|t:|1638250647
|move|p1a: Scyther|U-turn|p2a: Caterpie
|-damage|p2a: Caterpie|0 fnt
|faint|p2a: Caterpie
>> battle-gen4ou-1463597300|/choose switch 2|4
<< >battle-gen4ou-1463597300
|request|{"wait":true,"side":{"name":"david stone","id":"p1","pokemon":[{"ident":"p1: Cloyster","details":"Cloyster, F","condition":"241/241","active":true,"stats":{"atk":209,"def":396,"spa":206,"spd":126,"spe":176},"moves":["blizzard"],"baseAbility":"shellarmor","item":"","pokeball":"pokeball"},{"ident":"p1: Scyther","details":"Scyther, M","condition":"308/308","active":false,"stats":{"atk":256,"def":196,"spa":146,"spd":196,"spe":246},"moves":["uturn"],"baseAbility":"swarm","item":"","pokeball":"pokeball"}]},"rqid":6}
<< >battle-gen4ou-1463597300
|
|t:|1638250649
|switch|p1a: Cloyster|Cloyster, F|241/241
|
|upkeep
<< >battle-gen4ou-1463597300
|request|{"active":[{"moves":[{"move":"Blizzard","id":"blizzard","pp":8,"maxpp":8,"target":"allAdjacentFoes","disabled":false}]}],"side":{"name":"david stone","id":"p1","pokemon":[{"ident":"p1: Cloyster","details":"Cloyster, F","condition":"241/241","active":true,"stats":{"atk":209,"def":396,"spa":206,"spd":126,"spe":176},"moves":["blizzard"],"baseAbility":"shellarmor","item":"","pokeball":"pokeball"},{"ident":"p1: Scyther","details":"Scyther, M","condition":"308/308","active":false,"stats":{"atk":256,"def":196,"spa":146,"spd":196,"spe":246},"moves":["uturn"],"baseAbility":"swarm","item":"","pokeball":"pokeball"}]},"rqid":8}
<< >battle-gen4ou-1463597300
|
|t:|1638250650
|switch|p2a: Exeggutor|Exeggutor, F|100/100
|turn|2
You can see that I had to send my move before |request|
appears.
Relatedly, |request|
arrives too early for normal moves -- it is sent prior to |turn|
indicating that the turn has even begun.
I'm confused because your first post says that |request|
arrives too late or not at all, but your second post says that |request|
arrives too early.
It's true that |request|
arrives too early, but that shouldn't be unsolvable. Just store it. I think probably it's worth fixing eventually, but is this urgent?
For your first move of the turn, |request|
is too early and that's weird but otherwise not a problem (you can see this on line 38 of my log). For U-turn switches, Baton Pass switches, and replacing fainted Pokemon, it arrives after the user sends in their move (you can see this on lines 28 and 30 of my log) . I've tried to work around this by guessing when it's time to make my selection, but I keep doing it wrong and either sending my selection before I have all the information or trying to send it too late and having my program hang.
I've looked at the logs a little more closely and I see I was misunderstanding which messages go with what. It consistently arrives too early, and I was mistaking the "too early" message from the next turn as being a "too late" message for this turn when using U-turn or Baton Pass.
To clarify my previous comment about what the issue is for me, it's not about the data contained in the request -- I could easily store that if I needed it. The issue is trying to decide when it's time to actually send my move. In the log I provided, at what point do I know the server is "done" sending me updates and I now have all the information I need to decide my move? As far as my testing has shown, if I use U-turn and have received the -damage
message, it means I've gotten everything. If I use Baton Pass and have received the move
message, I've gotten everything. I have to do something different for sending my move at the start of the turn, replacing a fainted Pokemon that fainted during a turn (but only in generations 1-3), and replacing a Pokemon that fainted at the end of the turn.
If that's just how it is, that's fine, I can add in all the special cases (and continue stumbling on more), it's just unfortunate that there's this thing that's documented as "You're ready to send your move once you get this message" and I can't use it to decide when to send my move. This isn't a major issue for human clients because you expect all of the messages to arrive faster than a human will see things and try to click a button, so things are eventually correct usually before anyone sees it. For a machine trying to make decisions based on the messages, it's more complicated.
Oh, I agree; I think this is worth fixing. I'm not sure when I'm likely to find time for this, though. :(