本文へ移動

Narabe並べ

48種類の盤上ゲームを、新しい局面を返す手の操作、合法手の一覧、再生できる棋譜で扱えます。

「並べ」は五目並べの「並べ」。石を並べることを表す言葉です。 名前について(英語)

目次

リファレンス · ルールと棋譜

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;
};

メンバー

名前型説明
lineRuleRecord<Stone, LineRule>

Per colour, because renju lets white win with an overline and not black.

forbiddenRecord<Stone, readonly ForbiddenPattern[]>
capturesboolean

Flanking a pair of enemy stones removes them.

stonesPerTurnnumber
firstTurnStonesnumber

Connect6 opens with a single stone before the two-a-turn rhythm starts.

winLengthnumber | null

A pinned line length, or null when the players may choose.

allowFirstPlayerChoiceboolean

Whether the players may hand the first stone to white or draw lots.

firstStoneStone

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.

openingsreadonly OpeningRule[]
placementPlacement
loseLengthnumber | null

Making exactly this many in a row loses, as in the trap game; null when nothing does.

quadrantSizenumber | null

Side of the quadrants a move ends by rotating; null when moves do not twist.

piecesnumber | null

Pieces per player; once all are down, a turn moves one. Null for unlimited stones.

squareWinsboolean

A 2×2 square of one colour also wins.

boardSizesreadonly 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.

defaultBoardnumber | 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 boardSizes, which is now the smallest.

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.

gridBoardGrid

Where its stones sit when it is drawn its own way — see BoardGrid. Declared, never inferred.

analysisboolean

Whether the threat reading means anything; off where stones move after placing.

wrapWrapMode

Which edges join. columns is a cylinder — left meets right; both is a torus, where top meets bottom as well. A mode rather than two booleans because "rows wrap but columns do not" is the same cylinder turned on its side, and there is no reason for the type to allow two ways to say it.

deadSquaresnumber

Squares taken out of play at random when the game starts, or when the rocks fall (see rocks).

hotSquaresnumber

Squares that count as either colour's stone, placed at random when the game starts, or when the rocks fall.

rocksRockSpec | null

The rock games' way of laying the dead squares and hotspots above, or null for the older way (randomSquares). When set, rules/rocks.ts lays them from the seed across the whole board, never on the centre, and they land when the game starts or, with arriveAfter, once that many stones have been played — on the empty points only. The counts stay in deadSquares and hotSquares, so everything that asks whether a game has either still reads one field.

lineClearboolean

A full bottom row disappears and everything above it drops, as in the falling-block game.

misereboolean

Making the winning line loses, and a full board goes to the player who opened.

queuePieceQueue | null

Pieces come from a shared seeded queue rather than being single stones.

singlesnumber

Single stones of your own colour each player may lay instead of a piece.

captureSizesreadonly number[]

How many enemy stones a flank may take at once: pairs, or pairs and triples.

capturesToWinnumber | null

Enemy stones to capture for a win, in stones, in the capture variants.

wormholesnumber

Two random squares joined by a wormhole: a line entering one leaves the other.

anyColourboolean

The mover chooses the colour of every stone.

singleColourboolean

Every stone is black, whoever placed it.

makerBreakerboolean

Maker wants a line of either colour; breaker wants a full board without one.

flipsboolean

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.

startingDiscsStartingDiscs

How the centre is set before the first move: fixed, laid by the players, or empty.

campsboolean

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.

connectsboolean

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.

checkersboolean

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.

checkersRulesCheckersRules | null

How this game of the checkers family moves and takes — see CheckersRules. Null exactly when checkers is false: a game with no men and no kings has no answer to "may a man take backward", and a default here would be one.

chineseCheckersboolean

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 BLOCKED. Otherwise the same race as Halma's camps — step or jump-chain to fill the point opposite, nothing captured — just six hex directions in place of eight square ones, and a star's points in place of a corner's square.

hexagonboolean

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 BLOCKED. The rules are the flipping game's, in six directions rather than eight: Reversi on a honeycomb. See rules/hexagon.ts for the shape and rules/flips.ts for the six directions.

goboolean

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.

headStartTraditionalHeadStart | null

The head start this game's own tradition gives a weaker player, or null where it has none — see TraditionalHeadStart and rules/headStart.ts. Every game also offers free turns at the start; this is what it adds.

headStartTurnsHeadStartTurns

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 (simulation.headStartDecides.ts, held by variants.coverage.test.ts). Declared on every row, never defaulted, as grid is.

例

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
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/narabe 1.3.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。