Documentation Index
Fetch the complete documentation index at: https://openturn.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
@openturn/gamekit is a sugar layer over @openturn/core. You author phases and moves; gamekit compiles them into core states and transitions. The output is a normal GameDefinition<...>, so everything downstream (replay, inspector, hosted runtime) treats a gamekit game exactly like a hand-authored core game.
Use gamekit when your game has a natural “a player picks one of a few things to do on their turn” shape. Drop to core when the state graph is the interesting part.
The authoring surface
setupreturns a plain stateG. Gamekit wraps it with internal bookkeeping (see “wrapping core” below); you never touch the wrapper.phasesare named high-level steps (planning, bidding, play). Each compiles to a core state.movesis the only place logic lives. Each move declares its args, optional permissions, optional phase gate, and arunfunction.viewsis identical to core:publicandplayerprojectGinto JSON.
Moves
A move is a pure function from(G, args, player, turn, phase, computed) to an outcome:
stay, endTurn, goto, finish, invalid).
Turn gating
With a round-robinturn policy, only the current player is in the engine’s activePlayers set, and core’s dispatch gate handles “wrong seat” rejections automatically. When more than one seat is allowed in a phase (simultaneous play, plugins) or you need a state-dependent rule, enforce it inline in run and reject with a reason:
Views and computed
Computed values are selectors under a friendlier name. You read them asC inside moves and views. Use them to avoid recomputing derived facts in every code path.
See gamekit views and computed.
Wrapping core
Gamekit wrapsG in an internal __gamekit field to track whether the game ended with a result. The wrapper is invisible: your move run receives G without __gamekit, and your views never see it. If you ever need to read it (you probably do not), snapshot.meta.result carries the same data.
If gamekit cannot express what you need, drop through to core transitions with the core field:
Randomness
Every move context hasrng: DeterministicRng from @openturn/core. Use it for all randomness, never Math.random(). See how-to: handle randomness.
What to read next
- Gamekit moves and outcomes is the outcome cheatsheet.
- Gamekit turn gating covers turn-gating patterns.
- Gamekit views and computed covers projection and derivation.