Skip to main content
Because createLocalSession is just a reducer with a subscribe, you can drive it from a Bun script, a Node process, or any environment that can do stdin. This is useful for:
  • Rapid prototyping of game rules before you build a UI.
  • Smoke tests and AI players.
  • Keeping a CLI variant alongside your React app (see the examples/games/tic-tac-toe/cli and examples/games/pig-dice/cli packages).

Minimal CLI

cli/package.json (excerpt)

Mark the package openturn.runtime: "bun" so the runtime checker knows you are allowed to use Node builtins and Bun globals.

Capture a replay from the CLI

Pair the CLI with @openturn/replay to record matches:
See how-to: capture replays.

AI player sketch

An AI driver is a loop that reads session.getState(), picks an event, and calls applyEvent:
Because the reducer is deterministic, fixing the RNG seed and action order makes AI evaluation reproducible.