VariantSpec型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
One rule set, as data. The engine consults this and never the variant's name, so adding a variant is a matter of adding a row.
インポート
import type { VariantSpec } from "@johnmorrisdotca/narabe";
定義
type VariantSpec = {
lineRule: Record<Stone, LineRule>;
forbidden: Record<Stone, readonly ForbiddenPattern[]>;
captures: boolean;
stonesPerTurn: number;
firstTurnStones: number;
winLength: number | null;
allowFirstPlayerChoice: boolean;
firstStone: Stone;
openings: readonly OpeningRule[];
placement: Placement;
loseLength: number | null;
quadrantSize: number | null;
pieces: number | null;
squareWins: boolean;
boardSizes: readonly number[] | null;
defaultBoard: number | null;
grid: BoardGrid;
analysis: boolean;
wrap: WrapMode;
deadSquares: number;
hotSquares: number;
rocks: RockSpec | null;
lineClear: boolean;
misere: boolean;
queue: PieceQueue | null;
singles: number;
captureSizes: readonly number[];
capturesToWin: number | null;
wormholes: number;
anyColour: boolean;
singleColour: boolean;
makerBreaker: boolean;
flips: boolean;
startingDiscs: StartingDiscs;
camps: boolean;
connects: boolean;
checkers: boolean;
checkersRules: CheckersRules | null;
chineseCheckers: boolean;
hexagon: boolean;
go: boolean;
headStart: TraditionalHeadStart | null;
headStartTurns: HeadStartTurns;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
lineRule | Record<Stone, LineRule> | Per colour, because renju lets white win with an overline and not black. |
forbidden | Record<Stone, readonly ForbiddenPattern[]> | |
captures | boolean | Flanking a pair of enemy stones removes them. |
stonesPerTurn | number | |
firstTurnStones | number | Connect6 opens with a single stone before the two-a-turn rhythm starts. |
winLength | number | null | A pinned line length, or null when the players may choose. |
allowFirstPlayerChoice | boolean | Whether the players may hand the first stone to white or draw lots. |
firstStone | Stone | The colour that moves first where the players may not choose — and under an opening protocol, which always starts from it. Black for nearly every game here; White for the draughts games whose federations give White the first move. |
openings | readonly OpeningRule[] | |
placement | Placement | |
loseLength | number | null | Making exactly this many in a row loses, as in the trap game; null when nothing does. |
quadrantSize | number | null | Side of the quadrants a move ends by rotating; null when moves do not twist. |
pieces | number | null | Pieces per player; once all are down, a turn moves one. Null for unlimited stones. |
squareWins | boolean | A 2×2 square of one colour also wins. |
boardSizes | readonly number[] | null | Board sizes this game is played on, or null for the standard list. IN NUMERICAL ORDER, ALWAYS, because that is the order they are drawn in — John, 2026-09-21: "the order of the Boards, on all pages should be numerical." They used to be written default-first, which put Halma at 16, 10, 8 and Honeycomb at 11, 7, 9, 13 in every picker on the site. |
defaultBoard | number | null | The board a game opens on where it is not the smallest — Halma's own
sixteen, Honeycomb's ninety-one cells, Go's nineteen. Null means the first
of A field rather than a position in the list, because those are two different facts and reading one off the other is what made the order a decision it should never have been: sorting the list silently opened Halma on the quick board and Honeycomb on the small hexagon. |
grid | BoardGrid | Where its stones sit when it is drawn its own way — see |
analysis | boolean | Whether the threat reading means anything; off where stones move after placing. |
wrap | WrapMode | Which edges join. |
deadSquares | number | Squares taken out of play at random when the game starts, or when the rocks fall (see |
hotSquares | number | Squares that count as either colour's stone, placed at random when the game starts, or when the rocks fall. |
rocks | RockSpec | null | The rock games' way of laying the dead squares and hotspots above, or null
for the older way ( |
lineClear | boolean | A full bottom row disappears and everything above it drops, as in the falling-block game. |
misere | boolean | Making the winning line loses, and a full board goes to the player who opened. |
queue | PieceQueue | null | Pieces come from a shared seeded queue rather than being single stones. |
singles | number | Single stones of your own colour each player may lay instead of a piece. |
captureSizes | readonly number[] | How many enemy stones a flank may take at once: pairs, or pairs and triples. |
capturesToWin | number | null | Enemy stones to capture for a win, in stones, in the capture variants. |
wormholes | number | Two random squares joined by a wormhole: a line entering one leaves the other. |
anyColour | boolean | The mover chooses the colour of every stone. |
singleColour | boolean | Every stone is black, whoever placed it. |
makerBreaker | boolean | Maker wants a line of either colour; breaker wants a full board without one. |
flips | boolean | The flipping games. A stone may only be placed where it flanks a line of the other colour, which then turns; a colour with no such place passes; when neither can move the discs are counted. Lines and captures mean nothing here — the whole of the game is in the flip. |
startingDiscs | StartingDiscs | How the centre is set before the first move: fixed, laid by the players, or empty. |
camps | boolean | The race games. Every piece starts in a corner camp; a move is a step or a chain of jumps over any piece; filling the far camp wins. Lines, captures and placing mean nothing here. |
connects | boolean | The connection game. A colour wins by joining its own two sides of the board with a chain of touching stones, on a lattice where a cell touches six others rather than four or eight. No lines, no captures, no draws. |
checkers | boolean | The checkers family. Pieces stand on the board from the start and move one diagonal step forward, or capture by jumping an adjacent enemy piece into the empty square beyond. Capturing is forced whenever any of a colour's pieces can, and a piece that jumps again from where it lands keeps jumping in the same move for as long as it has another to take. A man reaching the far row is crowned a king, which may move and capture backward as well as forward; a colour with no legal move loses. |
checkersRules | CheckersRules | null | How this game of the checkers family moves and takes — see |
chineseCheckers | boolean | Chinese Checkers: a hexagram board, embedded in a square Point grid the
way Hex's rhombus is, with the cells outside it sealed off as |
hexagon | boolean | A hexagonal board on the hexagon lattice, embedded in a square Point grid
the way Chinese Checkers' star is, with the cells outside the hexagon and
the one at its centre sealed off as |
go | boolean | Go: stones never move once placed. A group of one colour with no liberties left is captured whole; a move that would leave the mover's own group with none, after any capture it makes, is suicide and illegal; a move that would exactly retake the single stone a capture just lifted is forbidden for one turn — the simple ko rule. Either side may pass at any point; two passes in a row end the game, scored by area — every stone on the board plus the empty points only that colour surrounds — with a fixed komi added for white. |
headStart | TraditionalHeadStart | null | The head start this game's own tradition gives a weaker player, or null
where it has none — see TraditionalHeadStart and |
headStartTurns | HeadStartTurns | The most free turns this game offers as a head start, 0 for none. A head
start must make a game easier, never decide it, so each game's figure is
the most its measurement shows cannot force a win within a short horizon
( |
例
import { VARIANT_SPECS, createGame, playMove } from "@johnmorrisdotca/narabe";
import type { VariantSpec } from "@johnmorrisdotca/narabe";
const go = playMove(createGame({variant:"go",size:9}),{row:4,col:4});
const value: VariantSpec = VARIANT_SPECS.go;
console.log(value);{
lineRule: { black: 'atLeast', white: 'atLeast' },
forbidden: { black: [], white: [] },
captures: false,
stonesPerTurn: 1,
firstTurnStones: 1,
winLength: 5,
allowFirstPlayerChoice: false,
firstStone: 'black',
openings: [ 'free' ],
placement: 'free',
loseLength: null,
quadrantSize: null,
pieces: null,
squareWins: false,
boardSizes: [ 9, 13, 19 ],
defaultBoard: 19,
analysis: false,
wrap: 'none',
deadSquares: 0,
hotSquares: 0,
rocks: null,
lineClear: false,
misere: false,
queue: null,
singles: 0,
captureSizes: [ 2 ],
capturesToWin: null,
wormholes: 0,
anyColour: false,
singleColour: false,
makerBreaker: false,
flips: false,
startingDiscs: 'none',
camps: false,
connects: false,
checkers: false,
checkersRules: null,
chineseCheckers: false,
hexagon: false,
go: true,
headStart: 'stones',
grid: 'lines',
headStartTurns: 3
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。