---
url: /demos/territory-wars.md
description: Multiplayer territory capture game built with Yjs CRDTs on Durable Streams.
---

# Territory Wars

Multiplayer territory capture game built with [Yjs](https://yjs.dev) CRDTs on [Durable Streams](/primitives/durable-streams). Read the [blog post](/blog/2026/04/07/yjs-durable-streams-on-electric-cloud) for more details.

## How it works

Built with [`y-durable-streams`](https://www.npmjs.com/package/@durable-streams/y-durable-streams) on [Durable Streams](/primitives/durable-streams). Game state is managed via [StreamDB](/blog/2026/03/26/stream-db). The game board is a Yjs Y.Map where each cell is a last-writer-wins register. Players move to claim cells and enclose territory. Player presence is tracked via ephemeral awareness streams with built-in TTL that garbage-collects stale state from disconnected players.
