Sashité for Developers
  1. Sashité for Developers
  2. Specifications
  3. STN
  4. 1.0.0

State Transition Notation (STN) Specification


1. Status of this document

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY are to be interpreted as normative requirements.

Capitalized terms (Position, Board, Square, Hand, Piece, Active Player, Game Protocol, Rule System) are defined in the Glossary and the Game Protocol. This document does not redefine those terms.


2. Overview

State Transition Notation (STN) is a rule-agnostic, JSON-based format for describing state transitions in abstract strategy board games. STN captures the net changes between any two game Positions by recording modifications in Piece Locations, Hand/reserve contents, and Active Player status using standardized CELL coordinates and QPI Piece identification.

STN provides a precise way to represent position deltas without requiring knowledge of how those transitions were achieved. STN is purely a difference format — it describes the observable changes between two complete game Positions, including all aspects that define a Position: Piece Locations, reserve contents, and Active Player identity.


3. Dependencies

STN builds upon two foundational Sashité specifications:

Specification Purpose
CELL Multi-dimensional coordinate encoding for Board positions
QPI Qualified Piece Identifier for unambiguous Piece identification

4. Scope

4.1 What STN defines

STN defines:

4.2 What STN does not define

STN is deliberately format-only. It does not define:

All legality and game-specific semantics belong to Rule Systems, not to STN.


5. Format specification

5.1 JSON structure

An STN object is a JSON object with three optional fields:

{
  "board": {
    "<cell-coordinate>": "<qpi-piece | null>"
  },
  "hands": {
    "<qpi-piece>": <delta>
  },
  "toggle": <boolean>
}

All fields are optional. Each field represents changes to different aspects of the game Position.

5.2 Grammar (EBNF)

stn-object     ::= "{" [ field-list ] "}" ;
field-list     ::= field ( "," field )* ;
field          ::= board-field | hands-field | toggle-field ;

board-field    ::= '"board"' ":" board-object ;
board-object   ::= "{" [ board-entries ] "}" ;
board-entries  ::= board-entry ( "," board-entry )* ;
board-entry    ::= cell-key ":" ( qpi-value | "null" ) ;
cell-key       ::= json-string ;   (* Must conform to CELL specification *)
qpi-value      ::= json-string ;   (* Must conform to QPI specification *)

hands-field    ::= '"hands"' ":" hands-object ;
hands-object   ::= "{" [ hands-entries ] "}" ;
hands-entries  ::= hands-entry ( "," hands-entry )* ;
hands-entry    ::= qpi-key ":" integer-delta ;
qpi-key        ::= json-string ;   (* Must conform to QPI specification *)
integer-delta  ::= json-integer ;  (* Must be non-zero *)

toggle-field   ::= '"toggle"' ":" json-boolean ;

6. Field specifications

6.1 board field

Type: Object Purpose: Records changes to Piece positions on the Board

Maps CELL coordinates to their final state after the transition:

Semantics:

Condition Meaning
Key present, value is QPI Location contains the specified Piece after transition
Key present, value is null Location becomes empty after transition
Key absent Location was not affected by the transition

Example:

{
  "board": {
    "e2": null,
    "e4": "C:P",
    "f3": "S:+N"
  }
}

6.2 hands field

Type: Object Purpose: Records changes to Piece counts in player reserves/Hands

Maps QPI Piece identifiers to net count changes:

Constraints:

Example:

{
  "hands": {
    "S:P": -1,
    "S:B": 1,
    "c:q": 2
  }
}

6.3 toggle field

Type: Boolean Purpose: Indicates whether the Active Player changes during the transition Default: false when omitted

Value Meaning
false (or omitted) The Active Player remains the same after applying the transition
true The Active Player changes after applying the transition

Example:

{
  "board": { "e2": null, "e4": "C:P" },
  "toggle": true
}

7. Semantic interpretation

7.1 Empty object behavior

{}

An empty STN object represents no changes to the Position:

This represents scenarios such as:

7.2 Minimal changes

Board-only change (no turn change):

{
  "board": {
    "e2": null,
    "e4": "C:P"
  }
}

Piece movement with same player remaining active.

Board change with turn change:

{
  "board": {
    "e2": null,
    "e4": "C:P"
  },
  "toggle": true
}

Standard move where turn passes to opponent.

Turn-only change (pass move):

{
  "toggle": true
}

Only the Active Player changes — no Board or Hand modifications.

Hand and Board change (drop):

{
  "hands": {
    "S:P": -1
  },
  "board": {
    "e5": "S:P"
  },
  "toggle": true
}

Piece drop from reserve to Board with turn change.

7.3 Complex transitions

Multi-piece movement (e.g., castling):

{
  "board": {
    "e1": null,
    "g1": "C:K",
    "h1": null,
    "f1": "C:R"
  },
  "toggle": true
}

Capture with state change:

{
  "board": {
    "e7": null,
    "e8": "C:Q",
    "f8": null
  },
  "hands": {
    "c:b": 1
  },
  "toggle": true
}

Cumulative multi-move delta:

{
  "board": {
    "e2": null,
    "e4": "C:P",
    "e7": null,
    "e5": "c:p"
  }
}

Net result of multiple moves with original player still active.


8. Validation rules

8.1 Structural validation

An STN document MUST satisfy:

  1. JSON object — The document MUST be a valid JSON object.
  2. Known fields only — The object MAY contain board, hands, and/or toggle fields.
  3. Correct typesboard MUST be an object, hands MUST be an object, toggle MUST be a boolean.

8.2 Format validation

An STN document MUST satisfy:

  1. Valid CELL keys — Board keys MUST conform to the CELL coordinate specification.
  2. Valid Board values — Board values MUST be valid QPI identifiers or null.
  3. Valid QPI keys — Hand keys MUST conform to the QPI specification.
  4. Non-zero deltas — Hand values MUST be non-zero integers.

8.3 Semantic validation

Semantic validation is application-specific. Implementations MAY validate:


9. Design properties

STN is intended to be:


10. Use cases

10.1 Position comparison

// Compare two positions and generate STN diff
const stn = calculatePositionDiff(positionA, positionB);

10.2 Incremental updates

// Apply STN delta to update position
const newPosition = applySTN(currentPosition, stnDelta);

10.3 Move validation

// Check if proposed changes are valid
const isValid = validateSTN(currentPosition, proposedSTN);

10.4 Undo/Redo systems

// Store STN deltas for reversible operations
const undoSTN = invertSTN(forwardSTN);

11. JSON Schema

A JSON Schema for STN is published for programmatic validation:

Implementations MAY rely on this schema as a baseline validator and add further semantic checks as needed.


12. Examples

See STN Examples for practical implementation guidance and integration patterns.


13. Reference implementations

The following reference libraries are maintained by Sashité and are intended to be idiomatic, fully tested, and spec-accurate implementations of STN v1.0.0.

They generally provide:

If a library behavior appears to conflict with this document, this specification is normative. Please report issues (or propose clarifications) on the relevant repository.


14. License

This specification is made available under the terms of the Open Web Foundation Agreement 1.0 (OWFa 1.0).

The authoritative legal text is the OWF “Final Specification Agreement (OWFa 1.0)”.