Frontmatter Schema

How to write the engine: block that defines a game variant. This is the primary interface for adding new games to the engine.

The engine: block

Every game variant in moddable-rules has a Markdown file with YAML frontmatter. The engine: block tells the engine everything it needs to render the board and (eventually) play the game.

---
title: My Variant
engine:
  topology:
    type: grid
    rows: 8
    cols: 8
  surface: parchment
  render:
    cellColor: checkered
    labels: true
  setup: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
  pieces:
    set: mce-chess
  players: [white, black]
---

topology

Defines the spatial structure. Required for any game with a board. The type field determines which topology is used and what other fields are valid.

surface

Visual theme. Either a named string (parchment, slate, etc.) or an inline object with custom colours.

render

Controls how the board is drawn: cell colouring, labels, decorations, coordinate style, and the ops pipeline.

setup

Initial position. Format depends on topology type (FEN for grids, coordinate pairs for hex, etc.).

pieces

Which piece set to use and optional configuration (borders, vocabulary mapping, FEN overrides).

Topology types

grid

Rectangular boards. Chess, draughts, go, xiangqi, shogi, pachisi.

FieldRequiredDescription
typeYesMust be grid
rowsYesNumber of rows
colsYesNumber of columns
layoutNocells (default), intersections, or cross
layersNoNumber of boards for multi-board games (Alice Chess)
layer_labelsNoArray of board names ([Board A, Board B])
cells = pieces on squares (chess). intersections = pieces on line crossings (go, xiangqi). cross = pachisi-shaped cross pattern.

hex

Hexagonal boards. Hex, nukes, hex-chess variants.

FieldRequiredDescription
typeYesMust be hex
shapeNohexagonal or triangular
radiusNoHex radius (for hexagonal shape)
rows / colsNoRectangular hex grid dimensions
gridNoExplicit array of [q, r] coordinates
orientationNopointy (default) or flat
sideLengthNoFor triangular shape
Provide one of: shape + radius, or rows + cols, or explicit grid array.

track

Linear paths. Backgammon, Landlord's Game.

FieldRequiredDescription
typeYesMust be track
positionsYesNumber of positions on the track

pit

Mancala-family sowing games.

FieldRequiredDescription
typeYesMust be pit
colsYesPits per side
rowsNoNumber of rows (default 2)
storesNoWhether end stores exist (default true)

graph

Arbitrary node-edge structures. Morris, stern-halma, nyout, asalto.

FieldRequiredDescription
typeYesMust be graph
structureYesconcentric-rings, perimeter-cross, grid-cross, or star
paramsNoStructure-specific: rings, midpoints, diagonals
nodesNoExplicit node definitions (for custom graphs)
edgesNoExplicit edge definitions

Surfaces

A surface provides default colours for the board. Reference by name or define inline.

# Named surface
surface: parchment

# Inline colours
surface:
  colors:
    cell-light: "#dcb35c"
    cell-dark: "#d4a843"
    stroke: "#3d2b1a"
    background: "#2c2c2c"

Available named surfaces:

NameCharacter
wood-classicTraditional wood tones (chess default)
wood-lightLighter wood (go boards)
felt-greenGreen baize (card table)
parchmentAged paper
earthBrown/terracotta
slateCool grey stone
jungleDeep greens
militaryOlive/khaki tactical
cosmicDark space theme

Setup notation

Each topology type has its own notation for initial positions.

Grid — FEN

# Standard chess
setup: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

# Multi-board (Alice Chess) — array of FENs
setup:
  - rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
  - 8/8/8/8/8/8/8/8

# 4-player (comma-separated, colour-prefixed)
setup: rR,rN,rB,rQ,rK,rB,rN,rR/rP,rP,rP,rP,...

# Large shogi (bracket notation for multi-char pieces)
setup: [ln][kn][ph][ig][fk]...

Hex — coordinate pairs

# q,r:piece format
setup: "0,0:mount,0,1:grass,1,0:grass,-1,0:base"

Track — position:count+owner

# Backgammon: position:countOwner pairs
setup: "0:2W,5:5B,7:3B,11:5W,12:5B,16:3W,18:5W,23:2B"

Pit — semicolon-separated counts

# Format: south-pits;south-store;north-pits;north-store
setup: "4,4,4,4,4,4;0;4,4,4,4,4,4;0"

Graph — node:piece pairs

# Morris/Halma: empty string means no initial pieces
setup: ""

# With pieces placed
setup: "n1:W,n4:B,n7:W"

Cascade resolution

Game definitions use inheritance. The family rulebook provides defaults, and each variant overrides only what differs.

# Family rulebook.md — shared by all variants
engine:
  topology:
    type: grid
    rows: 8
    cols: 8
  surface: wood-classic
  render:
    cellColor: checkered
    labels: true
    ops:
      - op: cells
        pattern: checkered
      - op: border
  pieces:
    set: mce-chess

# Variant (e.g. capablanca.md) — only overrides what changes
engine:
  topology:
    cols: 10
  setup: rnabqkbanr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBANR

The cascade resolver deep-merges: surface defaults → family engine → variant engine. Variants inherit everything from the family and only specify differences.

Complete examples

Chess variant (grid)

---
title: Capablanca Chess
engine:
  topology:
    type: grid
    rows: 8
    cols: 10
  setup: rnabqkbanr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBANR
  pieces:
    set: mce-chess
---

Hex game (hex)

---
title: "Nukes: Standard"
engine:
  topology:
    type: hex
    shape: hexagonal
    radius: 3
    orientation: pointy
  players: [player1, player2]
  render:
    cellSize: 24
    cellColor: terrain
    frame: true
  setup: "0,0:mount,0,1:grass,1,0:grass,1,-1:trees"
---

Mancala variant (pit)

---
title: Oware
engine:
  topology:
    type: pit
    cols: 6
    stores: false
  players: [south, north]
  render:
    cellSize: 24
  setup: "4,4,4,4,4,4;0;4,4,4,4,4,4;0"
---