← All guides

Game reference

What a Senet game is made of, what the platform calls, and what it hands back. For a step-by-step walkthrough, read Make Your Own Game. This page is the reference: the contracts, the limits, and the conventions the reference games follow.

A game is two kinds of code:

  • Logic (logic.ts): pure functions plus a declarative MANIFEST. It runs on the server, which enforces the rules. The browser’s game frame also runs it, for UIs (sdk.logic) and for replays.
  • UI modules (ui/{module}/main.ts): render the state a viewer is allowed to see and emit moves. They run in a sandboxed iframe.

Both are TypeScript or JavaScript. States and moves are strings, defined by the game.

Project layout

logic.ts                         rules + MANIFEST (required)
about.md                         the game page's description (Markdown)
ui/{module}/main.ts              a UI module; `ui/default/` by convention
ui/{module}/{skin}.css           its skins; the file name is the skin's identity
ui/{module}/assets/…             files only that module uses (sdk.asset(path))
asset-packs/{axis}/{pack}/…      files shared by modules, one pack per axis (sdk.asset(axis, path))
i18n/{locale}.json               UI translations (sdk.t)
cover.json                       the game's cover: a position, on its page and cards (Create cover)

UI modules and skins are discovered from disk, not declared: a directory under ui/ with a main.ts (or main.js) is a module, and each .css file next to it is a skin. Never name a skin default.css. The skin’s identity is its file name, and which skin is the default is the MANIFEST’s choice.

The cover is cover.json at the project’s root: a position of the game, shown on its page, its catalog card and the home page. It’s drawn there by your UI module, in its frame, with the reader’s theme and light or dark mode, so it always matches the page. The editor’s Create cover makes it: it opens a test match with you in every seat, and Use this position saves the board as it is, from the side shown (any test match of your working copy offers the same as Use as cover): {"state": …, "seat": …}, the state as that seat sees it (getPlayerState), so a game with hidden information shows only what that seat sees. Your UI gets it as any board: mount with that state, then setSeat, with :root[data-player-bars] set (it may leave out its own turn line); it takes no moves. setStatus and setResult aren’t called, and setLastMove gets null, so draw the position in mount itself. In the editor, cover.json has Write (its text, to edit by hand) and Preview (the cover drawn). It’s reviewed with the rest of a submission. A game without one is shown at its starting position: your UI gets what newGame (then startGame) returns with the default settings, as the spectator sees it (getPlayerState with null), with seat null. It’s computed in the reader’s browser, so a start your game draws at random is a new one each time.

Asset files may be .svg .png .jpg .jpeg .gif .webp .woff .woff2 .ttf .eot .js .css .txt. The editor uploads up to 20 files at a time, 2 MB each. A .txt file is how a pack carries its LICENSE.txt. Only assets you’re allowed to redistribute belong here.

Logic: the environment

logic.ts is loaded from its source into a locked-down worker:

  • Self-contained. It can’t import anything: no relative imports, no https:/npm:/jsr: modules, no Node built-ins.
  • No I/O. No timers (setTimeout and friends), no Deno.*, no storage, no network. Every SDK function is synchronous.
  • Frozen built-ins. Array.prototype, JSON, Math and the rest are frozen, so patching them throws. Your module’s exports are frozen too.
  • Pure. Everything a function needs is in its arguments. Calls are spread across a pool of workers, and a module can be reloaded at any time, so state kept in module-level variables between calls is unreliable. Module-level constants are fine.
  • Deterministic. Given the same arguments and the same senet.random results, a function must return the same answer. Replays, the waiting room’s preview and hidden-information detection all re-run your code and compare its output. Draw randomness only through senet.random (see Randomness below). Math.random works, but its values aren’t recorded, so a replay comes out different.
  • Runs in two places. It runs on the server (Deno) and in the browser frame (transpiled to logic.js). Don’t use APIs specific to either one: no DOM, no Deno.

A thrown Error is how logic refuses something. The message is shown to the player for a refused move.

