Skip to content

Mechanism reference

The ./engine package is a set of deterministic, product-neutral building blocks for turn-based grid games. Each page in this section describes one mechanism family: the state it expects, the ordering it guarantees, the policy the product must inject, and the edge cases an integration should test.

Every mechanism page also ends with a Zonoid example. Zonoid is the first production consumer of this engine: its universal grid reducer supplies the board, characters, abilities, authored levels, and presentation policy while the SDK supplies the deterministic algorithm.

How the pieces fit together

text
submitted action

    ├─ reducer validates product rules

    ├─ simultaneous movement / push / transport proposal

    └─ settlement waves
          ├─ arrival rules
          ├─ resource claims
          ├─ gates and triggers
          ├─ projectiles, rays, and chain reactions
          └─ linked-state interlocks

                 └─ stable turn view, score, transcript

The SDK does not prescribe that exact pipeline. A product composes only the mechanisms it needs and explicitly schedules their causal relationships through the settlement kernel.

Pages

FamilyWhat the SDK guarantees
Grid modelCoordinates, action shapes, observations, and the reducer boundary
Simultaneous movementCollision, priority, footprints, chains, rotations, and swaps
Geometry and FOVCardinal paths, nearest reachable cells, lines, sight, and cones
Turn settlementMulti-wave consequence scheduling, duplicate policy, traces, and limits
Chain reactionsBreadth-first, once-per-identity propagation
Projectiles and flightSnapshot-safe microsteps and bounded full-flight passes
Push chainsMutation-free planning and safe commit order
Arrival rulesStable dispatch of tile-entry effects
Resource claimsNeutral all-fail arbitration for contested resources
Resource transactionsProduct-defined balances and atomic requirements/effects
GatesLatching and occupancy-safe automatic transitions
Latched triggersAuthored-order, one-shot conditions and effects
RaysOrdered traversal with explicit stop or exhaustion
Behavior treesProduct-schema-neutral selectors, conditions, and leaves
Transport and interlocksDirected proposals, repeated passes, linked components, and stabilization
Deterministic randomnessSeeded streams, event-keyed rolls, and permutations
Scoring and budgetsThreshold scoring, failure precedence, and threshold suggestions
SolverBreadth-first minimum-action search over an injected reducer
Replay verificationTranscript permutation checks and deterministic re-simulation

Product integration showcases

These focused boards show how Zonoid composes several SDK mechanisms into player-facing interactions while retaining the normal game UI.

Simultaneous movement

Multiple rival NPCs and the player resolve their movement together from the same turn snapshot.

NPC conversation

The player starts a conversation and selects a dialogue response through Zonoid’s normal interaction UI.

Rival battle

The player and a rival exchange actions in a focused battle board with health and equipment visible.

Shared conventions

  • Stable identities are data. Entity, job, trigger, claim, and rule ids must be stable across replay.
  • Lower priority values run first. Where priorities tie, the documented stable input or id order decides the result.
  • Bounds are authored. Maximum steps, passes, reactions, nodes, and cycles are safety limits supplied by the product; they are not balance rules chosen by the SDK.
  • Callbacks own meaning. Tokens, terrain, damage, abilities, objectives, animation events, and persistence stay in the product.
  • Determinism includes ordering. Do not feed unordered database results or locale-dependent comparisons into a mechanism without normalizing them.

Import all mechanisms from the dedicated subpath:

ts
import {
  resolveMoves,
  runSettlementCascade,
  shortestGridPath,
} from '@yugao-gaos/turn-based-grid-sdk/engine';

Reusable mechanics in the toolkit. Product content stays in the product.