mons-rules 0.3.3 → 0.3.4
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/README.md +15 -56
- package/dist/mons-rules.js +1 -1
- package/package.json +4 -3
- package/MIGRATION.md +0 -219
package/README.md
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
# Mons rules engine
|
|
2
2
|
|
|
3
3
|
`mons-rules` is the dependency-free TypeScript rules engine for Super Metal
|
|
4
|
-
Mons.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Version 0.3 introduces an intentionally smaller, idiomatic TypeScript API.
|
|
8
|
-
Existing 0.2 users should follow [MIGRATION.md](./MIGRATION.md).
|
|
4
|
+
Mons. It is an ESM-only package for browsers, Web Workers, Node.js, and Firebase
|
|
5
|
+
Cloud Functions.
|
|
9
6
|
|
|
10
7
|
## Install
|
|
11
8
|
|
|
@@ -13,77 +10,39 @@ Existing 0.2 users should follow [MIGRATION.md](./MIGRATION.md).
|
|
|
13
10
|
npm install mons-rules
|
|
14
11
|
```
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
## Use
|
|
17
14
|
|
|
18
15
|
```ts
|
|
19
16
|
import { AutomovePreference, Game, GameVariant, type Input } from "mons-rules";
|
|
20
17
|
|
|
21
18
|
const game = new Game({ variant: GameVariant.Classic });
|
|
22
|
-
|
|
23
19
|
const inputs: Input[] = [
|
|
24
20
|
{ kind: "position", position: { row: 10, column: 5 } },
|
|
25
21
|
{ kind: "position", position: { row: 9, column: 4 } },
|
|
26
22
|
];
|
|
27
23
|
const result = game.play(inputs);
|
|
28
|
-
|
|
29
|
-
if (result.kind === "complete") {
|
|
30
|
-
console.log(result.events);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
24
|
const suggestion = game.suggestMove(AutomovePreference.Pro);
|
|
34
|
-
console.log(suggestion?.inputFen);
|
|
35
25
|
```
|
|
36
26
|
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
timeout result while canonical selection runs, starting with a packed move
|
|
41
|
-
when available or a deterministic legal fallback otherwise.
|
|
42
|
-
|
|
43
|
-
FEN helpers are available when a wire-format boundary is more convenient:
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
const game = new Game();
|
|
47
|
-
const result = game.playFen("l10,5;l9,4");
|
|
48
|
-
const restored = Game.fromFen(game.toFen());
|
|
49
|
-
```
|
|
27
|
+
Use `preview` or `previewFen` to inspect inputs without mutating the game. Use
|
|
28
|
+
`play` or `playFen` to apply a complete legal move. Serialize games with
|
|
29
|
+
`toFen` and restore them with `Game.fromFen`.
|
|
50
30
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
objects rather than mutable façade classes.
|
|
31
|
+
Published JavaScript targets ES2020 and uses Web-standard `performance` and
|
|
32
|
+
`crypto` globals. Node.js 22.13 through 22.x, or Node.js 24 or newer, is
|
|
33
|
+
required for Node consumers and repository tooling.
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
Node.js 22.13 through 22.x, or Node.js 24 or newer, is required for Node
|
|
58
|
-
consumers and repository tooling.
|
|
59
|
-
|
|
60
|
-
## Validation
|
|
61
|
-
|
|
62
|
-
Install dependencies and run the complete local gate:
|
|
35
|
+
## Validate
|
|
63
36
|
|
|
64
37
|
```sh
|
|
65
38
|
npm ci --engine-strict
|
|
66
39
|
npm run check
|
|
67
40
|
```
|
|
68
41
|
|
|
69
|
-
The check streams and replays 699,994 canonical rules transitions without
|
|
70
|
-
unpacking the compressed corpus. It also validates the public API,
|
|
71
|
-
deterministic automove decisions, and 1,527 complete real-player games
|
|
72
|
-
containing 25,185 turns and 169,480 inputs across all 12 variants.
|
|
73
|
-
|
|
74
|
-
Run `node ./scripts/check-complete-games.mjs` to validate the immutable public
|
|
75
|
-
corpus without replaying it. Run `npm run test:complete-games` for the full
|
|
76
|
-
engine replay.
|
|
77
|
-
|
|
78
42
|
## Release
|
|
79
43
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
A real publish uses the transient `mons-npm-publish-lock` tag on `origin`, or
|
|
87
|
-
the shared remote named by `MONS_PUBLISH_LOCK_REMOTE`, to serialize releases
|
|
88
|
-
across hosts. The script prints lease-protected recovery instructions if
|
|
89
|
-
cleanup fails.
|
|
44
|
+
```sh
|
|
45
|
+
npm run bump
|
|
46
|
+
npm run publish -- --check-only
|
|
47
|
+
npm run publish
|
|
48
|
+
```
|