Each call has 5 seconds. A whole-match replay has 10 seconds.

MANIFEST

MANIFEST is the single source of a game’s declarative metadata. Export it with an accessor:

export const MANIFEST = { … };
export function getManifest() { return MANIFEST; }
Field Type Meaning
title string Catalog name. Copied into the database when a version is approved.
description string Short pitch shown in the catalog and on the game page.
players string[] Role names in seat order, one seat per role. Seat N plays players[N-1]. Every player argument the platform passes is one of these.
minPlayers / maxPlayers number How many seats must be filled before the match can start (capped at the number of roles).
tags string[] Catalog tags: lowercase letters, digits and single hyphens, up to 50 characters each, at most 20. Invalid names are dropped. A game with variantOf also gets {parent}-variant (on top of the 20; left out when it would be longer than 50 characters). The catalog shows them on the game’s card and page and filters by them. The {parent}-variant tag comes from variantOf whether or not the parent is on this server, while the game page’s Variant of link needs the parent present.
variantOf string The slug of the game this is a variant of. Create a Variant writes it. Only a slug naming another game on the server is honored.
moveNotation / stateNotation string Names of your move and state grammars, e.g. "algebraic", "compact", "json". Use generic names, not ones prefixed with the game’s name.
params ParamDescriptor[] Per-match settings (see Params below).
appearance object Presets and the asset packs each module supports (see Appearance below).
libs {name: version} Platform JavaScript libraries the UI imports (see Platform libraries below).
defaultLocale string The locale whose i18n/{locale}.json the UI gets.
defaultUi {module, skin} Legacy: use appearance presets. Still honored, and wins over appearance when present.

The platform reads MANIFEST by calling getManifest() in the worker. Validate in the editor checks that players can be read and that params is valid (see Params), then runs the required functions once on a new game (see the tutorial’s Step 4). A missing or unreadable MANIFEST leaves the game without roles, and it can’t be played.

Params

Each descriptor is {key, label, type, default, …}:

type Extra fields What the game gets
boolean true / false
select options: [{value, label}] One of the options’ values (strings); an unknown value becomes default
number min, max A number clamped to [min, max]; unparsable input becomes default
string Trimmed text; empty becomes default

A valid descriptor:

  • is an object with a string key, used by no other descriptor;
  • has a type from the table and a string label;
  • has a default, if any, that is a plain value (a string, number or boolean, not an object or a list) and fits the type: true/false for a boolean, a number for a number, a string for a string, one of the options’ values for a select;
  • for a select, has options as a list of {value, label} whose values are strings ({value: "8", label: "8×8"}, not {value: 8}) and whose labels are plain values;
  • for a number, has min and max, if any, as numbers;
  • has enabledWhen, if any, naming another param’s key.

Validate in the editor reports every descriptor that isn’t valid, by position and key (params[1] (`size`): …). Test, Create cover, Submit and the play page’s New test refuse such a game until it’s fixed. A published game whose params aren’t valid can’t start a match, however it’s started: its page says its settings are invalid.

enabledWhen: {key, value} makes a param apply only while another param has that value. The two are compared as text. The form disables it otherwise, and the game then gets null for it. Use a “Random / Choose” select plus a dependent number instead of a magic value such as -1 meaning random:

params: [
  { key: "start", label: "Starting position", type: "select", default: "random",
    options: [{ value: "random", label: "Random" }, { value: "choose", label: "Choose" }] },
  { key: "position", label: "Position number", type: "number", default: 518, min: 0, max: 959,
    enabledWhen: { key: "start", value: "choose" } },
],

newGame and startGame receive the settings as a JSON string ("{}" when the game declares none). Parse defensively. Every match shows its settings, by label, on the game page’s list of open matches and on the play page, so a joiner knows what they’re joining.

Appearance

