@johnmorrisdotca/kumimoji 1.2.2 → 1.3.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 +21 -1
- package/README.md +80 -39
- package/dist/check.d.ts +26 -1
- package/dist/check.js +26 -1
- package/dist/computer.types.d.ts +24 -2
- package/dist/computerPlay.d.ts +45 -2
- package/dist/computerPlay.js +45 -2
- package/dist/computerTurn.d.ts +42 -3
- package/dist/computerTurn.js +42 -3
- package/dist/daily.d.ts +22 -2
- package/dist/daily.js +22 -2
- package/dist/element-define.d.ts +1 -1
- package/dist/element-define.js +3 -13
- package/dist/element.d.ts +85 -4
- package/dist/element.js +176 -45
- package/dist/embed-day.d.ts +4 -0
- package/dist/embed-day.js +23 -0
- package/dist/export.d.ts +123 -6
- package/dist/export.js +91 -4
- package/dist/generate.d.ts +14 -0
- package/dist/generate.js +14 -0
- package/dist/grid.d.ts +181 -10
- package/dist/grid.js +122 -7
- package/dist/help.d.ts +36 -3
- package/dist/help.js +36 -3
- package/dist/judge.d.ts +14 -0
- package/dist/judge.js +14 -0
- package/dist/kana.d.ts +23 -1
- package/dist/kana.js +23 -1
- package/dist/kumimoji.types.d.ts +70 -5
- package/dist/party.d.ts +268 -14
- package/dist/party.js +268 -14
- package/dist/party.types.d.ts +50 -2
- package/dist/partyKept.d.ts +74 -4
- package/dist/partyKept.js +74 -4
- package/dist/partySeats.d.ts +92 -6
- package/dist/partySeats.js +72 -4
- package/dist/partyTurns.d.ts +171 -5
- package/dist/partyTurns.js +171 -5
- package/dist/placement.d.ts +50 -2
- package/dist/placement.js +30 -0
- package/dist/play.d.ts +247 -15
- package/dist/play.js +237 -15
- package/dist/random.d.ts +34 -3
- package/dist/random.js +23 -2
- package/dist/react.d.ts +42 -4
- package/dist/react.js +22 -5
- package/dist/showcase.d.ts +83 -7
- package/dist/showcase.js +49 -4
- package/dist/strings.d.ts +54 -5
- package/dist/strings.js +34 -3
- package/dist/tableView.d.ts +151 -8
- package/dist/tableView.js +129 -6
- package/dist/tileFace.d.ts +59 -5
- package/dist/tileFace.js +48 -4
- package/dist/tileFamily.d.ts +9 -0
- package/dist/tileFamily.js +9 -0
- package/dist/tileWords.d.ts +93 -6
- package/dist/tileWords.js +83 -6
- package/dist/tileWordsModule.d.ts +11 -1
- package/dist/tileWordsModule.js +11 -1
- package/dist/tiles.constants.d.ts +99 -5
- package/dist/tiles.constants.js +99 -5
- package/dist/turn.d.ts +82 -4
- package/dist/turn.js +82 -4
- package/dist/ui/board.d.ts +60 -5
- package/dist/ui/board.js +28 -2
- package/dist/ui/mount.d.ts +41 -2
- package/dist/ui/mount.js +38 -1
- package/dist/ui/style.d.ts +6 -1
- package/dist/ui/style.js +6 -0
- package/dist/version.d.ts +9 -2
- package/dist/version.js +9 -2
- package/dist/wilds.d.ts +22 -1
- package/dist/wilds.js +22 -1
- package/package.json +64 -56
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ All notable changes to this project are written down here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.3.0] - 2026-10-14
|
|
10
|
+
|
|
11
|
+
The table is a custom element 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, generation, seeds and saved games 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 crossword-table builder and validated iframe route with reflected settings and display options. Preserve native saved/table access and gameplay methods; presentation updates now retain play.
|
|
17
|
+
- Add native ready/set, optional initial saved state, control visibility and localized load failures, forwarded by the React wrapper. Preserve event shapes with composed JSON-safe snapshots and add load/error events.
|
|
18
|
+
- Share a package-independent embed builder for option controls, preview adapters, code tabs and shareable links.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Synchronize documentation tooling for repository layouts, generated type references, Node entry points and repository-specific README links.
|
|
23
|
+
- Keep large documentation resource catalogues on the entry index and the active resource beside core navigation, preserving every reference page; render valid default imports in HTML and Markdown.
|
|
24
|
+
- The props table of `KumimojiBoard` moved from the README to `docs/react.md`, so that the README, which now lists the sports packages too, stays under npm's 65,536 characters; the README keeps a summary and a link.
|
|
25
|
+
- Group the package family by kind, alphabetize each group, and include the geography packages and REST in Pieces in the shared footer and README.
|
|
26
|
+
- Update the shared family description for addresses in all seven supported countries, including France and Germany.
|
|
27
|
+
|
|
9
28
|
## [1.2.2] - 2026-10-06
|
|
10
29
|
|
|
11
30
|
Nothing that was exported has changed.
|
|
@@ -157,7 +176,8 @@ The first release.
|
|
|
157
176
|
`@johnmorrisdotca/kumimoji/react`.
|
|
158
177
|
- A static demo for GitHub Pages.
|
|
159
178
|
|
|
160
|
-
[Unreleased]: https://github.com/johnmorrisdotca/kumimoji/compare/v1.
|
|
179
|
+
[Unreleased]: https://github.com/johnmorrisdotca/kumimoji/compare/v1.3.0...HEAD
|
|
180
|
+
[1.3.0]: https://github.com/johnmorrisdotca/kumimoji/compare/v1.2.2...v1.3.0
|
|
161
181
|
[1.2.1]: https://github.com/johnmorrisdotca/kumimoji/compare/v1.2.0...v1.2.1
|
|
162
182
|
[1.1.1]: https://github.com/johnmorrisdotca/kumimoji/compare/v1.1.0...v1.1.1
|
|
163
183
|
[1.1.0]: https://github.com/johnmorrisdotca/kumimoji/releases/tag/v1.1.0
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center">Kumimoji <sub>組み文字</sub
|
|
1
|
+
<h1 align="center">Kumimoji <sub>組み文字</sub> — Crossword tile game in English and Japanese</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center"><strong>The crossword tile race: a word game where you build one crossword from a bag of letter tiles.</strong><br>
|
|
4
4
|
In English and in Japanese kana. The rules as pure, seeded TypeScript, two word lists, a computer player, and a table to play on in React, Vue, Svelte, Angular or plain HTML.</p>
|
|
@@ -10,9 +10,11 @@ In English and in Japanese kana. The rules as pure, seeded TypeScript, two word
|
|
|
10
10
|
<a href="./NOTICE.md"><img alt="Japanese word list: CC BY-SA 4.0" src="https://img.shields.io/badge/Japanese%20words-CC%20BY--SA%204.0-b5452c"></a>
|
|
11
11
|
<img alt="No dependencies" src="https://img.shields.io/badge/dependencies-0-2f5d4a">
|
|
12
12
|
<img alt="TypeScript" src="https://img.shields.io/badge/types-TypeScript-3178c6">
|
|
13
|
+
<a href="https://johnmorrisdotca.github.io/kumimoji/docs/api/main/index.html"><img alt="679.1 kB minified and gzipped" src="https://img.shields.io/badge/min%2Bgzip-679.1%20kB-2f5d4a"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@johnmorrisdotca/kumimoji#provenance"><img alt="Published with npm provenance" src="https://img.shields.io/badge/npm-provenance-2f5d4a"></a>
|
|
13
15
|
</p>
|
|
14
16
|
|
|
15
|
-
<p align="center"><a href="https://johnmorrisdotca.github.io/kumimoji/"><strong>Play a game →</strong></a> · <a href="https://johnmorrisdotca.github.io/kumimoji/api.html">API reference</a> · <a href="docs/API.md">The API in full</a></p>
|
|
17
|
+
<p align="center"><a href="https://johnmorrisdotca.github.io/kumimoji/"><strong>Play a game →</strong></a> · <a href="https://johnmorrisdotca.github.io/kumimoji/docs/">Documentation</a> · <a href="https://johnmorrisdotca.github.io/kumimoji/docs/guides/getting-started.html">Getting started</a> · <a href="https://johnmorrisdotca.github.io/kumimoji/api.html">API reference</a> · <a href="docs/API.md">The API in full</a></p>
|
|
16
18
|
|
|
17
19
|
<table align="center">
|
|
18
20
|
<tr>
|
|
@@ -184,6 +186,19 @@ Each picture is the table the package draws, taken from [the demo](https://johnm
|
|
|
184
186
|
|
|
185
187
|
## Use it in your project
|
|
186
188
|
|
|
189
|
+
### Install under another name
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm install word-game@npm:@johnmorrisdotca/kumimoji
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```ts no-check
|
|
196
|
+
import "word-game/words";
|
|
197
|
+
import { loadTileWords, generateKumimoji } from "word-game";
|
|
198
|
+
await loadTileWords("english");
|
|
199
|
+
console.log(generateKumimoji(7,"easy",42).seed);
|
|
200
|
+
```
|
|
201
|
+
|
|
187
202
|
### Install
|
|
188
203
|
|
|
189
204
|
```sh
|
|
@@ -384,6 +399,12 @@ fetches when a game is first dealt.
|
|
|
384
399
|
|
|
385
400
|
The cookbook, with the output of each example, is under [Examples](#examples).
|
|
386
401
|
|
|
402
|
+
### Embed builder and reflected settings
|
|
403
|
+
|
|
404
|
+
[Build a crossword-table embed](https://johnmorrisdotca.github.io/kumimoji/builder.html), preview English letters or Japanese kana and copy element, iframe, module, React 19, Vue, Svelte, Angular, HTML or URL code. It saves no play automatically. The builder/frame defaults `keep` off; the existing element default remains on for compatibility.
|
|
405
|
+
|
|
406
|
+
Every attribute reflects to a property. New `daily` accepts today or an explicit UTC date (the `seed="daily"` alias remains); `controls`, device/light/dark `theme`, `size` (small 320px, medium 480px, large 640px), pixel `width` and spoken `label` are available. `table`, `saved`, `newGame()` and `setGame()` remain. `options` accepts every native table choice, including initial saved state and callbacks. Readiness is available as `table.ready`; `table.set(...)` updates presentation without redealing. Load errors are visible and reported through `onError`/`kumimoji-error`. `defineTable` accepts a custom tag and is server-safe. See [the embed guide](docs/embeds.md).
|
|
407
|
+
|
|
387
408
|
## Examples
|
|
388
409
|
|
|
389
410
|
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 word lists are read from the package's files in Node, so nothing here uses a network.
|
|
@@ -747,7 +768,7 @@ The JSON, as `kumimojiToJSON` writes it:
|
|
|
747
768
|
{
|
|
748
769
|
"format": 1,
|
|
749
770
|
"game": "kumimoji",
|
|
750
|
-
"generator": "kumimoji 1.
|
|
771
|
+
"generator": "kumimoji 1.3.0",
|
|
751
772
|
"size": 3,
|
|
752
773
|
"level": "hard",
|
|
753
774
|
"seed": 44,
|
|
@@ -843,7 +864,7 @@ turn tiles into words: `glyphOf`, `soundOf`, `wordOf`, `wildFor`, `isWild`,
|
|
|
843
864
|
|
|
844
865
|
## API
|
|
845
866
|
|
|
846
|
-
The [
|
|
867
|
+
The [documentation](https://johnmorrisdotca.github.io/kumimoji/docs/) includes bilingual guides, local search, signatures, parameters, return values and checked examples, built from source by `pnpm docs:site`. The [API index](https://johnmorrisdotca.github.io/kumimoji/api.html) preserves export anchors.
|
|
847
868
|
|
|
848
869
|
Every function, type and constant has a doc comment, so an editor shows this
|
|
849
870
|
as you type. The entries:
|
|
@@ -885,7 +906,7 @@ The types are `TilePlay`, `Tiles`, `GridVerdict`, `GridRules`, `Run`,
|
|
|
885
906
|
|
|
886
907
|
### The table
|
|
887
908
|
|
|
888
|
-
`mountKumimoji(element, options?)` from `@johnmorrisdotca/kumimoji/ui` deals and plays a whole game alone in the element and returns a handle (`play()`, `saved()`, `newGame(options?)`, `setGame(saved)`, `setLocale(locale, strings?)`, `destroy()`). Its options are `language`, `hand`, `level`, `gameLength`, `diagonals`, `seed`, `onFinish`, `onChange`, `locale`, `strings`, `theme` and `
|
|
909
|
+
`mountKumimoji(element, options?)` from `@johnmorrisdotca/kumimoji/ui` deals and plays a whole game alone in the element and returns a handle (`play()`, `saved()`, `newGame(options?)`, `setGame(saved)`, `setLocale(locale, strings?)`, `ready`, `set(options)`, `destroy()`). Its options are `language`, `hand`, `level`, `gameLength`, `diagonals`, `seed`, `onFinish`, `onChange`, `locale`, `strings`, `theme`, `keep`, `controls`, `saved` and `onError`; each, with its default, is in [docs/API.md](docs/API.md#the-table).
|
|
889
910
|
|
|
890
911
|
### The element
|
|
891
912
|
|
|
@@ -914,19 +935,7 @@ export function Board() {
|
|
|
914
935
|
}
|
|
915
936
|
```
|
|
916
937
|
|
|
917
|
-
|
|
918
|
-
| --- | --- |
|
|
919
|
-
| `tiles` | The tiles on the table: `play.tiles` |
|
|
920
|
-
| `verdict` | From `judgeWithWords`: rings the runs that are not words and fades the tiles apart |
|
|
921
|
-
| `glyphOf` | What to print on a tile: `words.glyphOf` for the language played |
|
|
922
|
-
| `onSquare` | Called with a square's key when it is pressed, empty or not |
|
|
923
|
-
| `held` | A square to ring, such as the one holding a tile picked up |
|
|
924
|
-
| `square` | The side of a square in pixels; 36 by default |
|
|
925
|
-
| anything else | Passed to the `<div>` |
|
|
926
|
-
|
|
927
|
-
`KumimojiTable` takes every option of `mountKumimoji` as a prop, and anything
|
|
928
|
-
else for its `<div>`. Options are read when it mounts; give it a new `key` to
|
|
929
|
-
start over with different ones.
|
|
938
|
+
The props of `KumimojiBoard` (`tiles`, `verdict`, `glyphOf`, `onSquare`, `held`, `square`, and anything else for its `<div>`) and of `KumimojiTable` are in [docs/react.md](docs/react.md).
|
|
930
939
|
|
|
931
940
|
## Theming
|
|
932
941
|
|
|
@@ -1104,35 +1113,67 @@ issue and we will add you.
|
|
|
1104
1113
|
### The family
|
|
1105
1114
|
|
|
1106
1115
|
<!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
|
|
1107
|
-
Kumimoji is one of
|
|
1108
|
-
[github.com/johnmorrisdotca](https://github.com/johnmorrisdotca). The code of every one is MIT.
|
|
1116
|
+
Kumimoji is one of thirty-two packages, each made for the same site, each at
|
|
1117
|
+
[github.com/johnmorrisdotca](https://github.com/johnmorrisdotca) or [github.com/spxis](https://github.com/spxis). The code of every one is MIT.
|
|
1109
1118
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
- [
|
|
1113
|
-
- [
|
|
1114
|
-
- [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/).
|
|
1119
|
+
**Games — board**
|
|
1120
|
+
|
|
1121
|
+
- [Domino](https://github.com/johnmorrisdotca/domino) (ドミノ): dominoes and Mexican Train. [Demo](https://johnmorrisdotca.github.io/domino/).
|
|
1122
|
+
- [Gunjin](https://github.com/johnmorrisdotca/gunjin) (軍人): five hidden-rank strategy games with pass-the-device play. [Demo](https://johnmorrisdotca.github.io/gunjin/).
|
|
1115
1123
|
- [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/).
|
|
1124
|
+
- [Sugoroku](https://github.com/johnmorrisdotca/sugoroku) (双六): backgammon and its variants, with the doubling cube and match play. [Demo](https://johnmorrisdotca.github.io/sugoroku/).
|
|
1116
1125
|
- [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/).
|
|
1117
|
-
|
|
1118
|
-
|
|
1126
|
+
|
|
1127
|
+
**Games — cards & tiles**
|
|
1128
|
+
|
|
1129
|
+
- [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/).
|
|
1119
1130
|
- [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
|
|
1120
|
-
- [
|
|
1121
|
-
- [
|
|
1122
|
-
|
|
1123
|
-
|
|
1131
|
+
- [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
|
|
1132
|
+
- [Toranpu](https://github.com/johnmorrisdotca/toranpu) (トランプ): a deck of playing cards, card games with computer players, and solitaires. [Demo](https://johnmorrisdotca.github.io/toranpu/).
|
|
1133
|
+
|
|
1134
|
+
**Games — puzzles**
|
|
1135
|
+
|
|
1136
|
+
- [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/).
|
|
1137
|
+
- [Jirai](https://github.com/johnmorrisdotca/jirai) (地雷): minesweeper on shaped grids with verified no-guess boards. [Demo](https://johnmorrisdotca.github.io/jirai/).
|
|
1138
|
+
- [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/).
|
|
1124
1139
|
- [Kazu](https://github.com/johnmorrisdotca/kazu) (数): grid number puzzles: Sudoku and its variants, Futoshiki and Skyscrapers. [Demo](https://johnmorrisdotca.github.io/kazu/).
|
|
1140
|
+
- [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/).
|
|
1125
1141
|
- [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/).
|
|
1142
|
+
- [Suido](https://github.com/johnmorrisdotca/suido) (水道): a pipe puzzle: turn the pieces until the water reaches every drain. [Demo](https://johnmorrisdotca.github.io/suido/).
|
|
1143
|
+
- [Tobiishi](https://github.com/johnmorrisdotca/tobiishi) (飛び石): peg solitaire with nine boards and seeded solvable challenges. [Demo](https://johnmorrisdotca.github.io/tobiishi/).
|
|
1144
|
+
- [Tsunagi](https://github.com/johnmorrisdotca/tsunagi) (繋ぎ): a line-joining logic puzzle whose every level has exactly one answer. [Demo](https://johnmorrisdotca.github.io/tsunagi/).
|
|
1145
|
+
|
|
1146
|
+
**Games — dice & random**
|
|
1147
|
+
|
|
1148
|
+
- [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/).
|
|
1149
|
+
- [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/).
|
|
1150
|
+
|
|
1151
|
+
**Language**
|
|
1152
|
+
|
|
1153
|
+
- [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
|
|
1126
1154
|
- [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/).
|
|
1155
|
+
- [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
|
|
1156
|
+
|
|
1157
|
+
**Geography & data**
|
|
1158
|
+
|
|
1159
|
+
- [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/).
|
|
1127
1160
|
- [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/).
|
|
1128
|
-
- [
|
|
1129
|
-
- [
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
- [
|
|
1161
|
+
- [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/).
|
|
1162
|
+
- [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/).
|
|
1163
|
+
|
|
1164
|
+
**Sports**
|
|
1165
|
+
|
|
1166
|
+
- [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/).
|
|
1167
|
+
- [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/).
|
|
1168
|
+
- [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/).
|
|
1169
|
+
- [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/).
|
|
1170
|
+
|
|
1171
|
+
**Developer tools**
|
|
1172
|
+
|
|
1173
|
+
- [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/).
|
|
1174
|
+
|
|
1134
1175
|
|
|
1135
|
-
**This package is Kumimoji.** The demos of all
|
|
1176
|
+
**This package is Kumimoji.** The demos of all thirty-two share one header and footer, so each links the rest.
|
|
1136
1177
|
<!-- family:end -->
|
|
1137
1178
|
|
|
1138
1179
|
## Development
|
|
@@ -1160,7 +1201,7 @@ Please follow the [code of conduct](./CODE_OF_CONDUCT.md). A way to make a check
|
|
|
1160
1201
|
|
|
1161
1202
|
See [CHANGELOG.md](./CHANGELOG.md).
|
|
1162
1203
|
|
|
1163
|
-
The latest release is 1.
|
|
1204
|
+
The latest release is 1.3.0: the table's standard embed attributes, the shared embed builder, and the documentation site with a checked example for every export.
|
|
1164
1205
|
|
|
1165
1206
|
## Licence
|
|
1166
1207
|
|
package/dist/check.d.ts
CHANGED
|
@@ -11,9 +11,34 @@ import type { KumimojiCheck, KumimojiLevel, KumimojiOptions } from "./kumimoji.t
|
|
|
11
11
|
* Written out here rather than asked of the play page, which is what made the
|
|
12
12
|
* grid; the list must have been loaded (`loadTileWords`), and a check that
|
|
13
13
|
* cannot read it refuses.
|
|
14
|
+
*
|
|
15
|
+
* @param size - The supported initial hand size.
|
|
16
|
+
* @param givens - The original bag of internal tile codes.
|
|
17
|
+
* @param answer - The encoded completed grid to verify.
|
|
18
|
+
* @param options - Native game, component or presentation options.
|
|
19
|
+
* @returns WHETHER A GRID FINISHES A KUMIMOJI: the one check the server also runs. O(squares) and a lookup a word, nothing searched: the grid uses exactly the tiles of the bag, as many of each, it is all one piece, and every run of two or more across or down is in the list — and, for a game set up with Diagonals, every run of three or more along a diagonal. Which tiles were traded on the way does not matter — a finished game holds the whole bag whatever came out of it when — so the answer is the grid alone.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { checkKumimoji } from "@johnmorrisdotca/kumimoji";
|
|
23
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
24
|
+
*
|
|
25
|
+
* await loadTileWordsFromModule("english");
|
|
26
|
+
* console.log(checkKumimoji(3,"cat","cat",{level:"hard"}));
|
|
27
|
+
* ```
|
|
14
28
|
*/
|
|
15
29
|
export declare function checkKumimoji(size: number, givens: string, answer: string, options?: KumimojiOptions & {
|
|
16
30
|
level?: KumimojiLevel;
|
|
17
31
|
}): KumimojiCheck;
|
|
18
|
-
/** A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
32
|
+
/** A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
33
|
+
*
|
|
34
|
+
* @param givens - The original bag of internal tile codes.
|
|
35
|
+
* @param elapsedMs - The elapsed solve time in milliseconds.
|
|
36
|
+
* @returns A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { kumimojiPoints } from "@johnmorrisdotca/kumimoji";
|
|
40
|
+
*
|
|
41
|
+
* console.log(kumimojiPoints("cat",12000));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
19
44
|
export declare function kumimojiPoints(givens: string, elapsedMs: number): number;
|
package/dist/check.js
CHANGED
|
@@ -14,6 +14,20 @@ import { tileWords } from "./tileWords.js";
|
|
|
14
14
|
* Written out here rather than asked of the play page, which is what made the
|
|
15
15
|
* grid; the list must have been loaded (`loadTileWords`), and a check that
|
|
16
16
|
* cannot read it refuses.
|
|
17
|
+
*
|
|
18
|
+
* @param size - The supported initial hand size.
|
|
19
|
+
* @param givens - The original bag of internal tile codes.
|
|
20
|
+
* @param answer - The encoded completed grid to verify.
|
|
21
|
+
* @param options - Native game, component or presentation options.
|
|
22
|
+
* @returns WHETHER A GRID FINISHES A KUMIMOJI: the one check the server also runs. O(squares) and a lookup a word, nothing searched: the grid uses exactly the tiles of the bag, as many of each, it is all one piece, and every run of two or more across or down is in the list — and, for a game set up with Diagonals, every run of three or more along a diagonal. Which tiles were traded on the way does not matter — a finished game holds the whole bag whatever came out of it when — so the answer is the grid alone.
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { checkKumimoji } from "@johnmorrisdotca/kumimoji";
|
|
26
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
27
|
+
*
|
|
28
|
+
* await loadTileWordsFromModule("english");
|
|
29
|
+
* console.log(checkKumimoji(3,"cat","cat",{level:"hard"}));
|
|
30
|
+
* ```
|
|
17
31
|
*/
|
|
18
32
|
export function checkKumimoji(size, givens, answer, options = {}) {
|
|
19
33
|
const gameLength = options.gameLength ?? "short";
|
|
@@ -60,7 +74,18 @@ export function checkKumimoji(size, givens, answer, options = {}) {
|
|
|
60
74
|
return { ok: false, reason: "the grid is not finished" };
|
|
61
75
|
return { ok: true };
|
|
62
76
|
}
|
|
63
|
-
/** A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
77
|
+
/** A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
78
|
+
*
|
|
79
|
+
* @param givens - The original bag of internal tile codes.
|
|
80
|
+
* @param elapsedMs - The elapsed solve time in milliseconds.
|
|
81
|
+
* @returns A finished game's leaderboard points (`KUMIMOJI_SCORE`): ten a tile, and up to as much again for speed.
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { kumimojiPoints } from "@johnmorrisdotca/kumimoji";
|
|
85
|
+
*
|
|
86
|
+
* console.log(kumimojiPoints("cat",12000));
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
64
89
|
export function kumimojiPoints(givens, elapsedMs) {
|
|
65
90
|
const tiles = givens.length;
|
|
66
91
|
const base = KUMIMOJI_SCORE.tile * tiles;
|
package/dist/computer.types.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { PartyGame } from "./party.types.ts";
|
|
2
|
-
/** What a computer did in one step of its turn, for the line over its table.
|
|
2
|
+
/** What a computer did in one step of its turn, for the line over its table.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { ComputerSaid } from "@johnmorrisdotca/kumimoji";
|
|
7
|
+
*
|
|
8
|
+
* const value: ComputerSaid = {kind:"drew"};
|
|
9
|
+
* console.log(value);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export type ComputerSaid = {
|
|
4
13
|
kind: "rebuilt";
|
|
5
14
|
} | {
|
|
@@ -16,7 +25,20 @@ export type ComputerSaid = {
|
|
|
16
25
|
} | {
|
|
17
26
|
kind: "resigned";
|
|
18
27
|
};
|
|
19
|
-
/** One step of a computer's turn: the game after it, and what it did. The last step's game is the one kept.
|
|
28
|
+
/** One step of a computer's turn: the game after it, and what it did. The last step's game is the one kept.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { startParty } from "@johnmorrisdotca/kumimoji";
|
|
33
|
+
* import type { ComputerStep } from "@johnmorrisdotca/kumimoji";
|
|
34
|
+
*
|
|
35
|
+
* const settings = {size:3,level:"hard",seed:44,gameLength:"short",language:"english",doubleSet:false,diagonals:false,hints:false} as const;
|
|
36
|
+
* const bag = "catdogsun";
|
|
37
|
+
* const game = startParty(settings,bag,["Seat 1","Seat 2"]);
|
|
38
|
+
* const value: ComputerStep = {game,said:{kind:"drew"}};
|
|
39
|
+
* console.log(value);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
20
42
|
export type ComputerStep = {
|
|
21
43
|
game: PartyGame;
|
|
22
44
|
said: ComputerSaid;
|
package/dist/computerPlay.d.ts
CHANGED
|
@@ -1,17 +1,60 @@
|
|
|
1
1
|
import { type GridRules, type GridVerdict, type Tiles } from "./grid.ts";
|
|
2
2
|
import { type TilePlay } from "./play.ts";
|
|
3
3
|
import type { TileWords } from "./tileWords.ts";
|
|
4
|
-
/** Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
4
|
+
/** Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
5
|
+
*
|
|
6
|
+
* @param tiles - The map from row,column square names to internal tile codes.
|
|
7
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
8
|
+
* @param rules - Whether diagonal runs are also judged.
|
|
9
|
+
* @returns Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
13
|
+
* import { judgeTiles } from "@johnmorrisdotca/kumimoji";
|
|
14
|
+
*
|
|
15
|
+
* const words = await loadTileWordsFromModule("english");
|
|
16
|
+
* const tiles = new Map([["0,0","c"],["0,1","a"],["0,2","t"]]);
|
|
17
|
+
* console.log(judgeTiles(tiles,words));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
5
20
|
export declare function judgeTiles(tiles: Tiles, words: TileWords, rules?: GridRules): GridVerdict;
|
|
6
21
|
/**
|
|
7
22
|
* THE COMPUTER'S NEXT WORD: its play after laying the best word its hand can
|
|
8
23
|
* lay on its table, and the word, or null when there is none. The grid after
|
|
9
24
|
* it is judged against the list, by the game's rules (`rules`), and is
|
|
10
25
|
* always sound.
|
|
26
|
+
*
|
|
27
|
+
* @param play - The current immutable solo-game progress.
|
|
28
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
29
|
+
* @param rules - Whether diagonal runs are also judged.
|
|
30
|
+
* @returns THE COMPUTER'S NEXT WORD: its play after laying the best word its hand can lay on its table, and the word, or null when there is none. The grid after it is judged against the list, by the game's rules (`rules`), and is always sound.
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
34
|
+
* import { bestLaying, deal } from "@johnmorrisdotca/kumimoji";
|
|
35
|
+
*
|
|
36
|
+
* const words = await loadTileWordsFromModule("english");
|
|
37
|
+
* const play = deal("catdog",3);
|
|
38
|
+
* console.log(bestLaying(play,words)?.word);
|
|
39
|
+
* ```
|
|
11
40
|
*/
|
|
12
41
|
export declare function bestLaying(play: TilePlay, words: TileWords, rules?: GridRules): {
|
|
13
42
|
play: TilePlay;
|
|
14
43
|
word: string;
|
|
15
44
|
} | null;
|
|
16
|
-
/** The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. Null for a hand of wilds.
|
|
45
|
+
/** The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. Null for a hand of wilds.
|
|
46
|
+
*
|
|
47
|
+
* @param hand - The hand size or tile codes, as declared by the function signature.
|
|
48
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
49
|
+
* @returns The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. null for a hand of wilds.
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
53
|
+
* import { deal, tradeChoice } from "@johnmorrisdotca/kumimoji";
|
|
54
|
+
*
|
|
55
|
+
* const words = await loadTileWordsFromModule("english");
|
|
56
|
+
* const play = deal("catdog",3);
|
|
57
|
+
* console.log(tradeChoice(play.hand,words));
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
17
60
|
export declare function tradeChoice(hand: readonly string[], words: TileWords): number | null;
|
package/dist/computerPlay.js
CHANGED
|
@@ -28,7 +28,22 @@ function plainOf(tile, words) {
|
|
|
28
28
|
const sound = words.soundOf(tile);
|
|
29
29
|
return sound === null ? "" : (words.codeOf(sound) ?? "");
|
|
30
30
|
}
|
|
31
|
-
/** Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
31
|
+
/** Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
32
|
+
*
|
|
33
|
+
* @param tiles - The map from row,column square names to internal tile codes.
|
|
34
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
35
|
+
* @param rules - Whether diagonal runs are also judged.
|
|
36
|
+
* @returns Whether a grid is sound, read against the loaded word list by the game's rules: the same judgement the desk shows.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
40
|
+
* import { judgeTiles } from "@johnmorrisdotca/kumimoji";
|
|
41
|
+
*
|
|
42
|
+
* const words = await loadTileWordsFromModule("english");
|
|
43
|
+
* const tiles = new Map([["0,0","c"],["0,1","a"],["0,2","t"]]);
|
|
44
|
+
* console.log(judgeTiles(tiles,words));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
32
47
|
export function judgeTiles(tiles, words, rules = {}) {
|
|
33
48
|
return judgeWithWords(tiles, words, rules);
|
|
34
49
|
}
|
|
@@ -173,6 +188,20 @@ const JUDGED_MOST = 12;
|
|
|
173
188
|
* lay on its table, and the word, or null when there is none. The grid after
|
|
174
189
|
* it is judged against the list, by the game's rules (`rules`), and is
|
|
175
190
|
* always sound.
|
|
191
|
+
*
|
|
192
|
+
* @param play - The current immutable solo-game progress.
|
|
193
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
194
|
+
* @param rules - Whether diagonal runs are also judged.
|
|
195
|
+
* @returns THE COMPUTER'S NEXT WORD: its play after laying the best word its hand can lay on its table, and the word, or null when there is none. The grid after it is judged against the list, by the game's rules (`rules`), and is always sound.
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
199
|
+
* import { bestLaying, deal } from "@johnmorrisdotca/kumimoji";
|
|
200
|
+
*
|
|
201
|
+
* const words = await loadTileWordsFromModule("english");
|
|
202
|
+
* const play = deal("catdog",3);
|
|
203
|
+
* console.log(bestLaying(play,words)?.word);
|
|
204
|
+
* ```
|
|
176
205
|
*/
|
|
177
206
|
export function bestLaying(play, words, rules = {}) {
|
|
178
207
|
if (play.hand.length === 0)
|
|
@@ -186,7 +215,21 @@ export function bestLaying(play, words, rules = {}) {
|
|
|
186
215
|
}
|
|
187
216
|
return null;
|
|
188
217
|
}
|
|
189
|
-
/** The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. Null for a hand of wilds.
|
|
218
|
+
/** The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. Null for a hand of wilds.
|
|
219
|
+
*
|
|
220
|
+
* @param hand - The hand size or tile codes, as declared by the function signature.
|
|
221
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
222
|
+
* @returns The tile a computer trades: its rarest letter in the set, the first of those in its hand; never a wild. null for a hand of wilds.
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
226
|
+
* import { deal, tradeChoice } from "@johnmorrisdotca/kumimoji";
|
|
227
|
+
*
|
|
228
|
+
* const words = await loadTileWordsFromModule("english");
|
|
229
|
+
* const play = deal("catdog",3);
|
|
230
|
+
* console.log(tradeChoice(play.hand,words));
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
190
233
|
export function tradeChoice(hand, words) {
|
|
191
234
|
let chosen = null;
|
|
192
235
|
let fewest = Infinity;
|
package/dist/computerTurn.d.ts
CHANGED
|
@@ -24,9 +24,48 @@ import type { TileWords } from "./tileWords.ts";
|
|
|
24
24
|
* - Resign only where the rules offer it (`mayResign`) and it can do nothing
|
|
25
25
|
* at all: nothing to lay, nothing to trade for, and it is not its last turn.
|
|
26
26
|
*/
|
|
27
|
-
/** The most things a computer does in one turn before pressing Done: at the page's pause, a turn of about three seconds.
|
|
27
|
+
/** The most things a computer does in one turn before pressing Done: at the page's pause, a turn of about three seconds.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { COMPUTER_STEPS_MOST } from "@johnmorrisdotca/kumimoji";
|
|
32
|
+
* console.log(COMPUTER_STEPS_MOST);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
28
35
|
export declare const COMPUTER_STEPS_MOST = 8;
|
|
29
|
-
/** A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
36
|
+
/** A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
37
|
+
*
|
|
38
|
+
* @param game - The current immutable shared-bag party game.
|
|
39
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
40
|
+
* @returns A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts no-run
|
|
43
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
44
|
+
* import { planComputerTurn, startParty } from "@johnmorrisdotca/kumimoji";
|
|
45
|
+
*
|
|
46
|
+
* const words = await loadTileWordsFromModule("english");
|
|
47
|
+
* const settings = {size:3,level:"hard",seed:44,gameLength:"short",language:"english",doubleSet:false,diagonals:false,hints:false} as const;
|
|
48
|
+
* const bag = "catdogsun";
|
|
49
|
+
* const game = startParty(settings,bag,["Seat 1","Seat 2"]);
|
|
50
|
+
* console.log(planComputerTurn(game,words).map(step=>step.said));
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
30
53
|
export declare function planComputerTurn(game: PartyGame, words: TileWords): ComputerStep[];
|
|
31
|
-
/** The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
54
|
+
/** The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
55
|
+
*
|
|
56
|
+
* @param game - The current immutable shared-bag party game.
|
|
57
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
58
|
+
* @returns The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts no-run
|
|
61
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
62
|
+
* import { afterComputerTurn, startParty } from "@johnmorrisdotca/kumimoji";
|
|
63
|
+
*
|
|
64
|
+
* const words = await loadTileWordsFromModule("english");
|
|
65
|
+
* const settings = {size:3,level:"hard",seed:44,gameLength:"short",language:"english",doubleSet:false,diagonals:false,hints:false} as const;
|
|
66
|
+
* const bag = "catdogsun";
|
|
67
|
+
* const game = startParty(settings,bag,["Seat 1","Seat 2"]);
|
|
68
|
+
* console.log(afterComputerTurn(game,words).turn);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
32
71
|
export declare function afterComputerTurn(game: PartyGame, words: TileWords): PartyGame;
|
package/dist/computerTurn.js
CHANGED
|
@@ -25,11 +25,34 @@ import { liftAll, mayTrade, trade } from "./play.js";
|
|
|
25
25
|
* - Resign only where the rules offer it (`mayResign`) and it can do nothing
|
|
26
26
|
* at all: nothing to lay, nothing to trade for, and it is not its last turn.
|
|
27
27
|
*/
|
|
28
|
-
/** The most things a computer does in one turn before pressing Done: at the page's pause, a turn of about three seconds.
|
|
28
|
+
/** The most things a computer does in one turn before pressing Done: at the page's pause, a turn of about three seconds.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { COMPUTER_STEPS_MOST } from "@johnmorrisdotca/kumimoji";
|
|
33
|
+
* console.log(COMPUTER_STEPS_MOST);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
29
36
|
export const COMPUTER_STEPS_MOST = 8;
|
|
30
37
|
/** How many settling steps may be needed at the end to be allowed Done at all; one trade a turn and a hand of tiles, so it is bounded anyway. */
|
|
31
38
|
const SETTLING_MOST = 200;
|
|
32
|
-
/** A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
39
|
+
/** A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
40
|
+
*
|
|
41
|
+
* @param game - The current immutable shared-bag party game.
|
|
42
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
43
|
+
* @returns A computer seat's whole turn as its steps, in order, for a page to show one at a time. None when it is not a computer's turn or the game is over.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts no-run
|
|
46
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
47
|
+
* import { planComputerTurn, startParty } from "@johnmorrisdotca/kumimoji";
|
|
48
|
+
*
|
|
49
|
+
* const words = await loadTileWordsFromModule("english");
|
|
50
|
+
* const settings = {size:3,level:"hard",seed:44,gameLength:"short",language:"english",doubleSet:false,diagonals:false,hints:false} as const;
|
|
51
|
+
* const bag = "catdogsun";
|
|
52
|
+
* const game = startParty(settings,bag,["Seat 1","Seat 2"]);
|
|
53
|
+
* console.log(planComputerTurn(game,words).map(step=>step.said));
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
33
56
|
export function planComputerTurn(game, words) {
|
|
34
57
|
const steps = [];
|
|
35
58
|
if (game.ending !== null || !isComputer(game, game.turn))
|
|
@@ -89,7 +112,23 @@ export function planComputerTurn(game, words) {
|
|
|
89
112
|
take(endTurn(now, verdict(), handSpells), { kind: "done", out: goesOut(now, verdict()) });
|
|
90
113
|
return steps;
|
|
91
114
|
}
|
|
92
|
-
/** The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
115
|
+
/** The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
116
|
+
*
|
|
117
|
+
* @param game - The current immutable shared-bag party game.
|
|
118
|
+
* @param words - The loaded native language word list and tile mappings.
|
|
119
|
+
* @returns The game a computer's turn passes on: its plan's last step, or the game as it was where there is nothing to play.
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts no-run
|
|
122
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
123
|
+
* import { afterComputerTurn, startParty } from "@johnmorrisdotca/kumimoji";
|
|
124
|
+
*
|
|
125
|
+
* const words = await loadTileWordsFromModule("english");
|
|
126
|
+
* const settings = {size:3,level:"hard",seed:44,gameLength:"short",language:"english",doubleSet:false,diagonals:false,hints:false} as const;
|
|
127
|
+
* const bag = "catdogsun";
|
|
128
|
+
* const game = startParty(settings,bag,["Seat 1","Seat 2"]);
|
|
129
|
+
* console.log(afterComputerTurn(game,words).turn);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
93
132
|
export function afterComputerTurn(game, words) {
|
|
94
133
|
return planComputerTurn(game, words).at(-1)?.game ?? game;
|
|
95
134
|
}
|