12.07.2015 Views

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.4.3 Object Synchronization and <strong>Game</strong> Logic ExecutionAs any real (and not completely simplistic) computer game has objects <strong>with</strong> associated state that canbe manipulated, there is obviously the need for supporting them in massively multiplayer online games.The challenge in distributed multiplayer games is <strong>to</strong> synchronize the objects so that each player has a(sufficiently) consistent view and all his actions on these objects have the expected consequences. Thisis particularly difficult <strong>to</strong> achieve when two players manipulate an object concurrently. <strong>Game</strong> objects arebasically everything in the game world that is not directly related <strong>to</strong> a single player and that is not part<strong>of</strong> the immutable terrain.Immutable parts <strong>of</strong> the game are usually installed (and if necessary updated) <strong>to</strong>gether <strong>with</strong> the gameand do not require any synchronization; all participants agree based on identical data. The player’savatar (typically including its properties and direct belongings) is treated separately and not the sameway as other game objects because it constantly belongs <strong>to</strong> one player (and thus one node in the network)and is always controlled from there. Each avatar has a dedicated node (i.e., the corresponding player’snode) that is naturally responsible for serializing all operations.Some types <strong>of</strong> objects, most commonly any type <strong>of</strong> NPC (non-player character), have think functionsassociated that (regularly) execute some piece <strong>of</strong> code which au<strong>to</strong>matically makes these take some action,for instance moving around in the game world. But the think functions may also be much simpler,possibly just causing some slow resource regeneration. These functions must be executed somewhere;the decision on which node(s) a particular think function is <strong>to</strong> be executed is closely related <strong>to</strong> thedecision whose nodes are responsible for managing object modifications.Basically, it has <strong>to</strong> be decided which consistency mechanisms are <strong>to</strong> be applied <strong>to</strong> the objects. Pessimisticmodels (e.g., locking objects for modification) is not feasible for distributed realtime gamesmostly <strong>of</strong> two reasons. First, in realtime games, it is not possible <strong>to</strong> wait possibly several seconds whenevermodifying an object. And second, as the system consists <strong>of</strong> unreliable nodes connected over theInternet, locks may not be correctly released in some cases. Necessary timeouts would cause even morewaiting for object manipulation or just reading the current state.Thus, there is the need for optimistic consistency. In most cases it is not necessary <strong>to</strong> have strict consistency,but the game logic must then be prepared for handling some inconsistency properly. Colyseushas an optimistic consistency model in which all updates are tentative until approved by the node responsiblefor the primary copy. The responsible node serializes all modifications and rejects conflictingchanges. Of course, <strong>with</strong> Internet-typical latencies, the player will eventually notice when an object thathe manipulated is reverted after a few seconds. The game logic will not always be able <strong>to</strong> compensateand hide these effects from the player.The common approach for object consistency is <strong>to</strong> serialize changes on one node that is chosen <strong>to</strong>be the owner <strong>of</strong> the particular object. In SimMud there is a coordina<strong>to</strong>r node for each object, andColyseus has nodes holding the primary copy which is the reference object, i.e., everyone eventually has<strong>to</strong> synchronize <strong>to</strong> that object. This approach makes the serialization relatively easy as it is done locally onone node. But it also entails a reliability issue, since a failure <strong>of</strong> the one node responsible for a particularobject will result in a loss <strong>of</strong> its state.Data loss can be prevented by having certain nodes keeping backup copies that are always synchronized<strong>with</strong> the primary copy. Ideally, one <strong>of</strong> the nodes holding a backup copy can immediately take overwhen the failure <strong>of</strong> the node holding the primary copy is detected.One approach <strong>of</strong> selecting the nodes responsible for a particular object is based on regions. Eachregion has one coordina<strong>to</strong>r node who is responsible for all objects in that region. Another possibility is <strong>to</strong>have one coordina<strong>to</strong>r for all objects <strong>of</strong> a particular type. Better load balancing is achieved by assigningan ID <strong>to</strong> each object and giving each node the responsibility for a certain range.All approaches that cover game object management use a DHT for manging responsibilities. AlthoughDHTs have the previously described weaknesses, especially concerning latencies, they appear <strong>to</strong> be themost feasible solution so far. Timing concerns can be answered by pre-fetching object copies before they30 2.4 Design Space for <strong>Peer</strong>-<strong>to</strong>-<strong>Peer</strong> <strong>Game</strong>s

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!