appearance: {
  modules: {                                   // per module: the packs it supports, per axis
    tiles: { board: ["wood", "slate"], pieces: ["classic", "neon"] },
    default: { pieces: [null, "rhosgfx"] },    // null: also works with no pack
  },
  presets: {                                   // named looks: a module, a skin, a pack per axis
    classic: { module: "default", skin: "classic" },
    tiles:   { module: "tiles", skin: "classic", board: "wood", pieces: "classic" },
    glyphs:  { module: "default", skin: "classic", pieces: null },
  },
  default: "classic",                          // the default preset
},
  • The picker. Players choose a preset on the game’s tab of the theme panel, which the play page’s Appearance button (or the navigation bar’s theme button) opens. Presets whose module and skin exist on disk are listed, the default first, then the rest alphabetically. A Customize panel picks the module, skin and pack per axis directly. A game without appearance gets bare module and skin choices. The choice is saved per game: in the player’s account (guests included), or for a visitor without one in a browser cookie.
  • Which pack is active. When a match opens, per axis: the player’s saved choice, else the default preset’s, else the first entry of the module’s list. Picking a preset applies its own choices, else the default preset’s, else the first listed. Each must be one the module allows. Put null first to make “no pack” the last fallback.
  • Optional axes. null in a module’s list makes the axis optional. The picker offers None, and sdk.asset(axis, …) returns null, so the module has to be able to draw without the pack.
  • An axis a preset leaves out. The preset makes no choice for it, so the default preset’s choice applies, then the module’s first listed pack. An explicit null is a choice (“no pack”); a missing key isn’t.
  • What the picker offers. For each axis, the packs listed for the module that also exist on disk.
  • The default skin. When no preset names one, the first skin alphabetically.

Platform libraries

Shared libraries live in a catalog the platform’s admins curate. Declare the ones your UI uses:

libs: { three: "0.123.0" },

The frame installs an import map before your module loads, so UI code imports the library by its bare name (import * as THREE from "three"). A version is approved only if every declared library and version is in the catalog. Libraries are for UI modules. Logic can’t import anything.

Logic: the exports

The SDK is at version 1.1, and it only grows: what a published game uses keeps working. Additions are optional, with one exception: 1.1’s getResult, which every new submission must export, while versions published before it keep running.

Required

Export Returns Called
getManifest() MANIFEST Whenever the platform reads metadata
newGame(paramsJson) the initial state When a match is created. The waiting room shows this state, and the match starts from it.
getActivePlayers(state) string[] After every state change. The roles allowed to move now: one for a turn-based game, several for simultaneous moves, [] when it’s over.
applyMove(state, move, player) the new state For a move by player, who is always one of the active players. Throw to refuse the move.
getPlayerState(state, player) the state as player sees it For each role and for spectators (player is null), after every state change
getWinner(state) a role name, "draw", or null After every accepted move. Anything but null ends the match with that result.
getResult(state) (1.1) null, or how it ended: { reason, … } Once, when getWinner ends the match (see How it ended below). Required for new submissions; a version published without it still runs.

Optional

Export Returns Called
startGame(state, paramsJson) the started state Once, when the match goes from waiting to active (see Starting a match below)
getPlayerMoves(moves, viewer, state) one entry per move Whenever a viewer’s move history is shown (see Move history below)
getValidMoves(state, player) string[] Not called by the server. The new-project starter’s UI uses it to offer moves, and UIs may call it through sdk.logic.
isValidMove(state, move, player) boolean Not called by the server. A cheap, non-throwing check for UIs.
parseStateForUI(state) a view for rendering Not called by the platform. The convention for UIs to read the state (see Conventions of the reference games below).

A missing optional export is simply not called. An error your function throws is never mistaken for a missing export.

States and moves

A state is a string you define: JSON, or a compact notation like FEN. The reference games use compact notations. A move is a string the UI emits and applyMove parses.

The server never sends the full state to a browser. Each viewer gets getPlayerState‘s answer for their seat, or the spectator’s. Make sure getPlayerState doesn’t throw: if it fails for a viewer, that viewer gets no board at all, just a note that it can’t be shown, and your match counts as hiding information. A move is at most 4 KB, and longer moves are refused before your code sees them.

