maze-test 0.1.0 → 0.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/dist/index.d.ts CHANGED
@@ -1,4 +1,315 @@
1
- /** The npm package name. */
1
+ type Language = "en" | "zh";
2
+ type ScenarioKind = "success" | "treasure-and-leave" | "death-and-stop" | "mechanism-tour";
3
+ type Direction = "up" | "down" | "left" | "right";
4
+ type MechanismComplexity = "basic" | "intermediate" | "advanced";
5
+ type KeyMaterial = "copper" | "silver" | "gold";
6
+ type TreasureType = "treasure" | "coin" | "gem" | "relic";
7
+ type PotionKind = "healing" | "poison" | "antidote" | "haste" | "slow";
8
+ type SpeedMode = "normal" | "fast" | "slow";
9
+ type MaterialCounts = Record<KeyMaterial, number>;
10
+ type TreasureCounts = Record<TreasureType, number>;
11
+ interface MechanismConfig {
12
+ complexity: MechanismComplexity;
13
+ trapDamages: number[];
14
+ potionKinds: PotionKind[];
15
+ keyMaterials: KeyMaterial[];
16
+ treasureTypes: TreasureType[];
17
+ poisonDamage: number;
18
+ poisonDuration: number;
19
+ speedDuration: number;
20
+ movementTime: Record<SpeedMode, number>;
21
+ }
22
+ interface Cell {
23
+ row: number;
24
+ col: number;
25
+ }
26
+ interface Door {
27
+ id: string;
28
+ position: Cell;
29
+ state: "closed";
30
+ material?: KeyMaterial;
31
+ }
32
+ interface KeyObject {
33
+ id: string;
34
+ type: "key";
35
+ position: Cell;
36
+ material?: KeyMaterial;
37
+ }
38
+ interface TreasureContent {
39
+ type: TreasureType;
40
+ count: number;
41
+ }
42
+ interface ChestObject {
43
+ id: string;
44
+ type: "chest";
45
+ position: Cell;
46
+ treasures: number;
47
+ contents: TreasureContent[];
48
+ lockMaterial?: KeyMaterial;
49
+ }
50
+ interface TrapObject {
51
+ id: string;
52
+ type: "trap";
53
+ position: Cell;
54
+ damage: number;
55
+ }
56
+ /** Legacy basic-mode healing object retained for schema compatibility. */
57
+ interface MedicineObject {
58
+ id: string;
59
+ type: "medicine";
60
+ position: Cell;
61
+ recovery: number;
62
+ }
63
+ interface PotionObject {
64
+ id: string;
65
+ type: "potion";
66
+ position: Cell;
67
+ kind: PotionKind;
68
+ potency?: number;
69
+ duration?: number;
70
+ }
71
+ type MazeObject = KeyObject | ChestObject | TrapObject | MedicineObject | PotionObject;
72
+ interface MazeMetrics {
73
+ totalCells: number;
74
+ wallCells: number;
75
+ floorCells: number;
76
+ connectedFloorCells: number;
77
+ connected: boolean;
78
+ floorAdjacencyEdges: number;
79
+ independentCycles: number;
80
+ deadEnds: number;
81
+ junctions: number;
82
+ entryGoalDistance: number | null;
83
+ doorCount: number;
84
+ gatingDoorCount: number;
85
+ objectCounts: Partial<Record<MazeObject["type"], number>>;
86
+ }
87
+ interface Maze {
88
+ schemaVersion: "solid-cell-maze-v3@1" | "solid-cell-maze-v4@1";
89
+ id: string;
90
+ seed: number;
91
+ requestedSeed: number;
92
+ rows: number;
93
+ cols: number;
94
+ braid: number;
95
+ coordinateSystem: {
96
+ origin: "top-left";
97
+ columns: "letters-left-to-right";
98
+ rows: "numbers-top-to-bottom";
99
+ };
100
+ mechanisms: MechanismConfig;
101
+ terrain: string[];
102
+ entry: Cell;
103
+ goal: Cell;
104
+ doors: Door[];
105
+ objects: MazeObject[];
106
+ metrics: MazeMetrics;
107
+ }
108
+ interface GenerateMazeOptions {
109
+ rows?: number;
110
+ cols?: number;
111
+ seed?: number;
112
+ requestedSeed?: number;
113
+ braid?: number;
114
+ id?: string;
115
+ mechanisms?: MechanismConfig;
116
+ }
117
+ interface DecorateMazeOptions {
118
+ seed?: number;
119
+ doorCount?: number;
120
+ chestCount?: number;
121
+ trapCount?: number;
122
+ medicineCount?: number;
123
+ potionCount?: number;
124
+ mechanisms?: MechanismConfig;
125
+ }
126
+ interface InitialState {
127
+ health: number;
128
+ healthMax: number;
129
+ keys: number;
130
+ treasures: number;
131
+ keysByMaterial?: Partial<MaterialCounts>;
132
+ treasuresByType?: Partial<TreasureCounts>;
133
+ elapsedTime?: number;
134
+ speed?: SpeedMode;
135
+ speedRemaining?: number;
136
+ poisonDamage?: number;
137
+ poisonRemaining?: number;
138
+ }
139
+ interface TrialState {
140
+ position: Cell;
141
+ health: number;
142
+ healthMax: number;
143
+ keys: number;
144
+ keysByMaterial: MaterialCounts;
145
+ treasures: number;
146
+ treasuresByType: TreasureCounts;
147
+ elapsedTime: number;
148
+ speed: SpeedMode;
149
+ speedRemaining: number;
150
+ poisonDamage: number;
151
+ poisonRemaining: number;
152
+ alive: boolean;
153
+ reachedGoal: boolean;
154
+ openedDoors: string[];
155
+ collectedKeys: string[];
156
+ openedChests: string[];
157
+ triggeredTraps: string[];
158
+ usedMedicines: string[];
159
+ usedPotions: string[];
160
+ }
161
+ interface TrialEvent {
162
+ type: "open-door" | "collect-key" | "open-chest" | "pass-closed-chest" | "trigger-trap" | "use-medicine" | "drink-potion" | "poison-tick" | "speed-expired" | "die" | "reach-goal";
163
+ id?: string;
164
+ material?: KeyMaterial;
165
+ potionKind?: PotionKind;
166
+ keyCost?: number;
167
+ treasures?: number;
168
+ contents?: TreasureContent[];
169
+ damage?: number;
170
+ recovery?: number;
171
+ duration?: number;
172
+ timeCost?: number;
173
+ }
174
+ type BlockedReason = "dead" | "wall-or-outside" | "closed-door-without-key" | "closed-door-without-matching-key";
175
+ interface TrialTraceItem {
176
+ step: number;
177
+ direction: Direction;
178
+ before: TrialState;
179
+ moved: boolean;
180
+ reason: BlockedReason | null;
181
+ events: TrialEvent[];
182
+ after: TrialState;
183
+ }
184
+ interface TrialAnswers {
185
+ finalPosition: string;
186
+ keys: number;
187
+ keysByMaterial: MaterialCounts;
188
+ treasures: number;
189
+ treasuresByType: TreasureCounts;
190
+ health: number;
191
+ alive: boolean;
192
+ reachedGoal: boolean;
193
+ openedDoors: number;
194
+ openedChests: number;
195
+ triggeredTraps: number;
196
+ usedMedicines: number;
197
+ usedPotions: number;
198
+ elapsedTime: number;
199
+ finalSpeed: SpeedMode;
200
+ speedRemaining: number;
201
+ poisonDamage: number;
202
+ poisonRemaining: number;
203
+ blockedMoves: number;
204
+ blockedAfterDeath: number;
205
+ }
206
+ interface SimulationResult {
207
+ state: TrialState;
208
+ trace: TrialTraceItem[];
209
+ answers: TrialAnswers;
210
+ }
211
+ interface TrialOptions {
212
+ seed?: number;
213
+ rows?: number;
214
+ cols?: number;
215
+ braid?: number;
216
+ doorCount?: number;
217
+ chestCount?: number;
218
+ trapCount?: number;
219
+ medicineCount?: number;
220
+ potionCount?: number;
221
+ complexity?: MechanismComplexity;
222
+ trapDamages?: number[];
223
+ potionKinds?: PotionKind[];
224
+ keyMaterials?: KeyMaterial[];
225
+ treasureTypes?: TreasureType[];
226
+ poisonDamage?: number;
227
+ poisonDuration?: number;
228
+ speedDuration?: number;
229
+ scenario?: ScenarioKind;
230
+ language?: Language;
231
+ style?: number;
232
+ minDistance?: number;
233
+ maxAttempts?: number;
234
+ }
235
+ interface ResolvedTrialOptions {
236
+ seed: number;
237
+ rows: number;
238
+ cols: number;
239
+ braid: number;
240
+ doorCount: number;
241
+ chestCount: number;
242
+ trapCount: number;
243
+ potionCount: number;
244
+ mechanisms: MechanismConfig;
245
+ scenario: ScenarioKind;
246
+ language: Language;
247
+ style: number;
248
+ minDistance: number;
249
+ maxAttempts: number;
250
+ }
251
+ interface TrialSections {
252
+ map: string;
253
+ rules: string;
254
+ actions: string;
255
+ questions: string;
256
+ }
257
+ interface MazeTrial {
258
+ schemaVersion: "maze-test-trial@2";
259
+ options: ResolvedTrialOptions;
260
+ maze: Maze;
261
+ initialState: InitialState;
262
+ actions: Direction[];
263
+ sections: TrialSections;
264
+ question: string;
265
+ answer: string;
266
+ result: SimulationResult;
267
+ }
268
+ interface MazeValidation {
269
+ valid: boolean;
270
+ errors: string[];
271
+ metrics: MazeMetrics | null;
272
+ }
273
+
274
+ declare function cell(row: number, col: number): Cell;
275
+ declare function cellKey(value: Cell): string;
276
+ declare function sameCell(a: Cell | undefined, b: Cell | undefined): boolean;
277
+ declare function columnLabel(col: number): string;
278
+ declare function letterNumberCoordinate(value: Cell): string;
279
+ declare function rowColumnCoordinate(value: Cell): string;
280
+ declare function neighbors(value: Cell, rows: number, cols: number): Cell[];
281
+
282
+ declare function generateSolidCellMaze(options?: GenerateMazeOptions): Maze;
283
+ declare function decorateSolidCellMaze(maze: Maze, options?: DecorateMazeOptions): Maze;
284
+ declare function analyzeSolidCellMaze(maze: Maze): MazeMetrics;
285
+ declare function validateSolidCellMaze(maze: Maze): MazeValidation;
286
+ declare function shortestPath(maze: Pick<Maze, "rows" | "cols" | "terrain">, start: Cell, goal: Cell, excludedCell?: Cell | null): Cell[];
287
+ declare function terrainAt(maze: Pick<Maze, "rows" | "cols" | "terrain">, value: Cell): string | null;
288
+ declare function isFloor(maze: Pick<Maze, "rows" | "cols" | "terrain">, value: Cell): boolean;
289
+
290
+ declare function renderCharacterMaze(maze: Maze, language?: Language): string;
291
+
292
+ declare function mechanismPreset(complexity: MechanismComplexity): MechanismConfig;
293
+ declare function resolveMechanisms(options: TrialOptions): MechanismConfig;
294
+ declare function defaultObjectCounts(complexity: MechanismComplexity): {
295
+ doors: number;
296
+ chests: number;
297
+ traps: number;
298
+ potions: number;
299
+ };
300
+ declare function emptyMaterialCounts(values?: Partial<MaterialCounts>): MaterialCounts;
301
+ declare function emptyTreasureCounts(values?: Partial<TreasureCounts>): TreasureCounts;
302
+ declare function totalMaterialKeys(counts: MaterialCounts): number;
303
+
304
+ declare function simulateTrial(maze: Maze, actions: readonly Direction[], initial?: Partial<InitialState>): SimulationResult;
305
+ declare function stateKey(state: TrialState): string;
306
+
307
+ declare function generateTrial(options?: TrialOptions): MazeTrial;
308
+ declare function generateQuestion(options?: TrialOptions): string;
309
+ declare function generateAnswer(options?: TrialOptions): string;
310
+ declare function resolveTrialOptions(options?: TrialOptions): ResolvedTrialOptions;
311
+
312
+ /** The npm package name. Retained for compatibility with the initial release. */
2
313
  declare const packageName = "maze-test";
