This is the multi-page printable view of this section.
Click here to print.
Return to the regular view of this page.
The basic concepts you need to understand with Elympics
Elympics — what do I need to know?
In this article we are going to dive deeper into one of the core functionalities of Elympics — Multiplayer Services. We will explain the difficulties of building a multiplayer gameplay and how Elympics eliminates them.
1 - Overview: Current Multiplayer implementations
What are the current implementations of multiplayer available?
Current multiplayer implementations
There are 3 main approaches towards multiplayer among game developers:
- Peer to Peer — a very basic, naive solution. No server is required. Suitable only for playing within a single WiFi network, or with a Bluetooth connection. The amount of transferred data increases significantly with more players thus this solution is rarely used in practice.
- Client authoritative — an approach to creating multiplayer games that gives clients (players) the full power to change the game state. Because of that, there is no need for a server as an arbiter, which controls the game. The biggest advantage of this approach is the lack of costs associated with the maintenance of server infrastructure. The unacceptable disadvantage in e-sports or play-to-earn games is the susceptibility to cheating by the lack of full verification of clients’ actions. Due to the lack of an arbitrator, the game developer is responsible for synchronization and resolving potential conflicts.
However, the client authoritative approach does require a server which plays the role of “transmitter” of information — no code related to the game logic is executed on it. Unfortunately, such solutions do not allow for creating a multiplayer game in the same way we would create a single player game, because of the programmers’ responsibility to synchronize the state of the game.
However, non of the solutions above is capable of ensuring fairness. This means that if you want to create a play-to-earn game where players are rewarded for their achievements during the gameplay, you only have one option:
- Server authoritative — an approach to creating multiplayer games requiring a central server on which the game takes place. Clients (players) act only as receivers of the game state from the server and as creators of minimal inputs according to the game rules. This approach prevents breaking the game rules but it requires hosting a separate server with the game logic.
This method has a number of advantages such as universal architecture and clear conflict resolution. The main difficulties in developing games this way are: synchronizing the state of the game correctly without creating a feeling of lag and maintaining a production environment adequate to the needs of the current number of players.
The problem is, this approach requires infrastructure that is both expensive and difficult to set up. This is the type of method used by Elympics Multiplayer Services games. We have solved the difficulties associated with it in a universal way. While using Elympics, the developers do not have to create the infrastructure themselves. This allows any studio to benefit from the advantages of server authoritative approach without having to write the network code or incur immense costs.
2 - Client Authoritative limitations
What is client authoritative and why is it limited?
A client-server architecture where players have the overriding role in arbitrating the game, implies the possibility for players to cheat. The client, having control over the arbitration, can freely modify the state of the game without any validation from the server.
In this example, it is the client that sends the new coordinates without an external referee. This allows them to send arbitrary values even though, according to the game rules, they should actually be able to move only one point.
The solution would be to delegate their role in refereeing the game to the server, so that the state they send is validated by the server and does not allow players to modify it against the game logic.
In the client-server architecture the game logic is also played on the server, and the game state sent by clients is validated and synchronized with the server. The server takes over the arbitration of the game and its state is superior to the players. This way the role of clients is reduced which prevents the players from cheating.
3 - Elympics Unity SDK
What is Elympics Unity SDK?
The Elympics system is independent from the game engine. This means that you can use it in any production environment you choose. In order to make game development easier and faster, an SDK for the Unity environment has been created, allowing you to conveniently implement multiplayer gameplay without having to create network code.
- Built-in game state synchronization,
- Integration with the Unity editor,
- Multiple game modes:
- Common code on server and client (forced by SDK architecture),
- Automatic building of the server part of the game
You can download Elympics SDK and get started creating your game right now!
4 - Prediction in multiplayer games
What is prediction? Why is it needed? How to take advantage of it?
In order to avoid traffic-related lag in the gameplay, prediction is needed, i.e. locally running the identical game logic locally, as on the server side. Upfront, with zero lag.
Let’s demonstrate this with the following example.
The client sends an input, then wants to initiate an animation that lasts 100ms. Due to the fact that the client has to wait for a response from the server, the whole action takes 200ms, where the first 100ms the client waits for a response.
In order to eliminate the traffic-related lag, we have implemented the prediction mechanism in the Elympics SDK. This allows the game to run locally at the same time as waiting for acknowledgement of inputs from the server.
This way we can eliminate any multiplayer-related lag in local player movement, leading to the same response time as you get in a single player game. In our example the whole action takes 100 ms less than without the prediction mechanism.
That’s it! 🎉
This however can lead to invalid state locally, which makes it really difficult to debug. Fortunately, Elympics SDK comes with prediction’s best friend – reconciliation!
5 - Reconciliation in multiplayer games
What is reconciliation and how it is implemented in Elympics
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
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.