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

STN Examples


Overview

This document provides comprehensive examples of STN (State Transition Notation) usage across various game types and transition scenarios. These examples illustrate practical applications of the STN specification while remaining rule-agnostic.

Note: All examples are for illustration purposes only. STN does not define or assume any game-specific rules, movement patterns, or win conditions.


Basic Examples

No Changes

{}

Interpretation:

This represents scenarios such as position comparisons yielding identical results, null transformations, or baseline states.

Pass Move (Turn-Only Change)

{
  "toggle": true
}

Interpretation:

This represents pass moves, forfeit turns, or any transition where only the turn changes.

Simple Movement (No Turn Change)

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

Interpretation:

Simple Movement (With Turn Change)

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

Interpretation:


Hand/Reserve Examples

Drop from Reserve (No Turn Change)

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

Interpretation:

Drop from Reserve (With Turn Change)

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

Interpretation:

Capture to Reserve

{
  "board": {
    "b1": "S:S",
    "c2": null
  },
  "hands": {
    "S:B": 1
  },
  "toggle": true
}

Interpretation:


Complex Movement Examples

Castling

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

Interpretation:

En Passant

{
  "board": {
    "e5": null,
    "f6": "C:P",
    "f5": null
  },
  "hands": {
    "c:p": 1
  },
  "toggle": true
}

Interpretation:

Promotion with Capture

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

Interpretation:


Multi-Dimensional Examples

3D Movement

{
  "board": {
    "e2A": null,
    "f3B": "R:B"
  },
  "toggle": true
}

Interpretation:


Turn Management Examples

Multiple Moves (Same Player Active)

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

Interpretation:

Multiple Moves (Different Player Active)

{
  "board": {
    "e2": null,
    "e4": "C:P",
    "e7": null,
    "e5": "c:p",
    "f1": null,
    "d3": "C:B"
  },
  "toggle": true
}

Interpretation:


Complex Scenarios

Piece Exchange (No Turn Change)

{
  "board": {
    "a1": "S:S",
    "b2": "S:L",
    "c3": null
  },
  "hands": {
    "s:g": 1,
    "S:G": -1
  }
}

Interpretation:

Multi-Location Drop Pattern

{
  "board": {
    "e5": "S:P",
    "f5": "S:P",
    "g5": "S:P"
  },
  "hands": {
    "S:P": -3
  },
  "toggle": true
}

Interpretation:


State Transition Patterns

Incremental Position Building

Step 1 - Initial move:

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

Step 2 - Response move:

{
  "board": {
    "e7": null,
    "e5": "c:p"
  },
  "toggle": true
}

Cumulative result (from initial position):

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

Position Comparison

Position A: Standard opening Position B: After player development

STN diff (A → B):

{
  "board": {
    "e2": null,
    "e4": "C:P",
    "g1": null,
    "f3": "C:N",
    "f1": null,
    "c4": "C:B"
  }
}

This shows the net development without indicating turn sequence.


Integration with FEEN

Standard Chess Example

Given the initial Western Chess position:

+rnbq+kbn+r/+p+p+p+p+p+p+p+p/8/8/8/8/+P+P+P+P+P+P+P+P/+RNBQ+KBN+R / C/c

After the first move (e2-e4):

+rnbq+kbn+r/+p+p+p+p+p+p+p+p/8/8/4P3/8/+P+P+P+P1+P+P+P/+RNBQ+KBN+R / c/C

STN representation:

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

After the second move (e7-e5):

+rnbq+kbn+r/+p+p+p+p1+p+p+p/8/4p3/4P3/8/+P+P+P+P1+P+P+P/+RNBQ+KBN+R / C/c

STN representation (cumulative from initial):

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

Note: toggle: false (default) because after two moves, we’re back to the original active player.

Shogi Drop Example

Before drop:

+l+n+s+g+k+g+s+n+l/1+r5+b1/+p+p+p+p+p+p+p+p+p/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL / S/s

After pawn drop to 5e:

+l+n+s+g+k+g+s+n+l/1+r5+b1/+p+p+p+p+p+p+p+p+p/9/4P4/9/PPPP1PPPP/1B5R1/LNSGKGSNL / s/S

STN representation:

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

Understanding STN Semantics

What STN Represents

What STN Does NOT Represent

Toggle Semantics


Best Practices

When to Use STN

Position comparison:

// Calculate difference between two positions
const stn = diffPositions(positionA, positionB);

Move validation:

// Check if proposed change is valid
if (isValidTransition(currentPosition, proposedSTN)) {
  applySTN(currentPosition, proposedSTN);
}

Undo/redo systems:

// Store reversible changes
const undoSTN = invertSTN(forwardSTN);
historyStack.push(undoSTN);

Network synchronization:

// Send only what changed
sendToClients(stnDelta);

Optimization Patterns

Minimal representation: Only include changed locations/pieces

// Good - only changed elements
{
  "board": { "e2": null, "e4": "C:P" },
  "toggle": true
}

// Avoid - unnecessary elements
{
  "board": { "e2": null, "e4": "C:P", "a1": "C:R" },
  "toggle": true
}

Batch changes: Combine related modifications

// Efficient - combined castling
{
  "board": {
    "e1": null, "g1": "C:K",
    "h1": null, "f1": "C:R"
  },
  "toggle": true
}

Toggle optimization: Use default behavior when possible

// Good - implicit toggle: false
{
  "board": { "e2": null, "e4": "C:P" }
}

// Unnecessary - explicit false
{
  "board": { "e2": null, "e4": "C:P" },
  "toggle": false
}

Common Pitfalls

Forgetting explicit toggle: Remember pass moves need toggle: true

// Wrong - this means no changes at all
{}

// Correct - pass move
{"toggle": true}

Zero hand deltas: Hand values must be non-zero

// Wrong
{
  "hands": { "S:P": 0 }
}

// Correct - omit unchanged hands
{}

Incomplete position tracking: Ensure all aspects are captured

// Consider all position components:
// - Board state
// - Hand/reserve contents
// - Active player status

Invalid QPI consistency: Use consistent piece identification

// Ensure QPI format compliance
{
  "board": { "e4": "C:P" },  // Valid QPI
  "hands": { "c:p": 1 }      // Consistent case
}