legalPlays関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Every different turn a side may make with a roll: one for each position that playing the roll as the rules require can leave, with one way of getting there. A side that cannot move has the one play of no moves.
インポート
import { legalPlays } from "@johnmorrisdotca/sugoroku";
定義
function legalPlays(spec: VariantSpec, position: Position, side: Side, roll: readonly number[]): Play[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
spec | VariantSpec | The native variant specification. |
position | Position | The native checker counts, bar, reserve and borne-off counts. |
side | Side | The side being examined: white or black. |
roll | readonly number[] | The valid dice as thrown, in throw order. |
戻り値
Play[]
Every different turn a side may make with a roll: one for each position that playing the roll as the rules require can leave, with one way of getting there. A side that cannot move has the one play of no moves.
例
import { legalPlays, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
console.log(legalPlays(spec,position,"white",[3,1]).length);16出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。