Multiplayer games have become increasingly popular; instead of beating an AI opponent, a player must confront strategies decided by human being. One way to implement multiplayer games over a network is by using a peer to peer games (P2P) approach.
A multiplayer game played over a P2P network can be implemented through different approaches that can be categorized into two groups: authoritative and non-authoritative.
In the authoritative approach, the most common method is to use a client-server architecture. This is where a central entity (the authoritative server) controls the game and each client that is connected to this server receives a constant update of game data which is then used on a local computer to represent the game state.
This means that when a client performs an action in the game, such as moving from one position to another, the information is sent to the authoritative server. The server then verifies whether the information is correct in terms of the game parameters and, if so, updates the game state. This information is then propagated to all the other clients, so that the game state is updated for all players.
In the non-authoritative approach, there is no central server and each peer (game player) controls their own game state. In a P2P approach, each peer must send data to all the other peers and also receive data from them in order to update the game state. Controls must be in place to ensure that the information sent is reliable and correct otherwise it becomes easy to cheat. The important element of this implementation is the communication between users and the synchronization of all peer states.
The authoritative approach is less prone to cheating, because the server controls the entire game state and can test moves against game rules, such as a player claiming to have moved 200 pixels only 10 are allowed.
Because a non-authoritative multiplayer game has no central server to control the game state, every peer must control its own game state. This means that the peer must update any changes and important actions to all the other players. This can mean that the player sees two scenarios simultaneously: both his ship moving according to his commands as well as a simulation of all the other player’s ships controlled by his opponents. These messages can take time to propagate over the network from one computer to another and this is why P2P network games are hard to implement and less often used today.