リファレンス
規則・ゲーム・記録
import { … } from "@johnmorrisdotca/sugoroku";
最小化と gzip 圧縮をしたサイズは 11.6 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Pure backgammon and variant rules, legal turns, cube and match scoring, dice, records and computer choices.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
agreeDraw | 関数 | The game drawn by agreement. |
allHome | 関数 | Whether every checker of side still in play is in its home board (own points 1 to 6): the condition for bearing off. |
applyMove | 関数 | The position after a move. |
BAR | 定数 | The number a move's from has when a checker comes from the bar (or from off the board at the start of a race). |
beaverDouble | 関数 | Beaver: the side that was doubled redoubles and keeps the cube; the side that doubled must now take it or drop it. |
boardPoint | 関数 | The point on the board, 1 to 24 counting the way white counts, that is side's own point own. |
canBeaver | 関数 | Whether the side that was doubled may beaver: redouble at once and keep the cube. |
canDouble | 関数 | Whether the side on turn may offer a double now. |
canPlayAll | 関数 | Whether every die of need (highest first) can be played from position, in some order. |
chanceOfWinning | 関数 | The chance, 0 to 1, that side wins from here, by the evaluation, or by the Keith count's rule of thumb in a race (as 0.5 plus a share of the count's lead). |
checkersOf | 関数 | The whole count of each side's checkers: on the board, on the bar, yet to enter, and off. |
choosePlay | 関数 | The play the computer makes for the rest of the turn of the side on turn, from the plays the rules leave it. |
computerAction | 関数 | What the side that has to act in a game would do, if the computer were playing it. |
ComputerAction | 型 | What the computer does next in a game, for the side it plays. |
ComputerOptions | 型 | Strength, tie-breaking randomness, lookahead time budget and evaluation weights for computer decisions. |
concede | 関数 | Give up the game: side loses. |
concedeKind | 関数 | What a side gives up if it gives up the game now, which is the worst the position could come to: a single game once it has borne a checker off; a gammon if nothing of the other side's can still hit it; otherwise a backgammon where it may have a checker caught in the other side's home board. |
countAt | 関数 | How many of side's checkers stand on its own point own (1 to 24). |
Cube | 型 | The doubling cube: what it shows, and who may turn it (null while it stands in the middle, for either). |
CUBE_LIMIT | 定数 | The most the cube can show. |
cubeInPlay | 関数 | Whether the cube is in play in a game of a match, given whether this is the Crawford game. |
cubeIsDead | 関数 | The cube is dead when turning it could not matter: it already shows enough for either side to win the match with a win. |
DEFAULT_RULES | 定数 | The rules a variant is played with when nothing else is asked: a single game with no cube and no gammons. |
diceMustPlay | 関数 | WHICH DICE MUST BE PLAYED. |
DiceSource | 型 | Where dice come from: each call is the number on one die, 1 to 6. |
diceToPlay | 関数 | The dice a roll gives to play, highest first: a double of a game that plays doubles four times is four of them. |
Direction | 型 | How the sides' tracks lie on the board. |
dropDouble | 関数 | Drop the double that was offered: the side that drops it loses the game, at the cube's value before the double, or for a beaver at its value once the double was taken. |
endTurn | 関数 | End the side on turn's turn, once everything it had to play has been played. |
evaluate | 関数 | The score of a position for side, with the other side to move, as a game where bearing off first wins. |
evaluateFor | 関数 | The score as side plays to win or to lose: a game played to lose is judged the other way up. |
EVALUATION_WEIGHTS | 定数 | The weights the computer plays with: set by hand and then held against random changes of themselves, none of which won more often over two thousand games. |
EvaluationWeights | 型 | The numbers the evaluation is made of, each a number of pips. |
finishGame | 関数 | The match after a game's result: the score added up, the Crawford game accounted for, and the match over if it is decided. |
formatMove | 関数 | One move as text: 24/18, bar/22*, 6/off. |
formatOpening | 関数 | One line of a game: the opening throw. |
formatPlay | 関数 | The text of a whole turn: moves of one checker joined, equal moves counted, the farthest-back checker first. |
formatPosition | 関数 | A position as text, for any variant: each side's checkers as point:count in that side's own numbering, highest point first, then the bar, those yet to enter and those borne off, [white, black] each. |
formatRecordHeader | 関数 | The header lines of a record: its version, the variant, the rules and the seed. |
formatResult | 関数 | The line that closes a game, with what it came to. |
formatTurn | 関数 | One line of a game: a turn, with its dice and its play. |
GameRecorder | クラス | A record written as a game is played. |
GameResult | 型 | The decided winner, ending, win kind, cube multiplier and points. |
GameState | 型 | The immutable game phase, board, dice, remaining moves, cube and optional result. |
Goal | 型 | What it takes to win. |
hashSeed | 関数 | A whole number from a seed given as a number or as text: the same seed is always the same number, in every browser and every Node. |
Hop | 型 | A step of a written play: one checker, one die's distance (or off), as written. |
HowItEnded | 型 | How a game came to its end. |
inContact | 関数 | Whether the two sides can still hit one another. |
inPlay | 関数 | Every checker of side that is still in the game: on the board, on the bar or yet to enter. |
isVariantKey | 関数 | Whether key names a variant. |
keithCount | 関数 | The Keith count of a side, a pip count corrected for how badly the checkers are placed for bearing off: plus 2 for each checker beyond the first on the 1-point, 1 for each beyond the first on the 2-point and beyond three on the 3-point, and 1 for each empty point among the 4, 5 and 6, and then the side on roll adds a seventh (rounded down). |
legalMoves | 関数 | The moves the side on turn may make next. |
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. |
legalPlaysOf | 関数 | Every different way the side on turn may play out the rest of its turn: for the dice it has yet to play, from where the position stands now. |
Match | 型 | A MATCH: games played one after another to a number of points, or without end in money play. |
mirrorPoint | 関数 | The other side's own number for the point that is side's own point own. |
Move | 型 | ONE CHECKER MOVED BY ONE DIE, in the mover's own numbering: from its own point from (or the BAR, 25, for a checker entering from the bar or from off the board at the start of a race) to its own point to (0 for borne off). |
movesOfDie | 関数 | Every move of one die that side may make from position, one for each point a checker can start from. |
multiplierOf | 関数 | What a win of kind is worth, after the rules: a single win when gammons do not count, or when the Jacoby rule holds them back because the cube was never turned. |
newGame | 関数 | A new game, waiting for the opening throw. |
NewGameOptions | 型 | Options for a new game. |
newMatch | 関数 | A match at 0 to 0. |
nextMoves | 関数 | The moves that may be made next, by a side that still has the dice need (highest first) to play from position: every move that leaves the rest of need playable. |
offerDouble | 関数 | Offer a double: the other side must now take it or drop it. |
onBoard | 関数 | How many checkers side has on the board's points, not counting the bar, the reserve and those borne off. |
Opening | 型 | How a game is opened. |
openingFrom | 関数 | An opening throw from a source: one die for white and one for black. |
opponentAt | 関数 | How many of the other side's checkers stand on the point that is side's own point own. |
otherSide | 関数 | The other side. |
parseHops | 関数 | The hops a written play names, in the order written: a chain of three points is two hops, and 13/11(2) is two. |
parsePlay | 関数 | The moves a written play makes with a roll, or null if it is not a legal play of that roll. |
parsePosition | 関数 | The position that text of formatPosition's kind stands for, or null if it is not one. |
Phase | 型 | Where a game has got to. |
pipCount | 関数 | The pip count of a side: the sum of every checker's distance from being borne off. |
Play | 型 | A WHOLE TURN: the moves a side makes with a roll, in the order it makes them, and the position they leave. |
playMove | 関数 | Make one move for the side on turn, given as the checker's own point it leaves and the one it goes to. |
playMoves | 関数 | The position after a list of moves, made one after another. |
playTurn | 関数 | Make a whole play (the moves of legalPlays) for the side on turn and end the turn. |
POINTS | 定数 | The points on the board. |
pointsToGo | 関数 | How many points a side still needs to win the match: 0 in money play, where there is no such thing. |
Position | 型 | WHERE THE CHECKERS ARE. |
positionFromId | 関数 | The position an ID stands for, with onRoll to move, or null if the text is not an ID. |
positionId | 関数 | The ID of a position with onRoll to move, or null if it cannot be written in this form. |
positionKey | 関数 | A position as a short string that is the same for the same position, for keeping a set of them. |
Preset | 型 | A NAMED WAY OF PLAYING: a variant with its rules. |
presetByKey | 関数 | The preset with this key, or undefined. |
presetByName | 関数 | The preset a site's printed name leads to, or undefined. |
PRESETS | 定数 | Every named way of playing, in the order of docs/VARIANTS.md. |
Random | 型 | A source of random numbers from 0 up to but not including 1. |
randomDice | 関数 | Dice that are not seeded: from the device's own random numbers. |
RECORD_VERSION | 定数 | The record format's version, the number after sugoroku on the first line. |
RecordSeed | 型 | A seed in a record: all digits means a number, anything else is text. |
ReplayedGame | 型 | One game of a replayed record, finished. |
ReplayError | 型 | A refused record with its one-based line number and reason. |
ReplayOk | 型 | A successfully validated record, its settings, completed games and optional current game. |
replayRecord | 関数 | Replay a record against the rules. |
resolveRules | 関数 | The rules with anything left out filled from DEFAULT_RULES. |
restartTurn | 関数 | Take back every move of the turn. |
rollDice | 関数 | Roll the dice for the side on turn, which must not be waiting on an answer to a double. |
rollFrom | 関数 | A roll of count dice from a source. |
rollOpening | 関数 | The opening throw: one die for white and one for black. |
Rules | 型 | HOW A GAME IS SCORED AND STAKED, beside the variant's board. |
rulesProblems | 関数 | What goes wrong with a set of rules, as sentences; empty when they are fine. |
seededDice | 関数 | A SEEDED DICE SEQUENCE: the same seed is the same dice, one die after another, in every browser and every Node, so a game can be played again from its seed and a server can tell whether the dice a game says it had are the dice it should have had. |
seededRandom | 関数 | The mulberry32 stream: the same seed makes the same numbers everywhere. |
Settings | 型 | The settings of a game: the variant's row and the rules. |
settingsFor | 関数 | Settings from a variant key (or a row) and rules, left-out rules filled in. |
Side | 型 | THE TWO SIDES. |
sideIndex | 関数 | 0 for white and 1 for black: where a side's counts are kept in a position. |
SIDES | 定数 | Both sides, white first. |
sideToAct | 関数 | Whether a side is the one the computer would act for at this moment of a game: the side on turn, or the side that must answer a double. |
startCounts | 関数 | Which points a side's checkers start on, as an array indexed by own point 1 to 24 (index 0 is point 1). |
startGame | 関数 | The first game, or the next game, of a match. |
startPosition | 関数 | The position a variant starts from. |
startReserve | 関数 | How many checkers each side begins off the board, to be entered with the dice. |
stepComputer | 関数 | Carry out one step of what the computer would do, with dice from dice. |
Strength | 型 | THE COMPUTER PLAYER, in four strengths. |
STRENGTHS | 定数 | The strengths, weakest first. |
takeDouble | 関数 | Take the double that was offered. |
turnIsPlayed | 関数 | Whether the turn is played out and the side on turn has only to end it. |
undoMove | 関数 | Take back the last move made this turn. |
VARIANT_KEYS | 定数 | The variants' keys, in the order the demo lists them. |
VariantKey | 型 | THE VARIANTS, AS ROWS OF SETTINGS. |
VARIANTS | 定数 | Every variant. |
variantSpec | 関数 | The row for a variant. |
VariantSpec | 型 | A native variant’s checker counts, starting layout, dice, directions, opening and winning goal. |
VERSION | 定数 | The package's version. |
wantsToDouble | 関数 | Whether the computer, to move before it rolls, should offer a double. |
wantsToTake | 関数 | Whether the computer, doubled, should take. |
winChance | 関数 | A chance of winning, 0 to 1, that a score in pips stands for: the logistic curve, which a lead of 25 pips in a position of this kind takes to about three in four. |
winKind | 関数 | The kind of win a game that winner has won by bearing off is: single, gammon or backgammon, before the rules say what they count for. |
WinKind | 型 | What kind of win it was, which is how many times the cube's value it scores. |
withCounts | 関数 | A copy of a position with some counts changed. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。