@altnovatrail/widgets 0.1.3 → 0.2.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/README.md +1 -1
- package/kinds/cells/cells.handles.json +3 -3
- package/kinds/cells/cells.schema.json +69 -9
- package/kinds/cells/vectors/knight-after-no-parity.json +31 -0
- package/kinds/cells/vectors/knight-par-56-d2-2.json +61 -6
- package/kinds/cells/vectors/paper-drawn-lines.json +36 -1
- package/kinds/cells/vectors/polyomino-one-pieces.json +28 -0
- package/lib/cores/enumerate.js +2 -2
- package/lib/cores/kind.d.ts +18 -3
- package/lib/cores/kind.js +2 -2
- package/lib/cores/search.d.ts +21 -3
- package/lib/cores/search.js +52 -17
- package/lib/kinds/cells/bishop.d.ts +1 -1
- package/lib/kinds/cells/index.d.ts +8 -0
- package/lib/kinds/cells/index.js +10 -2
- package/lib/kinds/cells/kind.d.ts +3 -2
- package/lib/kinds/cells/kind.js +19 -6
- package/lib/kinds/cells/knight.d.ts +1 -1
- package/lib/kinds/cells/operation.d.ts +15 -1
- package/lib/kinds/cells/paper.js +27 -13
- package/lib/kinds/cells/piece.d.ts +17 -6
- package/lib/kinds/cells/piece.js +119 -38
- package/lib/kinds/cells/polyomino.js +22 -11
- package/lib/kinds/cells/registry.js +1 -1
- package/lib/kinds/cells/schema.js +4 -1
- package/lib/kinds/cells/step.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,6 @@ A component of [NovaTrail](https://github.com/altnovatrail/spec), a universal op
|
|
|
19
19
|
|
|
20
20
|
Its widgets run in `app` through the widget host of `canvas`, in an iframe sandbox with no network; each kind has a scene schema and a solver of its own; `modules` takes its bundles at a tag and pins each by its hash, and proves each scene's key with the kinds' solvers, an npm package of the same release.
|
|
21
21
|
|
|
22
|
-
Its design is detailed, and its first widget kind, the sheet of cells, is built: folds and paint, pieces on a board, paper folded in layers and punched, a table of numbers, paths, cuts and polyominoes; its rules and solver on the cores of search over states and of enumeration, which prove the fewest moves to a goal, a count, a maximum or a minimum, with their scene vectors, as an npm package checked the way a module's build takes it; its drawing — the sheet in perspective on a canvas, seen on the table or from above, as the learner switches —, bundled as one HTML file; the shell every kind shares; and the test host that plays it in the engines of Chromium, WebKit and Firefox. A release carries the bundle
|
|
22
|
+
Its design is detailed, and its first widget kind, the sheet of cells, is built: folds and paint, pieces on a board, paper folded in layers and punched, a table of numbers, paths, cuts and polyominoes; its rules and solver on the cores of search over states and of enumeration, which prove the fewest moves to a goal, a count, a maximum or a minimum, with their scene vectors, as an npm package checked the way a module's build takes it; its drawing — the sheet in perspective on a canvas, seen on the table or from above, as the learner switches —, bundled as one HTML file; the shell every kind shares, which speaks the widget protocol 1.0 of spec; and the test host that plays it in the engines of Chromium, WebKit and Firefox and passes spec's conformance tests of both sides. A release carries the bundle with its bundle's file — its protocol version and the digests a host's Content Security Policy names —, its handles, the npm package and the list of withdrawn bundles by the protocol's schema; the releases are published, the package in npm by trusted publishing.
|
|
23
23
|
|
|
24
24
|
Its card is in the architecture of [spec](https://github.com/altnovatrail/spec); its own documents, its decisions and its plan are in [docs/](docs/README.md).
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
326
|
"name": "show_best_path",
|
|
327
|
-
"description": "Show on the sheet the solver's best path from the state now to the goal
|
|
327
|
+
"description": "Show on the sheet the solver's best path from the state now to the goal — where the key is a count, to the nearest state counted; a maximum or a minimum, to its best —: the parts each move acts on, numbered in turn. It stays while the state is this one, until clear or your next reply. Refused where the scene has no goal.",
|
|
328
328
|
"inputSchema": {
|
|
329
329
|
"description": "No arguments.",
|
|
330
330
|
"type": "object",
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
},
|
|
335
335
|
{
|
|
336
336
|
"name": "show_outcomes",
|
|
337
|
-
"description": "Mark on the sheet each move the learner can make now by what it does to the fewest moves left to the goal: closer, as far, farther, or where the goal can no longer be reached. It stays while the state is this one, until clear or your next reply. Refused where the scene has no goal.",
|
|
337
|
+
"description": "Mark on the sheet each move the learner can make now by what it does to the fewest moves left to the goal, as the best path leads: closer, as far, farther, or where the goal — on a maximum or a minimum, its best — can no longer be reached. It stays while the state is this one, until clear or your next reply. Refused where the scene has no goal.",
|
|
338
338
|
"inputSchema": {
|
|
339
339
|
"description": "No arguments.",
|
|
340
340
|
"type": "object",
|
|
@@ -344,7 +344,7 @@
|
|
|
344
344
|
},
|
|
345
345
|
{
|
|
346
346
|
"name": "show_distance",
|
|
347
|
-
"description": "Say in the widget's bar the fewest moves left from the state now to the goal, or that it can no longer be reached. It stays while the state is this one, until clear or your next reply. Refused where the scene has no goal.",
|
|
347
|
+
"description": "Say in the widget's bar the fewest moves left from the state now to the goal, as the best path leads, or that it can no longer be reached; on a maximum or a minimum whose best can no longer be reached, that the goal is met, or can still be met, short of its best. It stays while the state is this one, until clear or your next reply. Refused where the scene has no goal.",
|
|
348
348
|
"inputSchema": {
|
|
349
349
|
"description": "No arguments.",
|
|
350
350
|
"type": "object",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://altnovatrail.github.io/widgets/kinds/cells/
|
|
3
|
+
"$id": "https://altnovatrail.github.io/widgets/kinds/cells/3.1/cells.schema.json",
|
|
4
4
|
"title": "A scene of the widget kind cells",
|
|
5
5
|
"description": "A sheet of cells, the operations a learner may play on it with their parameters, and at most one goal a state may meet. Under $defs, a move and a state of the kind.",
|
|
6
6
|
"type": "object",
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"cell": {
|
|
60
60
|
"description": "The cell the piece stands on at the scene's start, not a hole.",
|
|
61
61
|
"$ref": "#/$defs/cell"
|
|
62
|
+
},
|
|
63
|
+
"parity": {
|
|
64
|
+
"description": "Whether the state keeps, as step_parity, whether the piece has made an even or an odd count of moves; false where left out.",
|
|
65
|
+
"type": "boolean"
|
|
62
66
|
}
|
|
63
67
|
},
|
|
64
68
|
"required": [
|
|
@@ -73,6 +77,10 @@
|
|
|
73
77
|
"cell": {
|
|
74
78
|
"description": "The cell the piece stands on at the scene's start, not a hole.",
|
|
75
79
|
"$ref": "#/$defs/cell"
|
|
80
|
+
},
|
|
81
|
+
"parity": {
|
|
82
|
+
"description": "Whether the state keeps, as knight_parity, whether the piece has made an even or an odd count of moves; false where left out.",
|
|
83
|
+
"type": "boolean"
|
|
76
84
|
}
|
|
77
85
|
},
|
|
78
86
|
"required": [
|
|
@@ -87,6 +95,10 @@
|
|
|
87
95
|
"cell": {
|
|
88
96
|
"description": "The cell the piece stands on at the scene's start, not a hole.",
|
|
89
97
|
"$ref": "#/$defs/cell"
|
|
98
|
+
},
|
|
99
|
+
"parity": {
|
|
100
|
+
"description": "Whether the state keeps, as bishop_parity, whether the piece has made an even or an odd count of moves; false where left out.",
|
|
101
|
+
"type": "boolean"
|
|
90
102
|
}
|
|
91
103
|
},
|
|
92
104
|
"required": [
|
|
@@ -313,12 +325,20 @@
|
|
|
313
325
|
"unevaluatedProperties": false
|
|
314
326
|
},
|
|
315
327
|
"step_on": {
|
|
316
|
-
"description": "The piece step stands on the cell; the scene allows the operation step, which keeps the piece.",
|
|
328
|
+
"description": "The piece step stands on the cell, after a count of moves of the parity given where one is; the scene allows the operation step, which keeps the piece.",
|
|
317
329
|
"type": "object",
|
|
318
330
|
"properties": {
|
|
319
331
|
"cell": {
|
|
320
332
|
"description": "The cell, not a hole.",
|
|
321
333
|
"$ref": "#/$defs/cell"
|
|
334
|
+
},
|
|
335
|
+
"after": {
|
|
336
|
+
"description": "Whether the piece has made an even or an odd count of moves; the operation step of the scene then keeps their parity.",
|
|
337
|
+
"type": "string",
|
|
338
|
+
"enum": [
|
|
339
|
+
"even",
|
|
340
|
+
"odd"
|
|
341
|
+
]
|
|
322
342
|
}
|
|
323
343
|
},
|
|
324
344
|
"required": [
|
|
@@ -327,12 +347,20 @@
|
|
|
327
347
|
"unevaluatedProperties": false
|
|
328
348
|
},
|
|
329
349
|
"knight_on": {
|
|
330
|
-
"description": "The piece knight stands on the cell; the scene allows the operation knight, which keeps the piece.",
|
|
350
|
+
"description": "The piece knight stands on the cell, after a count of moves of the parity given where one is; the scene allows the operation knight, which keeps the piece.",
|
|
331
351
|
"type": "object",
|
|
332
352
|
"properties": {
|
|
333
353
|
"cell": {
|
|
334
354
|
"description": "The cell, not a hole.",
|
|
335
355
|
"$ref": "#/$defs/cell"
|
|
356
|
+
},
|
|
357
|
+
"after": {
|
|
358
|
+
"description": "Whether the piece has made an even or an odd count of moves; the operation knight of the scene then keeps their parity.",
|
|
359
|
+
"type": "string",
|
|
360
|
+
"enum": [
|
|
361
|
+
"even",
|
|
362
|
+
"odd"
|
|
363
|
+
]
|
|
336
364
|
}
|
|
337
365
|
},
|
|
338
366
|
"required": [
|
|
@@ -341,12 +369,20 @@
|
|
|
341
369
|
"unevaluatedProperties": false
|
|
342
370
|
},
|
|
343
371
|
"bishop_on": {
|
|
344
|
-
"description": "The piece bishop stands on the cell; the scene allows the operation bishop, which keeps the piece.",
|
|
372
|
+
"description": "The piece bishop stands on the cell, after a count of moves of the parity given where one is; the scene allows the operation bishop, which keeps the piece.",
|
|
345
373
|
"type": "object",
|
|
346
374
|
"properties": {
|
|
347
375
|
"cell": {
|
|
348
376
|
"description": "The cell, not a hole.",
|
|
349
377
|
"$ref": "#/$defs/cell"
|
|
378
|
+
},
|
|
379
|
+
"after": {
|
|
380
|
+
"description": "Whether the piece has made an even or an odd count of moves; the operation bishop of the scene then keeps their parity.",
|
|
381
|
+
"type": "string",
|
|
382
|
+
"enum": [
|
|
383
|
+
"even",
|
|
384
|
+
"odd"
|
|
385
|
+
]
|
|
350
386
|
}
|
|
351
387
|
},
|
|
352
388
|
"required": [
|
|
@@ -399,7 +435,7 @@
|
|
|
399
435
|
"unevaluatedProperties": false
|
|
400
436
|
},
|
|
401
437
|
"step_reach": {
|
|
402
|
-
"description": "The piece step stands on a cell whose fewest moves from the cell it starts on are at least least and at most most; the key counts those cells. The scene allows the operation step alone, so that its states are the piece's cells.",
|
|
438
|
+
"description": "The piece step stands on a cell whose fewest moves from the cell it starts on are at least least and at most most; the key counts those cells. The scene allows the operation step alone, keeping no parity of its moves, so that its states are the piece's cells.",
|
|
403
439
|
"type": "object",
|
|
404
440
|
"properties": {
|
|
405
441
|
"least": {
|
|
@@ -418,7 +454,7 @@
|
|
|
418
454
|
"unevaluatedProperties": false
|
|
419
455
|
},
|
|
420
456
|
"bishop_reach": {
|
|
421
|
-
"description": "The piece bishop stands on a cell whose fewest moves from the cell it starts on are at least least and at most most; the key counts those cells. The scene allows the operation bishop alone, so that its states are the piece's cells.",
|
|
457
|
+
"description": "The piece bishop stands on a cell whose fewest moves from the cell it starts on are at least least and at most most; the key counts those cells. The scene allows the operation bishop alone, keeping no parity of its moves, so that its states are the piece's cells.",
|
|
422
458
|
"type": "object",
|
|
423
459
|
"properties": {
|
|
424
460
|
"least": {
|
|
@@ -682,12 +718,12 @@
|
|
|
682
718
|
"unevaluatedProperties": false
|
|
683
719
|
},
|
|
684
720
|
"polyomino_placings": {
|
|
685
|
-
"description": "One figure lies on the sheet; the key counts the places it may lie on, two places one where they cover the same cells. The scene allows the operation polyomino alone, so that its states are the
|
|
721
|
+
"description": "One figure lies on the sheet; the key counts the places it may lie on, two places one where they cover the same cells. The scene allows the operation polyomino alone with pieces 1, so that its states are the one figure's places.",
|
|
686
722
|
"type": "object",
|
|
687
723
|
"unevaluatedProperties": false
|
|
688
724
|
},
|
|
689
725
|
"polyomino_shapes": {
|
|
690
|
-
"description": "One figure lies on the sheet; the key counts its shapes, two figures one shape where one moved, turned or turned over lies on the other. The scene allows the operation polyomino alone, so that its states are the
|
|
726
|
+
"description": "One figure lies on the sheet; the key counts its shapes, two figures one shape where one moved, turned or turned over lies on the other. The scene allows the operation polyomino alone with pieces 1, so that its states are the one figure's places.",
|
|
691
727
|
"type": "object",
|
|
692
728
|
"unevaluatedProperties": false
|
|
693
729
|
}
|
|
@@ -1076,7 +1112,7 @@
|
|
|
1076
1112
|
"maxProperties": 1
|
|
1077
1113
|
},
|
|
1078
1114
|
"state": {
|
|
1079
|
-
"description": "A state: the cells' marks, and a member for each operation of the scene that keeps one.",
|
|
1115
|
+
"description": "A state: the cells' marks, and a member for each operation of the scene that keeps one, with a second beside it where the scene's parameters of the operation ask for it.",
|
|
1080
1116
|
"type": "object",
|
|
1081
1117
|
"properties": {
|
|
1082
1118
|
"marks": {
|
|
@@ -1087,14 +1123,38 @@
|
|
|
1087
1123
|
"description": "The cell the piece step stands on.",
|
|
1088
1124
|
"$ref": "#/$defs/cell"
|
|
1089
1125
|
},
|
|
1126
|
+
"step_parity": {
|
|
1127
|
+
"description": "Whether the piece step has made an even or an odd count of moves; only where the scene's parameters of the piece ask for it.",
|
|
1128
|
+
"type": "string",
|
|
1129
|
+
"enum": [
|
|
1130
|
+
"even",
|
|
1131
|
+
"odd"
|
|
1132
|
+
]
|
|
1133
|
+
},
|
|
1090
1134
|
"knight_at": {
|
|
1091
1135
|
"description": "The cell the piece knight stands on.",
|
|
1092
1136
|
"$ref": "#/$defs/cell"
|
|
1093
1137
|
},
|
|
1138
|
+
"knight_parity": {
|
|
1139
|
+
"description": "Whether the piece knight has made an even or an odd count of moves; only where the scene's parameters of the piece ask for it.",
|
|
1140
|
+
"type": "string",
|
|
1141
|
+
"enum": [
|
|
1142
|
+
"even",
|
|
1143
|
+
"odd"
|
|
1144
|
+
]
|
|
1145
|
+
},
|
|
1094
1146
|
"bishop_at": {
|
|
1095
1147
|
"description": "The cell the piece bishop stands on.",
|
|
1096
1148
|
"$ref": "#/$defs/cell"
|
|
1097
1149
|
},
|
|
1150
|
+
"bishop_parity": {
|
|
1151
|
+
"description": "Whether the piece bishop has made an even or an odd count of moves; only where the scene's parameters of the piece ask for it.",
|
|
1152
|
+
"type": "string",
|
|
1153
|
+
"enum": [
|
|
1154
|
+
"even",
|
|
1155
|
+
"odd"
|
|
1156
|
+
]
|
|
1157
|
+
},
|
|
1098
1158
|
"paper": {
|
|
1099
1159
|
"description": "The paper: where its cells lie while it is folded, or the cells punched.",
|
|
1100
1160
|
"type": "object",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "A scene the kind refuses: its goal asks for the knight on a cell after an odd count of moves, but the knight's parameters keep no parity of its moves, so no state could tell an odd count from an even one; an author's slip, never a key that the goal cannot be reached.",
|
|
3
|
+
"scene": {
|
|
4
|
+
"sheet": {
|
|
5
|
+
"rows": 8,
|
|
6
|
+
"cols": 8
|
|
7
|
+
},
|
|
8
|
+
"operations": {
|
|
9
|
+
"knight": {
|
|
10
|
+
"cell": "A1"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"goal": {
|
|
14
|
+
"knight_on": {
|
|
15
|
+
"cell": "A1",
|
|
16
|
+
"after": "odd"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"seed": "0",
|
|
21
|
+
"sequences": [],
|
|
22
|
+
"proof": {
|
|
23
|
+
"undecided": "invalid",
|
|
24
|
+
"errors": [
|
|
25
|
+
{
|
|
26
|
+
"path": "/goal/knight_on/after",
|
|
27
|
+
"message": "the operation knight keeps no parity of the piece's moves: give it \"parity\": true"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "The knight of the course's task par-56-d2-2 on A1 of a chessboard
|
|
2
|
+
"description": "The knight of the course's task par-56-d2-2 on A1 of a chessboard, the state keeping whether it has made an even or an odd count of moves; the goal is the knight back on A1 after an odd count. Each move changes the colour of its cell, so it is back on A1 after an even count only, after 2 already, and the goal cannot be met: the whole graph of 64 states is the witness. A move that is no knight's, and a cell off the board, are refused, the parity as it was.",
|
|
3
3
|
"scene": {
|
|
4
4
|
"sheet": {
|
|
5
5
|
"rows": 8,
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
},
|
|
8
8
|
"operations": {
|
|
9
9
|
"knight": {
|
|
10
|
-
"cell": "A1"
|
|
10
|
+
"cell": "A1",
|
|
11
|
+
"parity": true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"goal": {
|
|
15
|
+
"knight_on": {
|
|
16
|
+
"cell": "A1",
|
|
17
|
+
"after": "odd"
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
},
|
|
@@ -15,7 +22,8 @@
|
|
|
15
22
|
"start": {
|
|
16
23
|
"state": {
|
|
17
24
|
"marks": {},
|
|
18
|
-
"knight_at": "A1"
|
|
25
|
+
"knight_at": "A1",
|
|
26
|
+
"knight_parity": "even"
|
|
19
27
|
},
|
|
20
28
|
"goal": false
|
|
21
29
|
},
|
|
@@ -29,7 +37,8 @@
|
|
|
29
37
|
},
|
|
30
38
|
"state": {
|
|
31
39
|
"marks": {},
|
|
32
|
-
"knight_at": "B3"
|
|
40
|
+
"knight_at": "B3",
|
|
41
|
+
"knight_parity": "odd"
|
|
33
42
|
},
|
|
34
43
|
"goal": false
|
|
35
44
|
},
|
|
@@ -41,7 +50,8 @@
|
|
|
41
50
|
},
|
|
42
51
|
"state": {
|
|
43
52
|
"marks": {},
|
|
44
|
-
"knight_at": "A1"
|
|
53
|
+
"knight_at": "A1",
|
|
54
|
+
"knight_parity": "even"
|
|
45
55
|
},
|
|
46
56
|
"goal": false
|
|
47
57
|
},
|
|
@@ -61,9 +71,54 @@
|
|
|
61
71
|
},
|
|
62
72
|
"refused": "no-cell"
|
|
63
73
|
}
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
"move": {
|
|
78
|
+
"knight": {
|
|
79
|
+
"to": "C2"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"state": {
|
|
83
|
+
"marks": {},
|
|
84
|
+
"knight_at": "C2",
|
|
85
|
+
"knight_parity": "odd"
|
|
86
|
+
},
|
|
87
|
+
"goal": false
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"move": {
|
|
91
|
+
"knight": {
|
|
92
|
+
"to": "A3"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"state": {
|
|
96
|
+
"marks": {},
|
|
97
|
+
"knight_at": "A3",
|
|
98
|
+
"knight_parity": "even"
|
|
99
|
+
},
|
|
100
|
+
"goal": false
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"move": {
|
|
104
|
+
"knight": {
|
|
105
|
+
"to": "B1"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"state": {
|
|
109
|
+
"marks": {},
|
|
110
|
+
"knight_at": "B1",
|
|
111
|
+
"knight_parity": "odd"
|
|
112
|
+
},
|
|
113
|
+
"goal": false
|
|
114
|
+
}
|
|
64
115
|
]
|
|
65
116
|
],
|
|
66
117
|
"proof": {
|
|
67
|
-
"
|
|
118
|
+
"key": "unreachable",
|
|
119
|
+
"witness": {
|
|
120
|
+
"layers": [1, 2, 9, 20, 21, 10, 1]
|
|
121
|
+
},
|
|
122
|
+
"ends": []
|
|
68
123
|
}
|
|
69
124
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "Lines drawn on the open sheet move with the part laid over: a strip of 1 by 6 with the lines v4 and v5 drawn. Its right part folded over along v4 lays v5 along v3, where the paper then folds, and the punch at A3 goes through the 4 layers there, the most holes, the key; folded the other way round the strip takes 3 layers at most. A line on the paper that no drawn line lies along is refused, and so is v5 once it lies elsewhere, off the paper.",
|
|
2
|
+
"description": "Lines drawn on the open sheet move with the part laid over: a strip of 1 by 6 with the lines v4 and v5 drawn. Its right part folded over along v4 lays v5 along v3, where the paper then folds, and the punch at A3 goes through the 4 layers there, the most holes, the key; folded the other way round the strip takes 3 layers at most. A line on the paper that no drawn line lies along is refused, and so is v5 once it lies elsewhere, off the paper. A fold is refused by its parts in turn: v1, not drawn, though laying its right part over would lay the wider one; then a side not the line's; then the wider part laid over.",
|
|
3
3
|
"scene": {
|
|
4
4
|
"sheet": {
|
|
5
5
|
"rows": 1,
|
|
@@ -105,6 +105,41 @@
|
|
|
105
105
|
},
|
|
106
106
|
"goal": true
|
|
107
107
|
}
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
{
|
|
111
|
+
"move": {
|
|
112
|
+
"paper": {
|
|
113
|
+
"fold": {
|
|
114
|
+
"line": "v1",
|
|
115
|
+
"lay": "right"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"refused": "not-given"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"move": {
|
|
123
|
+
"paper": {
|
|
124
|
+
"fold": {
|
|
125
|
+
"line": "v4",
|
|
126
|
+
"lay": "top"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"refused": "no-side"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"move": {
|
|
134
|
+
"paper": {
|
|
135
|
+
"fold": {
|
|
136
|
+
"line": "v5",
|
|
137
|
+
"lay": "left"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"refused": "overhang"
|
|
142
|
+
}
|
|
108
143
|
]
|
|
109
144
|
],
|
|
110
145
|
"proof": {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "A count of one figure's places on a scene that lets more than one figure lie at once: dominoes on 4 by 4 with no pieces given. The goal counts one figure, so the kind names the goal and asks for pieces 1, rather than build states of two figures that it never counts.",
|
|
3
|
+
"scene": {
|
|
4
|
+
"sheet": {
|
|
5
|
+
"rows": 4,
|
|
6
|
+
"cols": 4
|
|
7
|
+
},
|
|
8
|
+
"operations": {
|
|
9
|
+
"polyomino": {
|
|
10
|
+
"shapes": [["A1", "A2"]]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"goal": {
|
|
14
|
+
"polyomino_placings": {}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"seed": "0",
|
|
18
|
+
"sequences": [],
|
|
19
|
+
"proof": {
|
|
20
|
+
"undecided": "invalid",
|
|
21
|
+
"errors": [
|
|
22
|
+
{
|
|
23
|
+
"path": "/goal/polyomino_placings",
|
|
24
|
+
"message": "a count of one figure takes pieces 1 of the operation polyomino, so that no second figure lies at once"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
package/lib/cores/enumerate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The core of enumeration: what a key that is a count, a maximum or a minimum reads off a scene's
|
|
2
|
-
// whole state graph, which the search core builds within the kind's
|
|
3
|
-
// graph and walks it no deeper, so the kind's
|
|
2
|
+
// whole state graph, which the search core builds within the kind's limits. It adds no state to the
|
|
3
|
+
// graph and walks it no deeper, so the kind's limits bound it as they bound the search.
|
|
4
4
|
import { canonicalKey } from "./key.js";
|
|
5
5
|
/**
|
|
6
6
|
* The states of the graph that meet the goal, in the graph's order; where images is given, the
|
package/lib/cores/kind.d.ts
CHANGED
|
@@ -32,6 +32,15 @@ export type Played<State> = {
|
|
|
32
32
|
export interface Kind<Scene, State extends Json, Move extends Json> {
|
|
33
33
|
/** The most states a scene's whole state graph may hold, the same at a build and on a device. */
|
|
34
34
|
readonly limit: number;
|
|
35
|
+
/**
|
|
36
|
+
* The most work a scene's whole state graph may take, the same at a build and on a device: each
|
|
37
|
+
* state counts every move the kind lists from it, each move the length of the state's canonical
|
|
38
|
+
* key, what implied adds to it, and moveWork of cores/search.ts more — a move reads the state and
|
|
39
|
+
* writes the one it leads to, keyed again, and trying it costs something whatever the state. It
|
|
40
|
+
* bounds the time of a graph whose states carry many marks or places or have many moves to try,
|
|
41
|
+
* which a count of states does not.
|
|
42
|
+
*/
|
|
43
|
+
readonly workLimit: number;
|
|
35
44
|
read(input: unknown): Read<Scene>;
|
|
36
45
|
/** The state of the scene as given, at version 0. */
|
|
37
46
|
start(scene: Scene): State;
|
|
@@ -46,6 +55,12 @@ export interface Kind<Scene, State extends Json, Move extends Json> {
|
|
|
46
55
|
* path follows. A move listed here that play refuses is skipped.
|
|
47
56
|
*/
|
|
48
57
|
moves(scene: Scene, state: State): readonly Move[];
|
|
58
|
+
/**
|
|
59
|
+
* What a move from the state reads and writes that its canonical key leaves out, in characters as
|
|
60
|
+
* the key would write it: a place the state keeps by leaving it out, which every move still
|
|
61
|
+
* works on. A kind that leaves it out, or gives 0, keeps nothing so.
|
|
62
|
+
*/
|
|
63
|
+
implied?(scene: Scene, state: State): number;
|
|
49
64
|
hasGoal(scene: Scene): boolean;
|
|
50
65
|
/** Whether the state meets the scene's goal; never true for a scene with no goal. */
|
|
51
66
|
meets(scene: Scene, state: State): boolean;
|
|
@@ -79,9 +94,9 @@ export type Ask<State> = {
|
|
|
79
94
|
measure(state: State): number;
|
|
80
95
|
};
|
|
81
96
|
/**
|
|
82
|
-
* Why a scene gives no proof: limit, its state graph passes the kind's limit
|
|
83
|
-
* passes the safe integers, beyond what the solver takes either way;
|
|
84
|
-
* no-goal, it has no goal to prove.
|
|
97
|
+
* Why a scene gives no proof: limit, its state graph passes the kind's limit of states or of
|
|
98
|
+
* work, or a count of ways passes the safe integers, beyond what the solver takes either way;
|
|
99
|
+
* invalid, the kind refuses it; no-goal, it has no goal to prove.
|
|
85
100
|
*/
|
|
86
101
|
export type Undecided = {
|
|
87
102
|
readonly undecided: "limit";
|
package/lib/cores/kind.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// The interface every widget kind gives the cores of solvers: its scene read by its schema, its
|
|
2
|
-
// rules, its goal and its
|
|
3
|
-
// them; its scene may be any form the kind reads its JSON into.
|
|
2
|
+
// rules, its goal and its limits of states and of work. A kind's state and moves are JSON, as the
|
|
3
|
+
// widget reports them; its scene may be any form the kind reads its JSON into.
|
|
4
4
|
export {};
|
package/lib/cores/search.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { Json, Kind, ProofJson, SceneError, Undecided } from "./kind.js";
|
|
1
|
+
import type { Ask, Json, Kind, ProofJson, SceneError, Undecided } from "./kind.js";
|
|
2
|
+
/**
|
|
3
|
+
* The work of trying one move beyond the length of its state's canonical key, by which a kind's
|
|
4
|
+
* limit of work counts: about what listing, playing and keying a move costs whatever its state.
|
|
5
|
+
*/
|
|
6
|
+
export declare const moveWork = 64;
|
|
2
7
|
/** A move from a state and the index of the state it leads to. */
|
|
3
8
|
export interface Edge<Move> {
|
|
4
9
|
readonly move: Move;
|
|
@@ -17,6 +22,13 @@ export interface StateNode<State, Move> {
|
|
|
17
22
|
* the goal asks a maximum or a minimum, one of that measure —; null where none can be reached.
|
|
18
23
|
*/
|
|
19
24
|
readonly distance: number | null;
|
|
25
|
+
/**
|
|
26
|
+
* The fewest moves from the state to any state that meets the goal, whatever its measure; null
|
|
27
|
+
* where none can be reached. It is the distance but where the goal asks a maximum or a minimum,
|
|
28
|
+
* so that a state met short of the extreme measure, or one that can still meet the goal only
|
|
29
|
+
* short of it, is told from one where the goal cannot be met at all.
|
|
30
|
+
*/
|
|
31
|
+
readonly nearest: number | null;
|
|
20
32
|
/** Every move the rules take from the state, in the kind's order, a move that changes nothing among them. */
|
|
21
33
|
readonly next: readonly Edge<Move>[];
|
|
22
34
|
/** The state and move it was first reached by; null for the scene's own state. */
|
|
@@ -26,9 +38,13 @@ export interface StateNode<State, Move> {
|
|
|
26
38
|
} | null;
|
|
27
39
|
}
|
|
28
40
|
export interface StateGraph<State, Move> {
|
|
41
|
+
/** What the key asks, the fewest moves where the kind does not say: what the distances serve. */
|
|
42
|
+
readonly asks: Ask<State>["key"];
|
|
29
43
|
readonly nodes: readonly StateNode<State, Move>[];
|
|
30
44
|
/** The indices of the states of each layer, the scene's own state alone in layer 0. */
|
|
31
45
|
readonly layers: readonly (readonly number[])[];
|
|
46
|
+
/** The graph's work, as the kind's limit of work counts it. */
|
|
47
|
+
readonly work: number;
|
|
32
48
|
/** The node of a state, or undefined where the scene cannot reach it or it is no state. */
|
|
33
49
|
at(state: State): StateNode<State, Move> | undefined;
|
|
34
50
|
}
|
|
@@ -39,6 +55,7 @@ export type GraphResult<State, Move> = {
|
|
|
39
55
|
readonly ok: false;
|
|
40
56
|
} & ({
|
|
41
57
|
readonly undecided: "limit";
|
|
58
|
+
readonly passes: "states" | "work";
|
|
42
59
|
} | {
|
|
43
60
|
readonly undecided: "invalid";
|
|
44
61
|
readonly errors: readonly SceneError[];
|
|
@@ -67,8 +84,9 @@ export type Proof<State, Move> = {
|
|
|
67
84
|
/**
|
|
68
85
|
* The whole state graph of a scene, read from its JSON by the kind's schema: every state the
|
|
69
86
|
* scene's moves reach, layer by layer, states that are equal by their canonical key merged. A
|
|
70
|
-
* graph with more states than the kind's limit
|
|
71
|
-
*
|
|
87
|
+
* graph with more states than the kind's limit, or more work than its limit of work, is
|
|
88
|
+
* undecided, wherever its goal lies: the limits hold every state a learner can reach, not only the
|
|
89
|
+
* search from the scene to the goal. A
|
|
72
90
|
* measure the goal asks that is no safe integer throws, as a state that is no JSON of integers
|
|
73
91
|
* does: either is a fault of the kind, not of the scene.
|
|
74
92
|
*/
|