Ouroboros: Building a Real-Time Peer-to-Peer Snake Game
Peer-to-peer architectures offer several intriguing advantages over the client-server model, but they also bring challenges. Ouroboros is a real-time, fast-paced, in-browser, peer-to-peer snake game that was created to explore solutions to the challenges of P2P gaming. Peer connections are established over WebRTC, and data is exchanged between peers using an unreliable, UDP-like protocol. To ensure eventual consistency of game state among peers, our game utilizes a state-based, conflict-free replicated data type (CRDT). Users broadcast snapshots of their local state to peers, who incorporate these snapshots into local data structures with a merge function that is idempotent, commutative, and associative. Our fast-but-unreliable transport protocol guarantees neither packet delivery nor packet order, so peer messages necessarily include data redundancy, making our CRDT a variation of a Delta CRDT. We further adapt our CRDT for our use case by purging old data, which can introduce discrepancies across peers but only in data that is no longer relevant to gameplay. Local predictions improve user experience when peer data is missing, but are not incorporated into the canonical game state, allowing fast convergence with minimal computation when predictions and peer data differ.
6:00pm — Event begins with networking and pizza
6:30pm — Talk #1
7:15pm — Talk #2
8:00pm — Beers and drinks nearby (TBD)