@johnmorrisdotca/sugoroku 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +395 -77
- package/dist/board.d.ts +216 -12
- package/dist/board.js +204 -12
- package/dist/colours.d.ts +80 -8
- package/dist/colours.js +51 -6
- package/dist/computer.d.ts +138 -8
- package/dist/computer.js +109 -7
- package/dist/dice.d.ts +53 -4
- package/dist/dice.js +42 -3
- package/dist/draw.d.ts +43 -3
- package/dist/draw.js +33 -2
- package/dist/element-define.d.ts +1 -1
- package/dist/element-define.js +4 -13
- package/dist/element.d.ts +233 -3
- package/dist/element.js +402 -48
- package/dist/evaluate.d.ts +76 -4
- package/dist/evaluate.js +65 -3
- package/dist/game.d.ts +408 -23
- package/dist/game.js +328 -18
- package/dist/geometry.d.ts +50 -3
- package/dist/geometry.js +20 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/match.d.ts +66 -4
- package/dist/match.js +55 -4
- package/dist/mount.d.ts +75 -4
- package/dist/mount.js +25 -3
- package/dist/moves.d.ts +48 -1
- package/dist/moves.js +35 -1
- package/dist/notation.d.ts +92 -4
- package/dist/notation.js +82 -3
- package/dist/playStyle.d.ts +6 -0
- package/dist/playStyle.js +6 -0
- package/dist/plays.d.ts +108 -3
- package/dist/plays.js +96 -3
- package/dist/positionId.d.ts +29 -1
- package/dist/positionId.js +29 -1
- package/dist/random.d.ts +33 -3
- package/dist/random.js +22 -2
- package/dist/record.d.ts +150 -7
- package/dist/record.js +94 -5
- package/dist/rules.d.ts +130 -10
- package/dist/rules.js +99 -9
- package/dist/side.d.ts +38 -3
- package/dist/side.js +30 -3
- package/dist/sound.d.ts +61 -3
- package/dist/sound.js +27 -2
- package/dist/strings.d.ts +42 -2
- package/dist/strings.js +34 -2
- package/dist/style.d.ts +6 -0
- package/dist/style.js +6 -0
- package/dist/variants.d.ts +113 -8
- package/dist/variants.js +62 -5
- package/dist/version.d.ts +9 -2
- package/dist/version.js +9 -2
- package/package.json +27 -19
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,38 @@ All notable changes to this project are written here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.1.0] - 2026-10-14
|
|
10
|
+
|
|
11
|
+
The board and the position are custom elements with the family's standard embed attributes and a shared builder, and the package has an English and Japanese documentation site with a checked example for every export. The rules, dice, records and computer players are unchanged.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Add the bilingual documentation site, checked public examples, paired guides, local search and machine-readable pages.
|
|
16
|
+
- Add the shared embed builder and validated playable/position iframe routes. Preserve playable board methods and structured state while adding reflected attributes, host options and display sizes. Add a native SVG position element for GNU position IDs or JSON data; events now bubble across shadow roots with JSON-safe detail.
|
|
17
|
+
- Share a package-independent embed builder for option controls, preview adapters, code tabs and shareable links.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- The API link in the header reads "API" in English, so that the header takes the same number of rows in English and in Japanese on a phone, as the demo's test of a language change asks.
|
|
22
|
+
- Synchronize documentation tooling for repository layouts, generated type references, Node entry points and repository-specific README links.
|
|
23
|
+
- Keep complete resource catalogues on the documentation entry index and the active resource beside core navigation; render valid default imports in HTML and Markdown.
|
|
24
|
+
- Group the package family by kind, alphabetize each group, and include the geography packages and REST in Pieces in the shared footer and README.
|
|
25
|
+
- Update the shared family description for addresses in all seven supported countries, including France and Germany.
|
|
26
|
+
|
|
27
|
+
## [1.0.2] - 2026-10-06
|
|
28
|
+
|
|
29
|
+
Nothing that was exported has changed.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- The README takes the family's one layout, fully: a hero picture of the demo on a desk and on a phone in light and dark, a picture of the opening position of six variants, an Install section, an Examples section of twelve examples whose output is what they print (the notation, a record written and replayed, a record refused, the computer at four strengths, and more), and an Accessibility section. Its pictures are in `docs/images` (WebP, light and dark) and are retaken with `pnpm screenshots:readme` (it replaces `pnpm pictures` and the two JPEGs `docs/desktop.jpg` and `docs/phone.jpg`); they are not in the tarball, and `pnpm test:package` fails if one is.
|
|
34
|
+
- `pnpm test:readme` type-checks and runs every TypeScript and JavaScript example in the README against the built package, as a CI job of its own, and `pnpm check` holds the README to the family's lint (sections in order, a language on every fence, pictures with alt text, widths and captions, no marketing words, at most 64,000 characters, because npm shows only the first 65,536).
|
|
35
|
+
- Repository only: the package and everything it exports are unchanged. `CONTRIBUTING.md` is the family's one text with a section of its own for Sugoroku, held to the master in johnmorrisdotca/.github by `src/family.test.js`; `ci.yml` and `pages.yml` are the family's one text (`pnpm check`, the demo, and the package on Linux, macOS and Windows), and any jobs of the package's own after them.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- The API reference page wraps a long entry path instead of running about 2 px wider than a 360 px screen. Nothing the package exports has changed.
|
|
40
|
+
|
|
9
41
|
## [1.0.1] - 2026-10-05
|
|
10
42
|
|
|
11
43
|
Nothing that was exported has changed.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center">Sugoroku <sub>双六</sub
|
|
1
|
+
<h1 align="center">Sugoroku <sub>双六</sub> — Backgammon and its variants</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center"><strong>Backgammon and its variants for JavaScript and TypeScript.</strong><br>
|
|
4
4
|
The full rules, the doubling cube and match play with the Crawford rule, Nackgammon, Long Gammon, Hypergammon, Tabula, Anti-Backgammon and a race that starts from the bar, games written as text that a server can replay move by move, a seeded dice sequence, standard move notation, position IDs, a computer player in four strengths, and the board drawn as SVG and played by touch and mouse in any page with one call or one tag. No dependencies.</p>
|
|
@@ -8,14 +8,31 @@ The full rules, the doubling cube and match play with the Crawford rule, Nackgam
|
|
|
8
8
|
<a href="https://www.npmjs.com/package/@johnmorrisdotca/sugoroku"><img alt="npm" src="https://img.shields.io/npm/v/@johnmorrisdotca/sugoroku?color=2f5d4a"></a>
|
|
9
9
|
<a href="./LICENSE"><img alt="MIT licence" src="https://img.shields.io/badge/licence-MIT-2f5d4a"></a>
|
|
10
10
|
<img alt="No dependencies" src="https://img.shields.io/badge/dependencies-0-2f5d4a">
|
|
11
|
+
<img alt="TypeScript" src="https://img.shields.io/badge/types-TypeScript-3178c6">
|
|
12
|
+
<a href="https://johnmorrisdotca.github.io/sugoroku/docs/api/main/index.html"><img alt="11.6 kB minified and gzipped" src="https://img.shields.io/badge/min%2Bgzip-11.6%20kB-2f5d4a"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@johnmorrisdotca/sugoroku#provenance"><img alt="Published with npm provenance" src="https://img.shields.io/badge/npm-provenance-2f5d4a"></a>
|
|
11
14
|
</p>
|
|
12
15
|
|
|
13
|
-
<p align="center"><a href="https://johnmorrisdotca.github.io/sugoroku/"><strong>Play a game →</strong></a> · <a href="https://johnmorrisdotca.github.io/sugoroku/api.html">API reference</a> · <a href="docs/VARIANTS.md">The variants and their sources</a></p>
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
<p align="center"><a href="https://johnmorrisdotca.github.io/sugoroku/"><strong>Play a game →</strong></a> · <a href="https://johnmorrisdotca.github.io/sugoroku/docs/">Documentation</a> · <a href="https://johnmorrisdotca.github.io/sugoroku/docs/guides/getting-started.html">Getting started</a> · <a href="https://johnmorrisdotca.github.io/sugoroku/api.html">API reference</a> · <a href="docs/VARIANTS.md">The variants and their sources</a></p>
|
|
17
|
+
|
|
18
|
+
<table align="center">
|
|
19
|
+
<tr>
|
|
20
|
+
<td align="center" valign="top">
|
|
21
|
+
<picture>
|
|
22
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hero-desk-dark.webp">
|
|
23
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hero-desk-light.webp" alt="The demo on a desk, in English: the page's header with its language chooser, Docs link and cloth swatches, the game chooser (Backgammon, Race, Anti, Nackgammon, Long Gammon, Hypergammon, Tabula), the player choices, and a backgammon board in the middle of a match to 3 with the doubling cube at 2, black and white checkers on a green board with red and cream points, and the Roll dice, Double and Undo buttons under it." width="720">
|
|
24
|
+
</picture>
|
|
25
|
+
<br><em>A match to 3 against the computer, the cube at 2, on a desk.</em>
|
|
26
|
+
</td>
|
|
27
|
+
<td align="center" valign="top">
|
|
28
|
+
<picture>
|
|
29
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hero-phone-dark.webp">
|
|
30
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hero-phone-light.webp" alt="The demo on a phone, in Japanese, in the device's light or dark: the board standing up on its end, with the same match in progress and the three buttons under it." width="220">
|
|
31
|
+
</picture>
|
|
32
|
+
<br><em>The same board standing up on a phone, in Japanese.</em>
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
35
|
+
</table>
|
|
19
36
|
|
|
20
37
|
Sugoroku is the rules engine for backgammon and the games played on its board: the
|
|
21
38
|
classic game, and the relatives that ItsYourTurn.com and GoldToken.com played under their own
|
|
@@ -71,15 +88,101 @@ And in a page, a game to play against the computer, by touch and mouse, with not
|
|
|
71
88
|
- **English and Japanese** in the board's words and the demo.
|
|
72
89
|
- **No dependencies**, no network requests, and nothing stored outside the page it is in.
|
|
73
90
|
|
|
91
|
+
### What's in it
|
|
92
|
+
|
|
93
|
+
Each picture is a board drawn by the package's `drawSugoroku`, taken from [the demo](https://johnmorrisdotca.github.io/sugoroku/) with `pnpm screenshots:readme`, in light and dark: the opening position of six of the seven variants (Anti-Backgammon starts as the classic does). The hero is a seeded match, played up by the package's own computer. The pictures come again.
|
|
94
|
+
|
|
95
|
+
<table>
|
|
96
|
+
<tr>
|
|
97
|
+
<td align="center" valign="top" width="50%">
|
|
98
|
+
<picture>
|
|
99
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/backgammon-desk-dark.webp">
|
|
100
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/backgammon-desk-light.webp" alt="The classic backgammon board at the start: fifteen black and fifteen white checkers on the points of a green board with red and cream triangles, the bar down the middle, a cube in the middle of the left rail and a tray each side." width="400">
|
|
101
|
+
</picture>
|
|
102
|
+
<br><em><strong>Backgammon</strong>: fifteen each, two dice, bear off first.</em>
|
|
103
|
+
</td>
|
|
104
|
+
<td align="center" valign="top" width="50%">
|
|
105
|
+
<picture>
|
|
106
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/nackgammon-desk-dark.webp">
|
|
107
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/nackgammon-desk-light.webp" alt="A Nackgammon board at the start: the classic position with four back checkers on each side's 24-point instead of two." width="400">
|
|
108
|
+
</picture>
|
|
109
|
+
<br><em><strong>Nackgammon</strong>: four back checkers each, for a longer game.</em>
|
|
110
|
+
</td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td align="center" valign="top" width="50%">
|
|
114
|
+
<picture>
|
|
115
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/long-gammon-desk-dark.webp">
|
|
116
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/long-gammon-desk-light.webp" alt="A Long Gammon board at the start: all fifteen checkers of each side stacked on one point, the 24-point." width="400">
|
|
117
|
+
</picture>
|
|
118
|
+
<br><em><strong>Long Gammon</strong>: all fifteen start on the 24-point.</em>
|
|
119
|
+
</td>
|
|
120
|
+
<td align="center" valign="top" width="50%">
|
|
121
|
+
<picture>
|
|
122
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hypergammon-desk-dark.webp">
|
|
123
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/hypergammon-desk-light.webp" alt="A Hypergammon board at the start: three checkers each, on the 24, 23 and 22 points." width="400">
|
|
124
|
+
</picture>
|
|
125
|
+
<br><em><strong>Hypergammon</strong>: three checkers each.</em>
|
|
126
|
+
</td>
|
|
127
|
+
</tr>
|
|
128
|
+
<tr>
|
|
129
|
+
<td align="center" valign="top" width="50%">
|
|
130
|
+
<picture>
|
|
131
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/tabula-desk-dark.webp">
|
|
132
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/tabula-desk-light.webp" alt="A Tabula board at the start: fifteen checkers on each side waiting on the bar, and the track empty, in a dark-themed board." width="400">
|
|
133
|
+
</picture>
|
|
134
|
+
<br><em><strong>Tabula</strong>: the Roman game, three dice, both sides one way round.</em>
|
|
135
|
+
</td>
|
|
136
|
+
<td align="center" valign="top" width="50%">
|
|
137
|
+
<picture>
|
|
138
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/backgammon-race-desk-dark.webp">
|
|
139
|
+
<img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/backgammon-race-desk-light.webp" alt="A Backgammon Race board at the start: all fifteen checkers of both sides on the bar, none yet on the points." width="400">
|
|
140
|
+
</picture>
|
|
141
|
+
<br><em><strong>Backgammon Race</strong>: every checker enters from the bar.</em>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
</table>
|
|
145
|
+
|
|
74
146
|
## Use it in your project
|
|
75
147
|
|
|
148
|
+
### Install under another name
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
npm install backgammon@npm:@johnmorrisdotca/sugoroku
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```ts no-check
|
|
155
|
+
import { settingsFor } from "backgammon";
|
|
156
|
+
console.log(settingsFor("backgammon").variant);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Install
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
npm install @johnmorrisdotca/sugoroku
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
pnpm add @johnmorrisdotca/sugoroku
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
yarn add @johnmorrisdotca/sugoroku
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
A page with no bundler loads the board as a tag from a CDN, naming the major version so that a release that changes what you use is one you choose:
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/sugoroku@1/dist/element-define.js"></script>
|
|
177
|
+
```
|
|
178
|
+
|
|
76
179
|
Sugoroku is three things, each usable without the others: **the rules** (a position, a game, a match, text records, dice and the computer, as plain functions), **the drawing** (SVG text), and **the page** (a mounted board or a tag). The table at the end of [API](#api) says which entry holds which.
|
|
77
180
|
|
|
78
181
|
### 1. The API alone, on a server
|
|
79
182
|
|
|
80
183
|
A server that wants to be sure what was played takes the record the board keeps and replays it:
|
|
81
184
|
|
|
82
|
-
```ts
|
|
185
|
+
```ts no-check
|
|
83
186
|
import { replayRecord } from "@johnmorrisdotca/sugoroku";
|
|
84
187
|
|
|
85
188
|
const replayed = replayRecord(textFromTheBrowser);
|
|
@@ -145,7 +248,7 @@ import "@johnmorrisdotca/sugoroku/element/define";
|
|
|
145
248
|
<sugoroku-board bind:this={board} variant="backgammon" points="5" cube="on" gammons="on" black="strong"></sugoroku-board>
|
|
146
249
|
```
|
|
147
250
|
|
|
148
|
-
```ts
|
|
251
|
+
```ts no-check
|
|
149
252
|
// Angular: a standalone component with CUSTOM_ELEMENTS_SCHEMA
|
|
150
253
|
import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
|
|
151
254
|
import "@johnmorrisdotca/sugoroku/element/define";
|
|
@@ -171,6 +274,211 @@ These recipes are written to the tag's documented attributes and events; they ar
|
|
|
171
274
|
- **No dependencies.** ES modules, an entry per concern, and `sideEffects` set so that only the define entry has an effect.
|
|
172
275
|
- **Where it runs.** See [Browser support](#browser-support).
|
|
173
276
|
|
|
277
|
+
The cookbook, with the output of each example, is under [Examples](#examples).
|
|
278
|
+
|
|
279
|
+
### Embed builder
|
|
280
|
+
|
|
281
|
+
[Build a playable board or position](https://johnmorrisdotca.github.io/sugoroku/builder.html) and copy its embed code. The board adds `size` (small/medium/large), pixel `width`, spoken `label` and host `options`. Attributes reflect to properties; `game`, `match` and all board methods remain. `beaver` assignment changes the rule while `beaver()` retains its action.
|
|
282
|
+
|
|
283
|
+
`<sugoroku-position position="4HPwATDgc/ABMA" turn="white" size="small">` shows a GNU position ID or JSON position. Its structured `value`, drawing `options`, custom tags and all host formats are described in [the embed guide](docs/embeds.md).
|
|
284
|
+
|
|
285
|
+
## Examples
|
|
286
|
+
|
|
287
|
+
Every TypeScript and JavaScript block that can run is type-checked against the built package and run by `pnpm test:readme`, so the output after `// →` is what the code prints. The rules need no page and no network, so most of these run under Node.
|
|
288
|
+
|
|
289
|
+
### A page with nothing else
|
|
290
|
+
|
|
291
|
+
Save this as a file and open it: one script and one tag. The board is the whole game, a match against the computer, played by touch or mouse:
|
|
292
|
+
|
|
293
|
+
```html
|
|
294
|
+
<!doctype html>
|
|
295
|
+
<meta charset="utf-8">
|
|
296
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
297
|
+
<title>Backgammon</title>
|
|
298
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/sugoroku@1/dist/element-define.js"></script>
|
|
299
|
+
<sugoroku-board variant="nackgammon" points="5" cube gammons black="strong" seed="2026"></sugoroku-board>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Every play of a roll
|
|
303
|
+
|
|
304
|
+
`legalPlaysOf(game)` lists every different play of the dice in hand, so a board never has to know a rule; `formatPlay` writes one in standard notation. Here, after the opening throw of a 3 and a 2:
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
import { formatPlay, legalPlaysOf, newGame, openingFrom, rollOpening, seededDice, settingsFor } from "@johnmorrisdotca/sugoroku";
|
|
308
|
+
|
|
309
|
+
const dice = seededDice(2026); // the same dice in every browser and every Node
|
|
310
|
+
let game = newGame(settingsFor("backgammon"));
|
|
311
|
+
game = rollOpening(game, openingFrom(dice)); // a die each: the higher starts
|
|
312
|
+
console.log(game.turn, game.need); // → white [ 3, 2 ]
|
|
313
|
+
const plays = legalPlaysOf(game);
|
|
314
|
+
console.log(plays.length); // → 17
|
|
315
|
+
console.log(plays.slice(0, 3).map((play) => formatPlay(play.moves))); // → [ '24/21 24/22', '24/21 13/11', '24/21 8/6' ]
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### The computer, at four strengths
|
|
319
|
+
|
|
320
|
+
The four strengths are written for this package, and none of it is GPL. The same position, the same roll, and what each would play:
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
import { choosePlay, formatPlay, newGame, openingFrom, rollOpening, seededDice, settingsFor, STRENGTHS } from "@johnmorrisdotca/sugoroku";
|
|
324
|
+
|
|
325
|
+
let game = newGame(settingsFor("backgammon"));
|
|
326
|
+
game = rollOpening(game, openingFrom(seededDice(2026)));
|
|
327
|
+
for (const strength of STRENGTHS) console.log(strength, formatPlay(choosePlay(game, { strength, random: () => 0.5 }).moves));
|
|
328
|
+
// → random 13/10 6/4
|
|
329
|
+
// → greedy 13/10/8
|
|
330
|
+
// → careful 13/10/8
|
|
331
|
+
// → strong 13/10/8
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Does the computer want the cube?
|
|
335
|
+
|
|
336
|
+
`wantsToDouble` and `chanceOfWinning` are the computer's cube: where the sides are in contact, it doubles at 70 percent. At the start of a game it does not:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
import { chanceOfWinning, newGame, openingFrom, rollOpening, seededDice, settingsFor, wantsToDouble } from "@johnmorrisdotca/sugoroku";
|
|
340
|
+
|
|
341
|
+
let game = newGame(settingsFor("backgammon", { points: 3, cube: true }));
|
|
342
|
+
game = rollOpening(game, openingFrom(seededDice(2026)));
|
|
343
|
+
console.log(wantsToDouble(game, { strength: "strong" })); // → false
|
|
344
|
+
console.log(chanceOfWinning(game, "white").toFixed(2)); // → 0.56
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Write a record, and replay it on a server
|
|
348
|
+
|
|
349
|
+
A server that wants to be sure what was played takes the record the board keeps and replays it against the rules. `GameRecorder` writes one as a game is played; `replayRecord` checks every move, every double and every score, and the dice against the seed:
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
import { choosePlay, GameRecorder, newGame, openingFrom, replayRecord, rollOpening, seededDice, settingsFor } from "@johnmorrisdotca/sugoroku";
|
|
353
|
+
|
|
354
|
+
const settings = settingsFor("backgammon", { points: 3, cube: true, gammons: true });
|
|
355
|
+
const throws = openingFrom(seededDice(2026));
|
|
356
|
+
const game = rollOpening(newGame(settings), throws);
|
|
357
|
+
|
|
358
|
+
const recorder = new GameRecorder(settings, 2026);
|
|
359
|
+
recorder.startGame();
|
|
360
|
+
recorder.opening(throws);
|
|
361
|
+
recorder.turn(game.turn!, game.need, choosePlay(game, { strength: "careful", random: () => 0.5 }).moves);
|
|
362
|
+
const record = recorder.text();
|
|
363
|
+
console.log(record.split("\n").slice(-4, -1).join(" | ")); // → game 1 | open 3 2 | white 32: 13/10/8
|
|
364
|
+
const replayed = replayRecord(record);
|
|
365
|
+
console.log(replayed.ok, replayed.ok && replayed.current?.phase); // → true before-roll
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Refuse a record that was changed
|
|
369
|
+
|
|
370
|
+
A move the rules do not allow, or an opening throw that is not the seed's, is found at its line:
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import { replayRecord } from "@johnmorrisdotca/sugoroku";
|
|
374
|
+
|
|
375
|
+
const record = `sugoroku 1
|
|
376
|
+
variant backgammon
|
|
377
|
+
points 3
|
|
378
|
+
cube on
|
|
379
|
+
crawford on
|
|
380
|
+
jacoby off
|
|
381
|
+
beaver off
|
|
382
|
+
gammons on
|
|
383
|
+
seed 2026
|
|
384
|
+
game 1
|
|
385
|
+
open 3 2
|
|
386
|
+
white 32: 13/10/8
|
|
387
|
+
`;
|
|
388
|
+
const illegal = replayRecord(record.replace("13/10/8", "24/20 13/11"));
|
|
389
|
+
console.log(illegal.ok, !illegal.ok && illegal.line, !illegal.ok && illegal.reason);
|
|
390
|
+
// → false 12 "24/20 13/11" is not a legal play of 32
|
|
391
|
+
const changed = replayRecord(record.replace("open 3 2", "open 6 1"));
|
|
392
|
+
console.log(changed.ok, !changed.ok && changed.reason); // → false the opening throw is not the seed's
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Notation, and a position ID
|
|
396
|
+
|
|
397
|
+
Plays read and write as standard notation (`24/18 13/11`, `bar/22*`, `6/off`), and the standard board's position has the 14-character ID the GNU Backgammon manual gives it:
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
import { formatPlay, newGame, openingFrom, parsePlay, positionId, rollOpening, seededDice, settingsFor, VARIANTS } from "@johnmorrisdotca/sugoroku";
|
|
401
|
+
|
|
402
|
+
let game = newGame(settingsFor("backgammon"));
|
|
403
|
+
console.log(positionId(game.position, "white")); // → 4HPwATDgc/ABMA
|
|
404
|
+
game = rollOpening(game, openingFrom(seededDice(2026)));
|
|
405
|
+
const play = parsePlay(VARIANTS.backgammon, game.position, game.turn!, [3, 2], "24/21 13/11");
|
|
406
|
+
console.log(play && formatPlay(play)); // → 24/21 13/11
|
|
407
|
+
console.log(parsePlay(VARIANTS.backgammon, game.position, game.turn!, [3, 2], "24/20 13/11")); // → null: not a play of 3 and 2
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### The names of the two old sites
|
|
411
|
+
|
|
412
|
+
The names that ItsYourTurn and GoldToken printed are `PRESETS`, each a variant with its rules:
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
import { PRESETS, presetByName, settingsFor, VARIANT_KEYS, VARIANTS } from "@johnmorrisdotca/sugoroku";
|
|
416
|
+
|
|
417
|
+
console.log(VARIANT_KEYS.length, PRESETS.length); // → 7 22
|
|
418
|
+
const preset = presetByName("Pro Backgammon-9");
|
|
419
|
+
console.log(preset?.key, preset?.variant, preset?.rules.points); // → backgammon-9 backgammon 9
|
|
420
|
+
console.log(VARIANTS.tabula.dice); // → 3
|
|
421
|
+
console.log(settingsFor("hypergammon", { points: 3, cube: true, gammons: true }).rules.points); // → 3
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### The board as an image
|
|
425
|
+
|
|
426
|
+
`drawSugoroku` returns SVG text: a server that only checks a game never loads it, and a page can put it anywhere an image goes:
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
import { drawSugoroku } from "@johnmorrisdotca/sugoroku/draw";
|
|
430
|
+
import { newGame, settingsFor } from "@johnmorrisdotca/sugoroku";
|
|
431
|
+
|
|
432
|
+
const game = newGame(settingsFor("backgammon"));
|
|
433
|
+
const svg = drawSugoroku(game.position, { variant: "backgammon", numbers: true, board: "wood", style: true });
|
|
434
|
+
console.log(svg.startsWith("<svg"), svg.includes("class=\"sugoroku\"")); // → true true
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Mount a board, and listen
|
|
438
|
+
|
|
439
|
+
`mountSugoroku` is the tag as a function call; it keeps the match, the cube, undo and a record for you, and says what happens as events:
|
|
440
|
+
|
|
441
|
+
```ts no-run
|
|
442
|
+
import { mountSugoroku } from "@johnmorrisdotca/sugoroku/play";
|
|
443
|
+
|
|
444
|
+
const element = document.getElementById("board")!;
|
|
445
|
+
const board = mountSugoroku(element, {
|
|
446
|
+
variant: "nackgammon",
|
|
447
|
+
rules: { points: 5, cube: true, gammons: true },
|
|
448
|
+
computer: { black: "strong" }, // either side, or both, or neither
|
|
449
|
+
seed: 2026, // the dice from a seed; left out, random
|
|
450
|
+
sound: true,
|
|
451
|
+
});
|
|
452
|
+
element.addEventListener("sugoroku-turn", (event) => console.log((event as CustomEvent).detail.notation));
|
|
453
|
+
element.addEventListener("sugoroku-end", () => fetch("/matches", { method: "POST", body: board.record() }));
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Dice from your own server
|
|
457
|
+
|
|
458
|
+
With `dice: "host"` the board asks the page for its dice instead of rolling, so a server can be the one that throws them:
|
|
459
|
+
|
|
460
|
+
```ts no-run
|
|
461
|
+
import { mountSugoroku } from "@johnmorrisdotca/sugoroku/play";
|
|
462
|
+
|
|
463
|
+
const element = document.getElementById("board")!;
|
|
464
|
+
const board = mountSugoroku(element, { variant: "backgammon", dice: "host" });
|
|
465
|
+
element.addEventListener("sugoroku-need-dice", async () => {
|
|
466
|
+
const { dice } = await (await fetch("/roll")).json();
|
|
467
|
+
board.roll(dice); // for example [3, 1]
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### A look of your own
|
|
472
|
+
|
|
473
|
+
Every colour is a CSS variable on `.sugoroku`, set by the page (the table is under [Theming](#theming)); a named board (`board: "wood"`) and a set of checkers (`checkers: "contrast"`) come with the package:
|
|
474
|
+
|
|
475
|
+
```css
|
|
476
|
+
sugoroku-board .sugoroku {
|
|
477
|
+
--sg-felt: #1d4e5f;
|
|
478
|
+
--sg-frame: #4a2f1b;
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
174
482
|
## The variants
|
|
175
483
|
|
|
176
484
|
Each is a row of settings: how many checkers, where they start, how many dice, how doubles
|
|
@@ -319,7 +627,7 @@ sides are still in contact (`careful` and `strong` only; `greedy` takes and neve
|
|
|
319
627
|
there) the evaluation becomes a chance of winning (`winChance`) and it doubles at 70% and
|
|
320
628
|
takes at 25%. It never beavers, and never doubles at Tabula or in a game played to lose.
|
|
321
629
|
|
|
322
|
-
```ts
|
|
630
|
+
```ts no-check
|
|
323
631
|
import { choosePlay, computerAction, stepComputer, wantsToDouble } from "@johnmorrisdotca/sugoroku";
|
|
324
632
|
|
|
325
633
|
choosePlay(game, { strength: "careful" }); // { moves, position }: the rest of the turn, chosen
|
|
@@ -329,7 +637,7 @@ stepComputer(game, dice); // does it, with dice from a so
|
|
|
329
637
|
|
|
330
638
|
## Drawing
|
|
331
639
|
|
|
332
|
-
```ts
|
|
640
|
+
```ts no-check
|
|
333
641
|
import { drawSugoroku, SUGOROKU_STYLE } from "@johnmorrisdotca/sugoroku/draw";
|
|
334
642
|
|
|
335
643
|
const svg = drawSugoroku(game.position, {
|
|
@@ -363,7 +671,7 @@ drawing, so it stands alone as an image).
|
|
|
363
671
|
|
|
364
672
|
## Playing in a page
|
|
365
673
|
|
|
366
|
-
```ts
|
|
674
|
+
```ts no-check
|
|
367
675
|
import { mountSugoroku } from "@johnmorrisdotca/sugoroku/play";
|
|
368
676
|
|
|
369
677
|
const board = mountSugoroku(element, {
|
|
@@ -401,6 +709,8 @@ page's `lang`.
|
|
|
401
709
|
|
|
402
710
|
## API
|
|
403
711
|
|
|
712
|
+
The [documentation](https://johnmorrisdotca.github.io/sugoroku/docs/) provides paired guides, local search and checked examples. The [API index](https://johnmorrisdotca.github.io/sugoroku/api.html) retains export anchors.
|
|
713
|
+
|
|
404
714
|
| Export | What it does |
|
|
405
715
|
| --- | --- |
|
|
406
716
|
| `otherSide(side)`, `sideIndex(side)`, `SIDES` | the two sides, `white` and `black`, and where a side's counts are kept |
|
|
@@ -509,6 +819,19 @@ All of these are held by tests, and the ones with a name are exported.
|
|
|
509
819
|
|
|
510
820
|
The look-ahead is held to a time budget, not to a count of moves: a position of hundreds of plays, such as a double, stays well under a tenth of a second.
|
|
511
821
|
|
|
822
|
+
## Accessibility
|
|
823
|
+
|
|
824
|
+
Backgammon is played by sight and by touch, so what a person who cannot see the board hears, and what a person who cannot drag can do, matter. What is done, and what is not, in the mounted board and the tag:
|
|
825
|
+
|
|
826
|
+
- **Tap or drag.** A checker is picked up with a tap and put down with a tap on a point (the places it may go light up), or dragged; no move needs a drag, and nothing needs two fingers or a double tap. A turn may be undone move by move until Done.
|
|
827
|
+
- **The board says what is happening.** A line under the board says whose turn it is, what the dice are, and what is wanted next ("Your roll.", "Roll the dice: the higher die goes first."), and the score and the cube are a line of text above it. The words are English or Japanese by the page's `lang`.
|
|
828
|
+
- **Buttons are big.** The three buttons are one size in the same places whatever they say, and each is at least 48 pixels high.
|
|
829
|
+
- **Not by colour alone.** The two sides differ in lightness (cream and dark checkers), the cube and the dice show numbers, the checker picked up and the points it may go to are marked by a ring and a mark, and every point can carry its number (`numbers: true`).
|
|
830
|
+
- **Motion.** Nothing on the board animates. Under a request for reduced motion the computer answers at once instead of after a pause of 450 milliseconds, and the board is steady in size whatever is on it, so a page does not shift as a game goes on.
|
|
831
|
+
- **Contrast.** There are five boards and four sets of checkers, one of them `contrast`, and every colour is a CSS variable.
|
|
832
|
+
- **Without a pointer.** The engine decides every legal play (`legalPlaysOf`) and writes it in notation (`formatPlay`), so a host can offer the plays as a list or a text box; the board's own points and checkers are not yet reachable by keyboard, and a screen reader hears the board as a drawing with a status line beside it.
|
|
833
|
+
- **Known to fall short.** No keyboard play on the mounted board; the Japanese words have not been read by a native reader ([Languages](#languages)).
|
|
834
|
+
|
|
512
835
|
## Browser support
|
|
513
836
|
|
|
514
837
|
Any browser with ES2020 modules, custom elements, Pointer Events, `ResizeObserver` and CSS `color-mix`: Chrome and Edge 111, Safari 16.2, Firefox 113, all from early 2023. The element draws in the page's own DOM, with no shadow DOM. The demo is played in a real Chromium at a phone's width (with touch) and a desk's, and in WebKit, Safari's engine, at a phone's width; Firefox is not in that run. The package itself (the rules, the formats and the computer) needs no DOM: it runs in Node 22 or later (CI tests 22 and 24). Deno and Bun are not tested. The sounds need `Audio` and are off unless asked for.
|
|
@@ -528,50 +851,7 @@ Left out on purpose: play over a network, which needs a server (a record is plai
|
|
|
528
851
|
|
|
529
852
|
## Architecture
|
|
530
853
|
|
|
531
|
-
The
|
|
532
|
-
drawing and the playable board are separate entries.
|
|
533
|
-
|
|
534
|
-
```text
|
|
535
|
-
src/
|
|
536
|
-
├── index.ts the main entry: everything but the drawing and the page
|
|
537
|
-
├── side.ts the two sides, white and black
|
|
538
|
-
├── variants.ts every variant as a row of settings
|
|
539
|
-
├── rules.ts the rules a name adds (match, cube, Crawford, Jacoby, gammons), and the named presets
|
|
540
|
-
├── board.ts a position as plain data: counts, pips, the start, which point is which
|
|
541
|
-
├── moves.ts every move of one die, and what a move does
|
|
542
|
-
├── plays.ts whole turns: the dice that must be played, every different play, what may be played next
|
|
543
|
-
├── game.ts a game in play: the opening, a roll, a move, undo, the cube, giving up, the result
|
|
544
|
-
├── match.ts a match: the score, the Crawford game, the end
|
|
545
|
-
├── random.ts the seeded random numbers
|
|
546
|
-
├── dice.ts seeded dice, and dice from the device
|
|
547
|
-
├── notation.ts moves and positions as text, and reading a written play back
|
|
548
|
-
├── positionId.ts position IDs for the standard board
|
|
549
|
-
├── record.ts games as text: written as they are played, and replayed against the rules
|
|
550
|
-
├── evaluate.ts how good a position is: pips, blots, points, primes, anchors, the Keith count
|
|
551
|
-
├── computer.ts the computer's play and cube, in four strengths
|
|
552
|
-
├── colours.ts the colours a board is made of, and the named boards and checkers
|
|
553
|
-
├── geometry.ts where everything is on the drawn board, lying down or standing up
|
|
554
|
-
├── style.ts the style that makes the drawing a board, and keeps it from being selected
|
|
555
|
-
├── draw.ts the board as SVG text
|
|
556
|
-
├── draw-entry.ts the "/draw" entry: everything that draws
|
|
557
|
-
├── strings.ts the words, in English and Japanese
|
|
558
|
-
├── sound.ts the optional sounds
|
|
559
|
-
├── playStyle.ts the style of the playable board
|
|
560
|
-
├── mount.ts a board to play in any element: touch, mouse, buttons, computer, events, record
|
|
561
|
-
├── play-entry.ts the "/play" entry
|
|
562
|
-
├── element.ts the <sugoroku-board> class
|
|
563
|
-
├── element-define.ts defines the tag on the page
|
|
564
|
-
└── version.ts the package's version
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
Tests sit beside the code they test (`*.test.ts`). The rules are held to `brute.fixture.ts`,
|
|
568
|
-
which tries every order of the dice and every move on thousands of positions of every
|
|
569
|
-
variant; `simulate.test.ts` plays thousands of games to their end, at random and by the
|
|
570
|
-
computer, and checks that every checker is accounted for and the pips move by what was
|
|
571
|
-
played; and a game written down must replay to the same result. `scripts/` builds the demo
|
|
572
|
-
and checks the package as npm packs it; `demo/` is the playable page and `e2e/` plays it in
|
|
573
|
-
real browsers (Chromium and WebKit, at a phone's width and a desk's). The sounds are in
|
|
574
|
-
`sounds/`; `docs/VARIANTS.md` says how each variant was read.
|
|
854
|
+
The board, move, turn, game and match layers, record validation and drawing are explained in the [architecture guide](docs/guides/architecture.md), which preserves the complete source tree.
|
|
575
855
|
|
|
576
856
|
## The name
|
|
577
857
|
|
|
@@ -604,47 +884,83 @@ Nobody is listed yet. Using Sugoroku in something? Open an *Add my project* issu
|
|
|
604
884
|
### The family
|
|
605
885
|
|
|
606
886
|
<!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
|
|
607
|
-
Sugoroku is one of
|
|
608
|
-
[github.com/johnmorrisdotca](https://github.com/johnmorrisdotca). The code of every one is MIT.
|
|
887
|
+
Sugoroku is one of thirty-two packages, each made for the same site, each at
|
|
888
|
+
[github.com/johnmorrisdotca](https://github.com/johnmorrisdotca) or [github.com/spxis](https://github.com/spxis). The code of every one is MIT.
|
|
609
889
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
- [
|
|
613
|
-
- [
|
|
614
|
-
- [Tane](https://github.com/johnmorrisdotca/tane) (種): seeded random numbers and daily seeds, the same in every browser and on every server. [Demo](https://johnmorrisdotca.github.io/tane/).
|
|
890
|
+
**Games — board**
|
|
891
|
+
|
|
892
|
+
- [Domino](https://github.com/johnmorrisdotca/domino) (ドミノ): dominoes and Mexican Train. [Demo](https://johnmorrisdotca.github.io/domino/).
|
|
893
|
+
- [Gunjin](https://github.com/johnmorrisdotca/gunjin) (軍人): five hidden-rank strategy games with pass-the-device play. [Demo](https://johnmorrisdotca.github.io/gunjin/).
|
|
615
894
|
- [Narabe](https://github.com/johnmorrisdotca/narabe) (並べ): one rules engine for abstract board games, from gomoku and Reversi to Go and checkers. [Demo](https://johnmorrisdotca.github.io/narabe/).
|
|
895
|
+
- [Sugoroku](https://github.com/johnmorrisdotca/sugoroku) (双六): backgammon and its variants, with the doubling cube and match play. [Demo](https://johnmorrisdotca.github.io/sugoroku/).
|
|
616
896
|
- [Tenka](https://github.com/johnmorrisdotca/tenka) (天下): world conquest for two to six, on a map of the real world. [Demo](https://johnmorrisdotca.github.io/tenka/).
|
|
617
|
-
|
|
618
|
-
|
|
897
|
+
|
|
898
|
+
**Games — cards & tiles**
|
|
899
|
+
|
|
900
|
+
- [Hitotsu](https://github.com/johnmorrisdotca/hitotsu) (一つ): a colour-card shedding game for two to eight, with the house rules people play. [Demo](https://johnmorrisdotca.github.io/hitotsu/).
|
|
619
901
|
- [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
|
|
620
|
-
- [
|
|
621
|
-
- [
|
|
622
|
-
|
|
623
|
-
|
|
902
|
+
- [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
|
|
903
|
+
- [Toranpu](https://github.com/johnmorrisdotca/toranpu) (トランプ): a deck of playing cards, card games with computer players, and solitaires. [Demo](https://johnmorrisdotca.github.io/toranpu/).
|
|
904
|
+
|
|
905
|
+
**Games — puzzles**
|
|
906
|
+
|
|
907
|
+
- [Houseki](https://github.com/johnmorrisdotca/houseki) (宝石): gem and stone matching puzzles: falling triplets, stone collapse, colour chains and gem swap. [Demo](https://johnmorrisdotca.github.io/houseki/).
|
|
908
|
+
- [Jirai](https://github.com/johnmorrisdotca/jirai) (地雷): minesweeper on shaped grids with verified no-guess boards. [Demo](https://johnmorrisdotca.github.io/jirai/).
|
|
909
|
+
- [Karakuri](https://github.com/johnmorrisdotca/karakuri) (からくり): eight hyper-casual puzzle games, some of them physics: draw a shield, pull pins, cut ropes, slide blocks, pour tubes. [Demo](https://johnmorrisdotca.github.io/karakuri/).
|
|
624
910
|
- [Kazu](https://github.com/johnmorrisdotca/kazu) (数): grid number puzzles: Sudoku and its variants, Futoshiki and Skyscrapers. [Demo](https://johnmorrisdotca.github.io/kazu/).
|
|
911
|
+
- [Kyuubu](https://github.com/johnmorrisdotca/kyuubu) (キューブ): a turning cube for the browser, 2×2 to 7×7, with record solves to replay. [Demo](https://johnmorrisdotca.github.io/kyuubu/).
|
|
625
912
|
- [Meikyuu](https://github.com/johnmorrisdotca/meikyuu) (迷宮): mazes on squares, hexagons, triangles and circles, made from a seed and drawn through with a finger or the mouse. [Demo](https://johnmorrisdotca.github.io/meikyuu/).
|
|
913
|
+
- [Suido](https://github.com/johnmorrisdotca/suido) (水道): a pipe puzzle: turn the pieces until the water reaches every drain. [Demo](https://johnmorrisdotca.github.io/suido/).
|
|
914
|
+
- [Tobiishi](https://github.com/johnmorrisdotca/tobiishi) (飛び石): peg solitaire with nine boards and seeded solvable challenges. [Demo](https://johnmorrisdotca.github.io/tobiishi/).
|
|
915
|
+
- [Tsunagi](https://github.com/johnmorrisdotca/tsunagi) (繋ぎ): a line-joining logic puzzle whose every level has exactly one answer. [Demo](https://johnmorrisdotca.github.io/tsunagi/).
|
|
916
|
+
|
|
917
|
+
**Games — dice & random**
|
|
918
|
+
|
|
919
|
+
- [Korokoro](https://github.com/johnmorrisdotca/korokoro) (コロコロ): dice, with notation, exact odds, real sounds and the dice of many games. [Demo](https://johnmorrisdotca.github.io/korokoro/).
|
|
920
|
+
- [Tane](https://github.com/johnmorrisdotca/tane) (種): seeded random numbers and daily seeds, the same in every browser and on every server. [Demo](https://johnmorrisdotca.github.io/tane/).
|
|
921
|
+
|
|
922
|
+
**Language**
|
|
923
|
+
|
|
924
|
+
- [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
|
|
626
925
|
- [Hikidashi](https://github.com/johnmorrisdotca/hikidashi) (引き出し): a drawer of small Japanese text tools: era dates, kanji numerals, readings and sentence difficulty. [Demo](https://johnmorrisdotca.github.io/hikidashi/).
|
|
926
|
+
- [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
|
|
927
|
+
|
|
928
|
+
**Geography & data**
|
|
929
|
+
|
|
930
|
+
- [address-plus](https://github.com/johnmorrisdotca/address-plus) (アドレスプラス): parse and format addresses in the United States, Canada, Japan, Australia, France, Germany and the United Kingdom. [Demo](https://johnmorrisdotca.github.io/address-plus/).
|
|
627
931
|
- [Chizu](https://github.com/johnmorrisdotca/chizu) (地図): maps of the world and of countries' regions, in English and Japanese, with a quiz and callouts. [Demo](https://johnmorrisdotca.github.io/chizu/).
|
|
628
|
-
- [
|
|
629
|
-
- [
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
- [
|
|
932
|
+
- [Hata](https://github.com/johnmorrisdotca/hata) (旗): country and regional flags as SVG, at their true proportions and keyed by ISO code. [Demo](https://johnmorrisdotca.github.io/hata/).
|
|
933
|
+
- [Kuni](https://github.com/johnmorrisdotca/kuni) (国): countries and their regions, with ISO codes and names in English and Japanese. [Demo](https://johnmorrisdotca.github.io/kuni/).
|
|
934
|
+
|
|
935
|
+
**Sports**
|
|
936
|
+
|
|
937
|
+
- [Dougu Sports](https://github.com/johnmorrisdotca/dougu-sports) (道具): sports emblems as SVG: trophies, medals, crests, and the ball and gear of every sport, with optional 3D turning. [Demo](https://johnmorrisdotca.github.io/dougu-sports/).
|
|
938
|
+
- [Kyogijo Stadiums](https://github.com/johnmorrisdotca/kyogijo-stadiums) (競技場): sports fields, rinks, courts and ballparks drawn to scale as SVG, with each team and the score on them. [Demo](https://johnmorrisdotca.github.io/kyogijo-stadiums/).
|
|
939
|
+
- [Senshu Jerseys](https://github.com/johnmorrisdotca/senshu-jerseys) (選手): sports jerseys, sweaters, kits, caps, helmets and retired-number banners as SVG, front and back, with optional 2.5D turning. [Demo](https://johnmorrisdotca.github.io/senshu-jerseys/).
|
|
940
|
+
- [Taisen Brackets](https://github.com/johnmorrisdotca/taisen-brackets) (対戦): a sport-agnostic tournament bracket, drawn as SVG, from a list of ties. [Demo](https://johnmorrisdotca.github.io/taisen-brackets/).
|
|
634
941
|
|
|
635
|
-
**
|
|
942
|
+
**Developer tools**
|
|
943
|
+
|
|
944
|
+
- [REST in Pieces](https://github.com/spxis/rest-in-pieces) (レスト・イン・ピーシーズ): seeded test data and REST APIs for frontend development, with latency and error drills. [Demo](https://spxis.github.io/rest-in-pieces/).
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
**This package is Sugoroku.** The demos of all thirty-two share one header and footer, so each links the rest.
|
|
636
948
|
<!-- family:end -->
|
|
637
949
|
|
|
638
950
|
## Development
|
|
639
951
|
|
|
640
952
|
```sh
|
|
641
|
-
pnpm install
|
|
953
|
+
pnpm install --frozen-lockfile
|
|
642
954
|
pnpm check # lint, types and every test
|
|
643
955
|
pnpm test:package # pack, install and import it as somebody who installed it would
|
|
644
956
|
pnpm site # build the demo into site/, as the Pages workflow publishes it
|
|
645
957
|
pnpm test:demo # play the demo in Chromium and WebKit
|
|
958
|
+
pnpm test:readme # every TypeScript and JavaScript example in this README, type-checked and run
|
|
959
|
+
pnpm screenshots:readme # retake the README's pictures into docs/images (builds the demo first)
|
|
646
960
|
```
|
|
647
961
|
|
|
962
|
+
The pictures are taken on the maintainer's Mac and are retaken only when the look changes; they are in `docs/images` and are not in the package that npm installs.
|
|
963
|
+
|
|
648
964
|
## Contributing
|
|
649
965
|
|
|
650
966
|
See [CONTRIBUTING.md](./CONTRIBUTING.md). The commands are under [Development](#development).
|
|
@@ -655,6 +971,8 @@ Please follow the [code of conduct](./CODE_OF_CONDUCT.md). A record or a positio
|
|
|
655
971
|
|
|
656
972
|
See [CHANGELOG.md](./CHANGELOG.md).
|
|
657
973
|
|
|
974
|
+
The latest release is 1.1.0: the board and position as elements, the shared embed builder, and the documentation site with a checked example for every export.
|
|
975
|
+
|
|
658
976
|
## Licence
|
|
659
977
|
|
|
660
978
|
MIT, © John Morris. The board is drawn in code. The sounds are from [Casino Audio by
|