maze-test 0.1.0 → 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 CHANGED
@@ -1,29 +1,123 @@
1
1
  # maze-test
2
2
 
3
- A TypeScript package built with [tsup](https://tsup.egoist.dev/) and managed with [pnpm](https://pnpm.io/).
3
+ Generate deterministic bilingual maze reasoning questions and matching answer keys from the command line or a TypeScript API.
4
4
 
5
- ## Development
5
+ The maze uses solid wall cells and open passage cells. Trials can include doors, keys, chests, traps, medicine rooms, movement rules, and a fully reproducible action sequence.
6
+
7
+ ## Quick start
8
+
9
+ Generate an English question:
6
10
 
7
11
  ```sh
8
- pnpm install
9
- pnpm dev
12
+ npx maze-test question --seed 42 --rows 15 --cols 15
10
13
  ```
11
14
 
12
- ## Build
15
+ Generate its answer key using exactly the same seed and parameters:
13
16
 
14
17
  ```sh
15
- pnpm check
18
+ npx maze-test answer --seed 42 --rows 15 --cols 15
16
19
  ```
17
20
 
18
- The build emits ESM, CommonJS, type declarations, and source maps to `dist/`.
21
+ Chinese output:
22
+
23
+ ```sh
24
+ npx maze-test question --seed 42 --lang zh
25
+ npx maze-test answer --seed 42 --lang zh
26
+ ```
27
+
28
+ `question` is the default command, so this is also valid:
29
+
30
+ ```sh
31
+ npx maze-test --seed 42
32
+ ```
33
+
34
+ ## Options
35
+
36
+ | Option | Description | Default |
37
+ |---|---|---:|
38
+ | `--seed` | Non-negative root seed | `1` |
39
+ | `--rows` | Odd row count, at least 7 | `15` |
40
+ | `--cols` | Odd column count, at least 7 | `15` |
41
+ | `--braid` | Probability from 0 to 1 of opening a dead end | `0` |
42
+ | `--doors` | Number of doors and corresponding keys | `1` |
43
+ | `--chests` | Number of treasure chests | `2` |
44
+ | `--traps` | Number of traps | `2` |
45
+ | `--medicines` | Number of medicine rooms | `2` |
46
+ | `--scenario` | `success`, `treasure-and-leave`, or `death-and-stop` | `success` |
47
+ | `--lang` | `en` or `zh` | `en` |
48
+ | `--style` | Non-negative deterministic wording variation | `0` |
49
+ | `--min-distance` | Minimum entry-to-goal distance | `0` |
50
+ | `--max-attempts` | Deterministic search limit | `500` |
51
+ | `--format` | `text` or `json` | `text` |
52
+ | `--json` | Alias for `--format json` | — |
53
+
54
+ See all options with:
55
+
56
+ ```sh
57
+ npx maze-test --help
58
+ ```
59
+
60
+ ## Scenarios
61
+
62
+ - `success`: follows the main path, collects required keys, opens the gating doors, and reaches the goal alive.
63
+ - `treasure-and-leave`: visits a medicine room and a chest, reaches the goal, leaves it again, and includes blocked moves.
64
+ - `death-and-stop`: reaches a trap with one health point, dies, and demonstrates that later actions no longer change state.
65
+
66
+ Some braided mazes cannot support the requested number of non-bypassable doors. In that case, the root seed drives a deterministic search for the next valid maze seed. Both the requested seed and effective maze seed are reported, and identical inputs always produce identical output.
19
67
 
20
- ## Publishing
68
+ ## JSON output
21
69
 
22
70
  ```sh
23
- pnpm publish
71
+ npx maze-test question --seed 42 --json
72
+ npx maze-test answer --seed 42 --json
24
73
  ```
25
74
 
26
- The `prepublishOnly` script type-checks and builds the package before publication.
75
+ Question JSON contains the localized question sections but no answer. Answer JSON contains the structured answer values and formatted answer key.
76
+
77
+ ## TypeScript API
78
+
79
+ ```ts
80
+ import {
81
+ generateAnswer,
82
+ generateQuestion,
83
+ generateTrial,
84
+ } from "maze-test";
85
+
86
+ const options = {
87
+ seed: 42,
88
+ rows: 15,
89
+ cols: 15,
90
+ language: "en" as const,
91
+ };
92
+
93
+ const question = generateQuestion(options);
94
+ const answer = generateAnswer(options);
95
+
96
+ // Includes the maze, atomic actions, simulation trace, and structured answers.
97
+ const trial = generateTrial(options);
98
+ ```
99
+
100
+ The lower-level maze generator, validator, renderer, coordinate helpers, shortest-path function, and reference simulator are also exported.
101
+
102
+ ## 中文说明
103
+
104
+ 该工具根据种子与参数生成可复现的迷宫推理试题。题面与答案应分别使用完全相同的参数生成:
105
+
106
+ ```sh
107
+ npx maze-test question --seed 42 --rows 15 --cols 15 --lang zh
108
+ npx maze-test answer --seed 42 --rows 15 --cols 15 --lang zh
109
+ ```
110
+
111
+ 迷宫由实心墙格和空心通路格组成,并支持门、钥匙、宝箱、陷阱、药品房、逐格行动规则和独立参照模拟器。默认语言为英文,`--lang zh` 切换为中文。
112
+
113
+ ## Development
114
+
115
+ ```sh
116
+ pnpm install
117
+ pnpm check
118
+ ```
119
+
120
+ The build emits ESM, CommonJS, type declarations, and source maps to `dist/`.
27
121
 
28
122
  ## License
29
123