Selectors and views are the read side of an openturn game. They never mutateDocumentation Index
Fetch the complete documentation index at: https://openturn.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
G. They compute pure projections the engine re-evaluates after every transition.
Use them aggressively. Any fact you can derive from G should live here, not in G.
Selectors
Selectors are named, JSON-valued computations over the current snapshot. Core declares them asselectors; gamekit surfaces them as computed:
snapshot.derived.selectors and exposes them to views, permissions (gamekit), and inspector.
Selectors must return JsonValue and must not close over mutable outside state.
Public views
views.public is the redacted shape any observer can see. It is the default view for spectators, CLIs, and replay viewers. Anything you did not want to hide from the other players belongs here.
views.public, the engine uses G directly. Always define it when any part of G is secret.
Player views
views.player is called once per player per snapshot. Return what that seat should see. Hidden information (opponent cards, secret fleets, private scores) is filtered here.
Don’t cache views in G
It is tempting to compute a view once and store it inG so you can read it everywhere. Resist. G is the source of truth; views are projections. Caching a projection in G creates two representations of the same fact and the engine can only guarantee one of them. Keep G minimal and let the engine re-run your views.
What to read next
- Authoritative state and snapshots for the rule on what lives in
G. - How-to: model hidden information is the practical recipe with battleship.