Starting a match

  1. Creation. newGame(paramsJson) builds the state the waiting room shows. Whatever it draws from senet.random is saved, so the preview and the actual start are the same board.
  2. Start. When the seats are settled and the version is pinned, the platform calls startGame(state, paramsJson) once, if you export it. Its result becomes the match’s state. It isn’t a move and nobody makes it. Its draws are recorded as history row 0: no player, empty move, shown as “Match started — drew 437” unless getPlayerMoves rewords or hides it. If it throws, the match doesn’t start.
  3. Moves. applyMove, then getActivePlayers, getPlayerState for every viewer, and getWinner. When getWinner ends the match, getResult.

Randomize the start in startGame (a shuffled deck, a Chess960 position) and keep newGame‘s state neutral. Otherwise the waiting room reveals the start before anyone has joined.

A match always runs the version of the game it started with, even if a newer version is approved mid-match.

How it ended (getResult)

SDK 1.1. getResult(state) says how the match ended, in your own words: null while it isn’t over, and once it is, an object with a reason and anything else you want recorded for later (sides, scores, a move count). The platform reads only reason; it keeps the rest as it is.

export function getResult(state: string): { reason: string; score?: number } | null {
  const s = parse(state);
  if (!s.over) return null;
  return s.mated ? { reason: "checkmate" } : { reason: "stalemate" };
}
  • reason is a string of 1 to 60 characters (“checkmate”, “flag captured”, “no moves left”). The end-of-match card shows it under the result, translated like sdk.t: it’s looked up as a key in your i18n/{locale}.json, and shown as it is when there’s no entry.
  • The whole object is at most 4 KB as JSON.
  • It’s called once, at game over, with the full state, and saved with the match. A getResult that throws, or returns anything else (a string, an object with no reason, more than 4 KB, a NUL character \u0000 in any string), saves nothing: the match ends all the same, with no reason line.
  • When the platform ends the match itself, it writes its own reason instead: "resign" for a resignation, "draw agreed" for an accepted draw offer. An abandoned match has none.
  • What it returns is public once the match is over: the end card, and the replay API (/api/matches/:id/replay, result_details), give it to anyone who may see the match. It’s never shown while the match runs. It reads the full state, so leave out what your game keeps hidden, unless the end of the match reveals it anyway.

Validate calls it on the new game’s state, where it must return null (or a valid object), and fails when it’s missing (logic.ts must export getResult) or returns something else. Submitting runs Validate first, so every new submission needs it. Versions published before 1.1 keep running without it.

Hidden information

getPlayerState(state, player) filters state for one viewer. player is a role name, or null for spectators. For a fully visible game, return state itself.

The platform detects hidden information rather than asking you to declare it. A match counts as hidden-information the first time any viewer is shown less than everything:

  • a viewer’s state differs from the full state (compared as strings), or
  • a history row is hidden from someone, shown with other text than was played, or shown with different draw text to different viewers.

So a fully visible game must return the same string. A state that’s re-serialized but equivalent counts as hidden. Hidden-information matches get restricted replays: each viewer sees only their own perspective, and players choose whether to reveal theirs afterwards.

Move history (getPlayerMoves)

getPlayerMoves(moves, viewer, state): Array<string | { move: string, draws?: string } | null>
  • moves is the full canonical log: {seq, player, move, draws} per row, in order. Row 0 is the start (seq 0, move "") and has no player key: comparing m.player === viewer with a null spectator must not take the start for the spectator’s own move. draws are the recorded senet.random entries (numbers only, see Randomness below).
  • viewer is a role name, or null for a spectator.
  • state is the full state at that point.
  • The return value is a parallel array, one entry per row:
    • a string: the move text, with the default draw text;
    • {move, draws}: your own draw text, up to 1,000 bytes. Anything but a non-empty string there shows no draw text at all.
    • null: hides the row entirely.

Without the export, everyone sees the canonical moves with the default draw text.

