This tutorial rewrites tic-tac-toe at the core level: noDocumentation Index
Fetch the complete documentation index at: https://openturn.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
moves, no phases, no turn.roundRobin(). Just explicit states, events, and transitions. You reach for this when you want full control over the state graph — for debugging, for tooling, or for games whose progression does not fit the move-first shape.
Reference code: examples/using-core/tic-tac-toe-core.
What changes from gamekit
Gamekit generates transitions from moves, phases, and outcomes. Core makes them explicit:- Instead of
moves, you declareeventsandtransitions. - Instead of phases, you declare
states, each with its ownactivePlayers,label, andcontrol. - Instead of
turn.roundRobin(), you compute the current player fromposition.turnand the roster. - Instead of outcomes like
move.finish({ winner }), you return{ G, result, turn }from the matching transition branch.
The game definition
Read the transition branches
There are three branches, onefrom: "play" for each outcome:
place_mark_to_won: the move creates a three-in-a-row. Returns{ G, result: { winner } }.place_mark_to_drawn: the move fills the board without a winner.place_mark_continue: the move is legal and the game continues.
placeMark, getWinner, isBoardFull) but returns a match only when its specific shape applies. Exactly one branch matches any given dispatch. The engine raises ambiguous_transition if that invariant ever breaks.
Factor shared work into helpers (placeMark, getWinner, isBoardFull), not into the branches themselves.
Compare to gamekit
In the gamekit version, all three branches are expressed by a singlemove.run:
from/to branches for you. The runtime behavior is the same. The core version is useful when you want:
- More than one
eventname (gamekit has one event per move, named after the move). - States that do not correspond to gamekit phases (e.g. a “waiting for reconnect” state).
- Explicit
from/topairs for custom graph visualization. - The
controlandmetadatahooks on states for tooling.
What to read next
- How-to: author with core is the recipe version.
- Concepts: reducers and queued events goes deeper on labelled branches.
- Tutorial: tic-tac-toe with gamekit is the gamekit counterpart.