Blackjack¶
Blackjack is the most Engine-integrated example. Cards come from the standard
52-card token set, ordered in Stack/Source containers, and hands are Space
zones. The Node game stores Blackjack lifecycle and bankroll data below
doc.blackjack; Engine identity remains separate in doc.agents.
Run it¶
npm install
npm run build
npm run blackjack # compiled terminal game
npm run blackjack:server # multiplayer host, terminal 1
npm run blackjack:client # join from another terminal
For the browser implementation:
cd examples/blackjack
node web/build.js
python3 -m http.server 8000 --directory web
Open http://localhost:8000. The browser client is self-contained and bundled;
it is not the same CRDT-backed implementation as game.js.
What is implemented¶
The Node game supports seeded shuffles, betting, double down, split and re-split,
insurance, early/late surrender, American and European dealing, side-bet helpers,
and multi-agent tables. The multi-agent flow uses game:loopStart,
game:setActiveAgent, and game:loopStop; ordinary Blackjack methods compose
Stack/Space operations directly and are asynchronous.
Use await game._ready before reading a newly created game, and await setBet,
deal, hit, stand, and the other mutators. A fixed seed makes the Node
shuffle reproducible. The betting and side-bet modules are presentation/domain
helpers; they do not themselves write CRDT state.
Architecture caveats¶
Card movements and lifecycle/resource commits are separate CRDT changes. A successful lifecycle patch does not make Stack/Space operations one transaction. Dispatch is not rollback-safe after a handler has already mutated state, so game code validates before writing. Network play uses the relay and shared Chronicle sync; the relay is transport, not a trusted casino authority. Do not treat this example as a regulated gambling system or as proof that a client cannot cheat.