It’s called in two shapes. When a page loads a match’s history, the whole log goes in one call with the current state. During play, each new move is passed alone — moves is a one-row array [row], with the state after that move — once per viewer. So answer each row from the row, the viewer and the state; don’t rely on a row’s index in moves or on seeing earlier rows.

It fails closed. Once a game is known to export getPlayerMoves, any failure (a throw, a timeout, an answer of the wrong length or shape) shows each affected row as a placeholder (“hidden move”), with its number and player but neither move nor draws.

Move text is shown up to 1,000 bytes, cut with “…”. Draw text over 1,000 bytes isn’t shown.

Randomness: senet.random

A global senet object is available everywhere game code runs, in logic and in UIs:

Call Returns
senet.random.int(min, max) An integer, both ends inclusive. The range holds at most 2³² values.
senet.random.roll("2d6") An array of N values from 1 to M ("d20" = "1d20"). 1–1000 dice of up to 2³² sides.
senet.random.select(list) One element of a non-empty array
senet.random.shuffle(list) A new shuffled array; list isn’t modified
senet.random.weighted([[item, weight], …]) One item, with probability weight ÷ total. Weights must be numbers greater than 0.

Draws are unbiased (crypto.getRandomValues, with rejection sampling). Lists hold at most 10,000 items. senet is frozen and can’t be replaced. It also can’t be rigged by patching globals or prototypes, though the arrays you pass are read as given.

What’s recorded. On the server, the draws made by newGame, startGame and an accepted applyMove are recorded (a move that throws draws nothing). Each call is limited to 1,000 draws and 64 KB of recorded data. Recorded entries hold numbers only, never your items:

  • int and roll: the numbers drawn;
  • select and weighted: the index chosen;
  • shuffle: the permutation.

So a hidden hand passed to shuffle is never stored. Replays feed the recorded results back, which is why logic must be deterministic. Draws made anywhere else (in getPlayerState, getPlayerMoves, or in the browser) are plain randomness: not recorded, and not reproducible.

Who sees them. Viewers never get the draws themselves, only display text. By default:

  • roll and int show their numbers (“b2 — rolled 3, 5”);
  • select and weighted say “drew one”;
  • shuffle says “shuffled”.

To change that per viewer, return {move, draws} from getPlayerMoves. The draws themselves stay on the server until the match is over.

UI modules

A UI module is ui/{module}/main.ts, transpiled on its own to an ES module (it isn’t bundled). It runs in a sandboxed iframe at /game-frame.

Exports

