-
-
Notifications
You must be signed in to change notification settings - Fork 162
game-state mismatch [bug]/[possible enhancement] #27
Comments
Hi @rocketinventor, thanks for digging deep on this! I like the idea of using a hash to track the current game state. I don't think the server should proactively reset if it gets a mismatched token; better to let the client make the decision to either a) start a new game or b) request a sync of the full game state. So I guess the steps to complete are:
|
After reducing the frequency of this issue, I was able to confirm that #27 is indeed the root cause of #26 and not bad server logic.
|
@rocketinventor Indeed betago only is designed to serve a single game per launch of the server. That's consistent with the GTP protocol, but it raises issues like this one, and unnecessarily prevents you from running one web server to play simultaneous games across the internet. A simpler approach than implementing state tokens would be to have the server maintain no state at all, and to have the client to send the complete move history with each request. Then the bot would just do a loop of apply_move() starting from an empty board before selecting its move. |
Well this raises two separate questions:
|
@cdmalon As @macfergus said, a stateless server would be interesting but the implementation would be impractical and waste a lot of data and CPU cycles for what we need. Plus, parsing the game data for the server and implementing GTK over HTTP would add additional complexities. At this point, I think it is fine just to mirror one game across multiple clients. A similar system to what I proposed is being used right now by OGS, which is a popular game server uses a similar system to what I described and runs quite well. Session/device tokens are as simple as adding a few cookies to the flask server. The web browser handles the rest (automatically). The biggest problem right now is that the client sometimes accepts an invalid move or applies moves as the wrong color (or doesn't apply them at all). I have made some improvements to the client code that address this issue via improvements to #30. By making a few simple changes, I was able to reduce the rate of error so much that I had to artificially create new ones in order to test it. I will have the pull request out as soon as I get a chance. We don't need a production quality web server but, it needs to be reliable so that the web server/client aren't causing problems that inhibit the regular use of BetaGo. |
I just submitted a pull request (#38) that addresses this issue, please merge. |
I would like to implement game sync but I don't know where the data is stored (see #45). Please help! Thanks! |
If a user refreshes the betago web page but not the server, the game does not actually reset. As a result, an error is thrown by the server any time you try to play in an area that was previously played on. The javascript does not have proper error handling for this, so it stops playing as black, and starts playing and processing as white (locally) for the next move but sends the coordinates to the server as if it were a black move.
The js error always looks like this:
And, the server side callback always looks like this:
The problem is resolved if the server is restarted but if the web page is not reloaded, too, it can lead to more confusion. The web page doesn't know to reset, so the old (and wrong) game data still shows and moves from the server can coincide with illegal moves.
A possible solution to this is to create a randomly generated session number or hash that is sent to the server with each move, as well as what move number the client thinks it is at.
If the server gets a message with a new session number, it can:
If the client is getting mismatched data, it can display an alert, clear the board, or abort.
Another solution (and possible feature enhancement) could be for the server to keep track of the board and send a copy of the current game state as an array upon request of the client (i.e. when the web page is loaded or an error is suspected) or even as an additional piece of data embedded in the response (significantly enhances reliability but hurts speed and bandwidth). This would be very easy to implement client side.
Ideal for single instance server:
When UI client loads, it pulls latest game data from the server and continues from there as if it was open the whole time. The user can start a new game at any time by pressing a button.
This is a very similar to issue to #26 and the manifestation of the bugs are practically identical.
The text was updated successfully, but these errors were encountered: