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
| Name | Type | Description |
|---|---|---|
settings | GameSettings | 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));blackWhat it prints (run when this page was built)