Vladimir Sedach

Have Emacs - Will Hack

March 4, 2009

Peer-to-peer synchronized simulations

Topic: Distributed systems

I recently came across a 2001 article describing the multiplayer system of Age of Empires.

Age of Empires multiplayer is a peer-to-peer simulation where input from each player in the form of commands is synchronized across all nodes in discrete "game turn" steps, whose real-time duration is calculated as a function of latency between the nodes and the framerate at which the nodes can render the simulation.

It is interesting to compare the Age of Empires system to that of Croquet (I blogged about Croquet before). Like Age of Empires, Croquet is a peer-to-peer system. The TeaTime architecture behind Croquet can be thought of as a distributed object simulation where messages between objects are what gets synchronized across nodes.

Where Croquet and the Age of Empires multiplayer system differ is in how time and synchronization is handled. TeaTime extends Reed's multi-version timestamping with the notion of pseudo-real time and uses that notion to enable deadline-based scheduling for message processing, with synchronization being achieved via two-phase commit. This allows the decoupling of simulation rendering speed from message synchronization. Unlike the Age of Empires system, this approach is unaccomodating to high-latency nodes.

One thing I found interesing about the Age of Empires article is the large number of synchronization bugs (a lot of them relating to pseudorandom number generation) that the developers encountered.