xtagon / chatsnek

Twitch chat plays Battlesnake
MIT License
4 stars 1 forks source link

Votes are inconsistent when multiple games are run concurrently #8

Open xtagon opened 3 years ago

xtagon commented 3 years ago

ChatSnek was originally designed to run a single game at a time, for live streaming purposes. Because of this, it keeps only a single tally of votes per turn, not per game. This is fine when only one game is running, but it's possible to start multiple games before the one finishes, for example by reloading the browser or changing the scene when streaming.

  1. When that happens, the problem occurs where the votes will be reset after one of the game's turns, and the next game's tally will be empty, but if that game with the empty tally is the current one on the screen, that means the voting isn't working.

  2. ChatSnek's chat messages are enabled during that scenario, it could print double messages to the chat, one per game per turn.

  3. Ever since adding a "move safety" feature to ChatSnek, the games will run on their own even if the stream element has been reset or closed, or if nobody is voting, so it's not enough to just wait for the duplicate games to end, as that could take a while.

xtagon commented 3 years ago

Some workarounds for now:

  1. Be careful when streaming to only open one broadcast game window at a time. In OBS there's a setting to not refresh the window when the scene changes. In headless streaming it's less of a problem as long as you don't have to restart the server.

  2. If multiple games do happen, you can tell by the double vote messages if chat is enabled. Stop the duplicate game by checking for its last move and voting the opposite direction (the "forbidden move" in Battlesnake).