Reconciliation in multiplayer games
We've talked about how prediction lets us eliminate network lag when handling player input. However, what happens if prediction is not correct (because something the client does not yet know happens in the game world)?
When the client has predicted the game state incorrectly (which may be due to many factors, such as the opponent’s moves or the indeterminism of the game itself) and it does not match the state of the server, reconciliation takes place. An amendment of the client game state is made based on the received state from the server. In this way, we ensure that both of the states are synchronized.
Reconciliation not needed
Case 1: Reconciliation not needed
Reconciliation needed
Case 2: Reconciliation needed
Each input and state has its own identifier. The clients predict their actions and game states with the same identifier as the server, and stores them in its game history. After receiving a valid game state from the server, the client compares it with the state saved in its history. If these states differ, the received state of the server is superimposed on the game, and then the game logic along with the saved subsequent actions is played back to the point in time where the client was before the conflict occurred.
Sounds like magic and a nightmare to implement? Well, we've done it so that you don't have to! It's implemented out of the box and Elympics uses this mechanism to keep your game state synchronized. However, you don't have to do anything to use it - just follow our gameplay implementation guidelines and it will just work 🎉
Prediction and reconciliation are two large mechanisms that are independent of the logic of a particular game. We’ve encapsulated them behind a layer of abstraction in the Elympics SDK, so that developers won’t need to know how they work, or even that they work at all.
Because of those mechanisms incorporated into Elympic's core, building a multiplayer game with Elympics is as easy as a building a single player one.