Skip to the content

Narabe並べ

Play forty-eight abstract board games through immutable moves, legal choices and replayable records.

Narabe means arranging in Japanese, as in gomoku-narabe: five in a row. About the name

Contents

How-to

Save and replay a record

Save a record as settings and moves, replay it with its choices and clock, and spot a replay that stops early.

Store settings and moves

A record is initial settings plus moves, not a screenshot or a mutable board. StoredGame includes moveTimeMs: null means no clock. A replay accepts forfeits only for a game known to have run a clock.

import {replayTimeline,replayGame,type StoredGame} from "@johnmorrisdotca/narabe";
const saved: StoredGame = {size:15,winLength:5,variant:"freestyle",obstacles:"none",opener:"black",moveTimeMs:null,moves:[{row:7,col:7},{row:7,col:8}]};
console.log(replayTimeline(saved).length);
console.log(replayGame(saved).moves.length);
3
2

Preserve choices and versions

replayMoves accepts explicit opening choices and clock facts. StoredGame does not store swap choices, so its replay keeps the chooser's colour by default; do not assume its seat history preserves a missing choice. Store choices separately when that distinction matters. Preserve initial settings, seed and the version used to play a record.

Recognize a stopped replay

Replaying stops when an input cannot legally advance the game. Compare replay progress to the input; do not silently call a truncated record complete. undoMove removes effects of the last recorded move when enabled, but does not undo an opening colour decision. See troubleshooting.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/narabe 1.3.0.