ForgottenArbiter / CommunicationMod

Slay the Spire mod that provides a protocol for allowing another process to control the game
MIT License
81 stars 17 forks source link

CommunicationMod hangs if Match and Keep! choices are selected too quickly #9

Closed houeland closed 3 years ago

houeland commented 3 years ago

CommunicationMod hangs if spirecomm selects choose 0 too quickly (i.e. with no-ux version of SuperFastMode). One card is chosen, and then communicationmod gets stuck while the game displays "Remaining Attempts: 4", never sending a new game state after the latest choose 0 command.

I can consistently reproduce this with

result = coordinator.play_one_game(PlayerClass.IRONCLAD, seed="2TQ7CH7RF8M2H")

when SuperFastMode 999.0.0 is set to make some actions instant + increase speed to 1000%.

It doesn't hang if I disable instant actions and play at 100% speed, and doesn't hang if I play with SuperFastMode but add a small delay to def handle_screen(self):

[...]
else:
    time.sleep(0.07)  # Add a small delay before sending the choice to communicationmod
    return ChooseAction(0)
[...]

ModVersion Info:

Mod list:

communicationmod-hangs-on-match-and-keep-SlayTheSpire.log

Screenshot 2020-10-25 at 22 31 33
ForgottenArbiter commented 3 years ago

Thank you for the detailed description. This bug has been a bother for a long time, but I've never reproduced it before! I managed to recreate the issue and I think it should be fixed in 1.0.3, along with a couple more improvements to the event. Among other things, now, the game should never hijack your cursor without a controller plugged in.

houeland commented 3 years ago

Great, thanks for the quick fix!

I reproduced the buggy setup with v1.0.2 and verified that it failed 3x in a row, then swapped in v1.0.3 instead and it succeeded 5x in a row. And it also looks better while playing the event now :)

DevJac commented 3 years ago

I altered the SuperFastMod to go 10,000% speed, instead of the usual maximum of 1,000% speed, and was experiencing this bug. However, when I stopped (ab)using SuperFastMod the problem went away.

I wanted to mention this in case it's helpful in diagnosing future issues, or in case it helps someone else fix the same problem. TLDR: If you make SuperFastMod go too fast, you'll have problems.

ForgottenArbiter commented 3 years ago

Thanks for the note. I think this might have something to do with you speeding the game up so much that a chosen card both flips and unflips in the same frame. I'm probably not going to fix it to account for this corner case, but it's good to know.