← All notesNotes from the bench / Side projects

A word game became a systems problem

How a simple letter-changing game turned into real-time multiplayer engineering.

· 2 min read

Word Duel started with a small idea: change one letter of a word, make another valid word, and keep going. TALK becomes WALK, then WALL. It doesn’t take much explaining. Building it so two people can compete fairly is a different problem.

The browser isn’t the referee

The interface uses Vite and vanilla JavaScript; the backend runs on Cloudflare Workers, with each game room held in its own Durable Object. The server decides whether a move is valid. The browser can display a countdown and let a player edit tiles, but it doesn’t get to decide whose turn it is or whether a late move should count.

A room applies one action at a time, then pushes the new state to both players over WebSockets. That matters when players act at almost the same time, a deadline expires, or a request is retried.

A word can’t just be valid

It has to be the right length, change exactly the configured number of letters in place, and not have been used before. The shared set of used words persists across rounds and rematches. The rules are simple; reliably enforcing them is the interesting part.

The computer plays the same game

The bot occupies a player seat and plays through the same server-side engine. Difficulty changes think time and move strategy, not the rules of validation.

All the little edges

Turn deadlines are defined by the server, and each room sets an alarm for the next one. The same alarm closes idle connections and clears out old rooms. Match results are recorded with receipts so retries don’t create extra wins. Definitions come from a static WordNet-backed word dataset.

The lesson wasn’t really about words. It was how quickly a tiny interaction becomes a problem of shared state, fairness and handling failure.

Play the game ↗