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

Reference · Rules and records

resolveOpenerfunction

The colour that opens. random is decided by roll, a number in [0, 1), which the caller supplies so this stays pure and testable. Variants that constrain black, and every opening protocol, put black on move one.

Import it

import { resolveOpener } from "@johnmorrisdotca/narabe";

Definition

function resolveOpener(settings: GameSettings, roll?: number): Stone

Parameters

NameTypeDescription
settingsGameSettings

The native game settings to interpret.

roll (optional)number

A random value in [0,1), supplied for reproducible choices.

Returns

Stone

The colour that opens. random is decided by roll, a number in [0, 1), which the caller supplies so this stays pure and testable. Variants that constrain black, and every opening protocol, put black on move one.

Examples

import { createGame, resolveOpener } from "@johnmorrisdotca/narabe";

const state = createGame({variant:"freestyle",size:15});
console.log(resolveOpener({...state.settings,firstPlayer:"random"}, 0.25));
black

What it prints (run when this page was built)

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