Skip to main content

Crate sashite_qi

Crate sashite_qi 

Source
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 only core and alloc.
  • No unsafe. Built under a forbid-unsafe lint policy.
  • No required dependencies. serde is 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 Qi position.
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.