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/cliandexamples/games/pig-dice/clipackages).
Minimal CLI
cli/package.json (excerpt)
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:
AI player sketch
An AI driver is a loop that readssession.getState(), picks an event, and calls applyEvent:
Related
- How-to: run a local session is the primitive this recipe builds on.
- How-to: capture replays for recording the action log.