3
314
 
4
- export { packageName };
315
+ export { type BlockedReason, type Cell, type ChestObject, type DecorateMazeOptions, type Direction, type Door, type GenerateMazeOptions, type InitialState, type KeyMaterial, type KeyObject, type Language, type MaterialCounts, type Maze, type MazeMetrics, type MazeObject, type MazeTrial, type MazeValidation, type MechanismComplexity, type MechanismConfig, type MedicineObject, type PotionKind, type PotionObject, type ResolvedTrialOptions, type ScenarioKind, type SimulationResult, type SpeedMode, type TrapObject, type TreasureContent, type TreasureCounts, type TreasureType, type TrialAnswers, type TrialEvent, type TrialOptions, type TrialSections, type TrialState, type TrialTraceItem, analyzeSolidCellMaze, cell, cellKey, columnLabel, decorateSolidCellMaze, defaultObjectCounts, emptyMaterialCounts, emptyTreasureCounts, generateAnswer, generateQuestion, generateSolidCellMaze, generateTrial, isFloor, letterNumberCoordinate, mechanismPreset, neighbors, packageName, renderCharacterMaze, resolveMechanisms, resolveTrialOptions, rowColumnCoordinate, sameCell, shortestPath, simulateTrial, stateKey, terrainAt, totalMaterialKeys, validateSolidCellMaze };