Skip to the content

Sugoroku双六

Play backgammon and its relatives with native rules, cube and match scoring, seeded dice and replayable records.

Sugoroku is the Japanese name 双六 for games of tables. About the name

Contents

Reference · SVG boards and notation

BoardLayoutclass

The layout of a board, a function of its options: where each point, the bar, each tray, the rail and the dice sit, all in landscape units.

Import it

import { BoardLayout } from "@johnmorrisdotca/sugoroku/draw";

Definition

class BoardLayout
new BoardLayout(options: BoardOptions): BoardLayout

Parameters

NameTypeDescription
optionsBoardOptions

Cube rail, viewing side, home direction and board orientation.

Members

NameTypeDescription
widthnumber
heightnumber
fieldTopnumber
optionsBoardOptions
mx(x: number, w?: number): number

An x, for something w wide, after the board is mirrored for trays on the left.

fieldLeftnumber

The x the field of points starts at, before mirroring.

fieldHeightnumber
barLeftnumber
trayLeftnumber
slotOf(point: number): { top: boolean; col: number; }

Which slot of the drawing a point of the board is in: its row (the top row or the bottom) and its column from the left, 0 to 11. The board's points are counted the way white counts: 1 to 12 along the bottom from the right, and 13 to 24 along the top from the left. Seen from black's side the rows change places.

columnLeft(col: number): number

The x of the left edge of column col, before mirroring.

pointBox(point: number): Box & { top: boolean; }

The box of a point, as a base on its edge of the field and its length.

trayBox(side: Side): Box & { top: boolean; }

The tray of a side: the bottom one is white's when seen from white's side.

barBox(side: Side): Box & { top: boolean; }

The half of the bar a side's checkers wait in: the nearer half to the side's own tray.

cubeBox(owner: Side | null): Box

Where the cube rests: the middle of the rail, or the end of it nearer its owner.

diceCentre(side: Side): { x: number; y: number; }

The middle of the row of dice, on the half of the board a side plays from: its own home half for white, the other for black.

Examples

import { BoardLayout } from "@johnmorrisdotca/sugoroku/draw";

const layout = new BoardLayout({cube:true,view:"white",home:"right",orientation:"landscape"});
console.log(layout);
BoardLayout {
  width: 976,
  height: 552,
  fieldTop: 32,
  options: {
    cube: true,
    view: 'white',
    home: 'right',
    orientation: 'landscape'
  }
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/sugoroku 1.1.1.