2026.10.02 · 3 min read
Put the rules in a package with no dependencies.
How 4-Man Chess validates a move in the browser and on the server with the same code.
Chess for three or four players breaks assumptions that ordinary chess code makes without saying so: whose turn is next, what counts as check, what happens when a player is eliminated.
So the rules live in one pure TypeScript package with no runtime dependencies. The web client imports it to show legal moves. The game server imports it to decide whether a move is allowed. They cannot disagree because they are the same code.
The server stays authoritative. The client's copy is only for responsiveness. If they ever diverge, the server wins and the client resyncs.