Expand description
§Qi — a position model for two-player board games
Qi is an immutable, format-agnostic model of a board-game position as
defined by the Sashité Game Protocol.
A position encodes exactly four things: a board of squares, two hands
of off-board pieces, a style per player, and the turn.
§Generic over pieces and styles
Pieces and styles are type parameters, so Qi is independent of any
notation: the caller chooses how a piece and a style are represented (a typed
identifier, an interned id, a string, …). The Sashité notation crates plug in
their own token types; nothing here depends on them.
§Immutable, move-based transformations
Transformations consume the position and return a new one, so they chain like the protocol’s value semantics while moving — not cloning — the underlying storage. Clone a position explicitly to keep a snapshot.
§Bounded by construction
Every board is bounded — at most MAX_DIMENSIONS dimensions, each at most
MAX_DIMENSION_SIZE, at most MAX_SQUARE_COUNT squares — and the piece
count can never exceed the square count. These invariants are checked when a
position is built or transformed, so a Qi is safe to construct from
untrusted input.
§Guarantees
no_std. The crate links onlycoreandalloc.- No
unsafe. Built under a forbid-unsafelint policy. - No required dependencies.
serdeis an optional, off-by-default add-on.
Structs§
- Qi
- An immutable position: a board, two hands, a style per player, and the turn.
Enums§
- Error
- An error from constructing or transforming a
Qiposition. - Player
- Which of the two players is to move.
Constants§
- MAX_
DIMENSIONS - Maximum number of board dimensions (1D, 2D, or 3D).
- MAX_
DIMENSION_ SIZE - Maximum size of any single dimension.
- MAX_
SQUARE_ COUNT - Maximum total number of squares on a board.