Skip to content

Cuttle

Cuttle is a strategic card-combat example: players race to 21 points while playing point cards, permanents, one-offs, counters, and scuttles. The canonical rules live in the framework-agnostic examples/cuttle/CuttleGame.ts, whose state is a plain mutable object and whose public interface includes getValidActions(player) and getObservation(player).

Run it

npm run cuttle
node --loader ./test/ts-esm-loader.js examples/cuttle/cli.js --variant standard
node --loader ./test/ts-esm-loader.js examples/cuttle/cli.js --variant cutthroat

npm run cuttle:server       # authoritative room server
npm run cuttle:client       # create a room; copy the printed code
npm run cuttle:client -- ws://localhost:8080 ROOM-CODE

For the browser UI, serve examples/cuttle/web/ with a static server. For online rooms, proxy the browser's same-origin /ws endpoint to the authoritative room server. For AI play, use the classic MCP adapter or the CuttleAEC environment.

The former private two-way CRDT mode is unavailable. Its npm scripts were removed, and direct execution of examples/cuttle/crdt-client.ts fails closed before Engine, relay, or E2E setup. CRDT_SYNC_SCOPE.md and the retained CRDT helpers document the disabled design for source-level review only.

Supported integration modes

The local CLI calls CuttleGame.action(player, command) after checking the valid-action list. The authoritative CuttleRoomServer serializes room dispatches and binds each seat to a live WebSocket connection, not an ID supplied by the client. The terminal and browser clients use that authoritative path. Leaving or disconnecting makes the seat available to a new joiner; there are no account-based seat reservations. Client commands can make normal moves but cannot run administrative actions. The room server uses cryptographic randomness for shuffling.

Room snapshots expose the public board and scrap pile, deck and hand counts, and a public move log. Players receive their own hand and legal actions. Glasses Eights reveal hands only to the player entitled to see them, and cards inspected by a Seven are sent only to the player resolving it. Spectators get no private hands or legal actions. The server does not send deck order, other players' connection IDs, or raw engine action history. Public play can still reveal information indirectly (for example, a card returned to hand from the board is already known).

Variants and tests

Classic is the two-player default. Standard changes several card effects; cutthroat adds three-player rules and Jokers. Relevant checks for authoritative privacy, the retained CRDT helpers, and Cuttle rules are:

npm run test:cuttle:sync
npm run test:cuttle:crypto
npm run test:cuttle:hardening
npm run test:cuttle:privacy