Open matwate opened 5 months ago
Even weirder is, sometimes the bot just stops, no clue why and no steps to reproduce as its seemingly random
Hey! Im having the exact same issue. Did you find the solution or any leads?
Might help.
Might help.
Idk if the issue you mentioned is going to fix it 100%, since i think its not returning None anywhere, maybe i have to choose a random move in the outer most except block?
For my code, the sentchoice NotImplementedError occurred when players have the same usernames as those in previous unfinished battles. For some reason they rejoin these old battle rooms and battle in them. I do not know why they do this. The rejoining previous rooms happens fairly regularly, but I believe the error only occurs when the room is deemed inactive. The player tries to send an action choice for the inactive battle, which results in the error. This rejoining old rooms also persists across runs, unless the Showdown server is reset. I am currently looking into why. It probably has to do with the challenge loop, but I don't understand how they can apparently accept the same challenge for a room more than once, even across runs.
As for the other RunTimeErrors, I have not seen any of them.
I found what was causing the sentchoice NotImplementedError. You need to call .close() on the gym environment when done using it, always. If your run crashes or otherwise ends before calling .close() on all gym environments you started, it will leave all unfinished battles open, with no easy way of closing them. This results in my previously mentioned behavior, where players with the same usernames as those in the unfinished battle will rejoin the unfinished battle and cause the sentchoice NotImplementedError. In the case where the run crashes or ends before calling .close() on all gym environments, the only solution I could find was to restart the local showdown server. I tested adding "sentchoice" to AbstractBattle's MESSAGES_TO_IGNORE, but that resulted in occasional hangs on later environment .reset() calls and an exception on .close(). The old unfinished battle seems to cause an offset where an extra battle is created but not added into the environment's dictionary of battles.
I found what was causing the sentchoice NotImplementedError. You need to call .close() on the gym environment when done using it, always. If your run crashes or otherwise ends before calling .close() on all gym environments you started, it will leave all unfinished battles open, with no easy way of closing them. This results in my previously mentioned behavior, where players with the same usernames as those in the unfinished battle will rejoin the unfinished battle and cause the sentchoice NotImplementedError. In the case where the run crashes or ends before calling .close() on all gym environments, the only solution I could find was to restart the local showdown server. I tested adding "sentchoice" to AbstractBattle's MESSAGES_TO_IGNORE, but that resulted in occasional hangs on later environment .reset() calls and an exception on .close(). The old unfinished battle seems to cause an offset where an extra battle is created but not added into the environment's dictionary of battles.
I'm not using a gym environment but experiencing this issue, is there any way of just cleaning up all battles when turning the bot back on?
I'm not using a gym environment but experiencing this issue, is there any way of just cleaning up all battles when turning the bot back on?
Not that I know of, but I'm working on a solution right now.
I think an if statement may be added to Player's _handle_battle_message before it creates a battle object, after line 255. This should ignore battle object creation if the battle was created before the Player, using the UNIX timestamp |t:| provided by showdown in the battle's initialization message. This way the player never recognizes battles made before it.
This happens in two cases:
Here's the error message:
My custom player code is the following:
and the functions from "utils"