Export Purpose
mount(el, state, sdk) Render into el (#game-root). May be async; the frame waits for it.
update(state) A new state to draw
onMove(cb) Keep cb and call cb(move) with a move string to submit a move
destroy() Remove listeners; the frame is cleared after it
setSeat(seat) (optional) The seat whose side the board is drawn from: 1-based, or null for a spectator
setStatus(status) (optional) "waiting", "active", "completed", or "replay". "replay" means the board takes no moves: the replay viewer, or a player looking from another side.
setResult(result) (optional) When completed: the winning role, "draw", or "resign"
setLastMove(last) (optional) The last move of the position shown, called after mount and after every update: on a page just opened, live, and at each step of a replay. last is {player, move} as this viewer is shown it: move is null when the move is hidden from them, and both are null when its whole row is. last is null before the first move. Mark the move from its text (chess: "e2e4") rather than by comparing positions, which a page just opened can’t do.

state is always the viewer’s state from getPlayerState, never more. The player of seat N is sdk.players[N-1]. Don’t hard-code “seat 1 is the first role”.

The sdk object

The third argument to mount, frozen:

Field What it is
sdk.logic Your logic module, already imported, so mount can stay synchronous. null if logic.ts failed to load. Show an error then.
sdk.players MANIFEST.players, the roles by seat
sdk.asset(path) URL of ui/{module}/assets/{path}, with its content hash
sdk.asset(axis, path) URL of asset-packs/{axis}/{pack}/{path} for the active pack, or null when no pack is active on that axis
sdk.t(key, vars?) key translated into the active locale (see Translations below)
sdk.logicUrl URL of the transpiled logic.js. Prefer sdk.logic.
sdk.setInfo(items) Short info and controls for the page to show beside the board, in a part a theme places (see Game info below). Optional: a game that never calls it keeps drawing whatever it draws.

Game info

sdk.setInfo([{ label: "Position", value: "518" }, { kind: "control", label: "Rotate wall", value: "R" }]) sends text the platform shows in its own game-info part instead of drawing it inside the board: a position number, a phase name, a score, keyboard hints. A theme’s play layout places the part with its game-info slot (a sidebar, a panel); a layout that doesn’t place it gets it under the board, in a fold open on a desktop and closed on a phone. Call it again whenever the info changes; setInfo([]) clears it. Each call replaces the list. The page keeps the list until your next call: it isn’t cleared when the seat changes, so a UI that shows a seat’s view calls setInfo again from setSeat. Identical calls are dropped and the rest sent at most once per animation frame, so calling it from update() is fine.

Each item is { kind, label, value }: kind is "info" (the default) or "control" (label says what it does, value is the key or gesture), label and value are text. At most 20 items, a label of at most 40 characters and a value of at most 80. The platform escapes the text; it isn’t Markdown or HTML. A list past the limits (or malformed) is not cut: the part shows nothing, and the test bar of a test match in the editor says what is wrong. Send only what your seat’s view (getPlayerState) already holds: the items are display text that never reach the server’s game code. The play page and an embedded live board show it; the replay page and its embeds don’t.

Asset URLs carry their content hash (?v=) and are served only with it, so build URLs with sdk.asset, never by hand. For the same reason a static relative import of another file won’t load. Code shared between logic and UI belongs in logic.ts (sdk.logic). A third-party library belongs in the platform catalog (MANIFEST.libs), or can be uploaded as a .js asset and loaded with import(sdk.asset("lib.js")).

Switching a module, skin or pack remounts the frame, so sdk always reflects the current choice.

The sandbox

The frame is sandbox="allow-scripts" with an opaque origin. Game code there has:

  • no access to the host page’s DOM, cookies or storage;
  • no network: fetch, XHR and WebSocket are blocked (connect-src 'none');
  • nothing from another site, a CDN included: scripts, styles, images and fonts load only from this site (your assets through sdk.asset, libraries from the platform catalog), and images and fonts may also be data: URLs (images blob: too);
  • no nested frames.

It talks to the page only through the platform’s bridge.

Layout: the panel. CSS @media queries don’t work inside the frame. #game-root is the panel the page offers your game, a size container (container-type: size). It’s as wide as the page’s column. On the play page it’s as tall as the screen less the player bars and the page around them, so a game that fits the panel fits the screen; elsewhere (embeds, the replay page) it’s square. Size against it with container units, cqw, cqh and cqmin (the smaller of the two), and @container queries: a square board is width: 100cqmin.

Draw everything (the board, cards, captured pieces) inside the panel, centered horizontally, at its top. The frame measures what you drew, the box around #game-root‘s children, and the page lines its player bars up with it. So leave the panel’s empty sides empty: a wrapper as wide as the panel, or a background across it, measures as the whole panel. If what you draw is taller than the panel, the frame grows to show it and the page scrolls. Since the panel has a definite height, a percentage height in your UI (height: 100% on what you mount) is the panel’s height, not your content’s.

Styling. The platform’s stylesheet (app.css) is loaded in the frame, and the page’s mode (light or dark) is mirrored on <html data-mode> (and on data-theme, its older name), so skins can follow the user’s mode: [data-mode="dark"] .board { … }, or read the platform’s colors, rgb(var(--c-surface)), which follow it already. The active skin’s CSS is loaded before mount.

The theme’s colors. The platform’s colors follow the user’s theme too: the frame gets the theme’s color tokens for both modes (never its stylesheet), so a skin reading rgb(var(--c-…)) draws in the theme’s colors. Every token is an RGB triplet, so a tint is rgb(var(--c-accent) / 0.3).

Colors a game may read. The platform’s own colors are always set (by app.css, or the theme): read them as they are. The board and side colors are a convention a theme may follow or not, and the platform has no default for them: read each with a fallback of your own, rgb(var(--c-board-light, 240 217 181)), so your colors are what players see under a theme that sets none.

Token What it’s for
--c-surface, --c-surface-alt panels, cards, a board’s background when it isn’t your own
--c-primary, --c-secondary, --c-muted text, from the main to the faintest (a status line, a hint)
--c-edge, --c-edge-light borders and dividers
--c-accent what’s selected: a picked piece or square
--c-success a valid move, a target you may play to
--c-danger-text danger: a king in check, an illegal choice
--c-board-light (fallback) the light squares or cells, or the board’s field when it has one color
--c-board-dark (fallback) the dark squares, or the lines and cells that stand out from the field
--c-board-mark (fallback) a last move’s squares, as a tint: rgb(var(--c-board-mark, 205 210 106) / 0.45)
--c-board-frame (fallback) the frame around the board: its rim, border or edge
--c-table (fallback) what the board stands on, within what you draw: a mat under the board, trays, reserves, hands
--c-side-1, --c-side-2, … --c-side-N (fallback) side N’s color: its pieces, its turn marker
--c-side-N-soft (fallback) the cells side N owns: a home triangle, a base, a tint. Many themes won’t set it: fall back to --c-side-N, at an alpha
--c-side-N-outline (fallback) the outline of side N’s pieces. Most themes won’t set it: fall back to the other side of the pair, then your own color: rgb(var(--c-side-1-outline, var(--c-side-2, 40 34 30)))

The full set of platform colors is in app.css (--c-heading, --c-accent-bg, --c-info-bg…); the ones above are those a board most often needs.

Sides. Sides are numbered, and pairs are opposites: 1 and 2, 3 and 4, 5 and 6…, the odd side the light one and the even side the dark one, pair 1 the strongest contrast. Themes are asked to follow a convention, in both modes: each holds 3:1 against the other side of its pair and stays apart from the other sides, and a piece drawn in it reads on the board’s squares through its outline: on each square, its fill or its outline holds 3:1 (a light piece gets a dark outline). The outline is --c-side-N-outline where a theme sets it, and otherwise the other side of the pair (side 1 in --c-side-2, side 2 in --c-side-1), so outline your pieces with that chain: stroke: rgb(var(--c-side-1-outline, var(--c-side-2, 40 34 30))). A light side’s color alone may not read on light squares. It’s suggested, not enforced: nothing checks it and no theme is refused for breaking it. Senet’s own themes follow it. Read the sides your game has, with your own colors as the fallbacks, so it still works under a theme that sets fewer: chess reads 1 and 2; a game with colorful discs may read 3 and 4 to stay colorful where a theme sets them; a six-sided game reads 1 to 6, so opposite sides are pairs.

Keeping a color your own. Not reading a token keeps your color. To set your own value for one a theme may set, set it on your own element, #game-root { --c-side-1: 220 40 40; }, not on :root: the frame sets the theme’s tokens inline on its root, which wins over any :root rule. When you keep a side’s fill, keep its outline too (--c-side-1-outline): the theme’s outline was chosen for the theme’s fill. A skin of your own, with its own colors, is another way, for the player to pick.

Don’t paint the panel’s empty sides with --c-table: the frame would measure them as drawn (Layout: the panel, above). Whatever you draw on a theme’s color must still read against it: if your walls or marks sit on --c-board-light, check their contrast under the themes that set it, or keep both colors your own.

Chess’s skin (ui/default/classic.css) reads --c-board-light and --c-board-dark for its squares:

.chess-square.light { background: rgb(var(--c-board-light, 238 238 210)); }
.chess-square.dark  { background: rgb(var(--c-board-dark, 118 150 86)); }

Under a theme that sets board colors, the squares take them, in light and dark; under any other, the board keeps its own cream and green. Its pieces would follow a theme’s sides the same way, read from --c-side-1 and --c-side-2 with chess’s own colors as the fallbacks.

The last move, and whose turn it is. Tint a last move’s squares with --c-board-mark (Colors a game may read, above). On the play page, the platform’s player bars already say whose turn it is, so the frame’s root then carries data-player-bars: a game may hide its own turn line there with :root[data-player-bars] .my-turn-line { display: none; }, and keep it everywhere else (the replay page, embeds), where there are no bars. The play page keeps data-player-bars while it steps back through the match, so the board keeps its size between live and replay; the record says which step is shown.

Translations

Wrap user-facing text in sdk.t("English text", {name: value}). The literal is the key, gettext style. A missing translation returns the key, with {name} placeholders filled from vars, so wrapping changes nothing until an i18n/{locale}.json (a flat {"English text": "Texto"} map) exists.

The active locale is MANIFEST.defaultLocale if that file exists, else en, else the first locale alphabetically. There’s no per-user locale choice yet.

Conventions of the reference games

The reference games model current practice: tic-tac-toe, connect-four, hex, chess, chess960, nine-mens-morris, onitama, quarto, quoridor and stratego. You can read every file of each on its project page, such as /projects/tic-tac-toe.

Notation lives in logic. logic.ts is the single source of truth for the state and move grammars. It exports parseStateForUI(state), which returns a view for rendering that uses the same cell tokens the logic uses. UI modules call it, plus getWinner and friends, through sdk.logic in a synchronous mount. They never re-implement the grammar or the rules. When sdk.logic is null, they show an explicit error rather than falling back to a second parser. If a renderer needs another ordering (the 3D Connect Four board is Y-up, so its rows are bottom-up), treat it as a coordinate choice, not a format adapter.

Public surface first. Files put what they export first, in this order:

  • logic.ts: header comment (document your notations there) → MANIFEST / getManifest → // --- Required SDK exports --- → // --- Optional SDK exports --- → // --- UI helper export --- (parseStateForUI) → // --- Internal ---.
  • ui/*/main.ts: header → // --- SDK exports --- → // --- Internal ---.

Write export on each declaration, never in a trailing export { … } list. Hoisting makes this ordering safe, since exports only call internals at match time.

Match notation and replays

Finished matches can be replayed step by step, and matches can be written into posts as ```match blocks. The format is PGN generalized to any game:

```match chess960
[Event "Casual game"]
[White "Ana"]
[Version "2"]

{[%draws 19] A note on the start.}
1. e2e4 e7e5
2. g1f3 {[%draws 3, 5] A note on this move}
```

What it means for your game:

  • Moves are your move strings, separated by spaces. A move containing spaces, or one that would read as syntax, is quoted ("c3 3"). Where several players can move, a move is prefixed with its role (Blue: a4).
  • Draws. [%draws …] gives the senet.random results of the step it follows: the start before the first move, otherwise the move. A replay must be given every result your code draws, and no extra ones.
  • Positions. [Start "…"] (or [FEN "…"]) and [%start "…"] are positions written in your state notation. The replay takes the string as your state, as is.
  • Notations. A [MoveNotation] or [StateNotation] tag other than your MANIFEST’s own is refused.
  • Determinism. A replay runs your newGame, startGame and applyMove with the given draws, then getPlayerState and getPlayerMoves for each perspective. It must reproduce the match, which is why logic has to be pure and deterministic.

Limits

What Limit
A logic call 5 s
A whole-match replay 10 s
A move 4 KB
Move text in the history 1,000 bytes (cut with “…”)
A game’s own draw text 1,000 bytes (longer shows none)
Draws per call 1,000 draws, 64 KB recorded
roll 1–1000 dice, up to 2³² sides
Lists passed to senet.random 10,000 items
Tags 20, 50 characters each
Asset uploads 20 files per batch, 2 MB each
A match in notation 256 KB, 1000 moves, 4 KB per move, 1000 bytes per tag (Params/Start/FEN excepted)