@johnmorrisdotca/houseki 0.4.1 → 0.4.2

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +77 -95
  3. package/dist/colour-chains/challenge.d.ts +12 -1
  4. package/dist/colour-chains/challenge.js +12 -1
  5. package/dist/colour-chains/content-types.d.ts +112 -0
  6. package/dist/colour-chains/content.d.ts +140 -3
  7. package/dist/colour-chains/content.js +140 -3
  8. package/dist/colour-chains/engine.d.ts +85 -6
  9. package/dist/colour-chains/engine.js +85 -6
  10. package/dist/colour-chains/input.d.ts +97 -7
  11. package/dist/colour-chains/input.js +97 -7
  12. package/dist/colour-chains/persistence.d.ts +36 -3
  13. package/dist/colour-chains/persistence.js +36 -3
  14. package/dist/colour-chains/types.d.ts +291 -17
  15. package/dist/colour-chains/validation.d.ts +12 -1
  16. package/dist/colour-chains/validation.js +12 -1
  17. package/dist/falling-triplets/content-types.d.ts +69 -0
  18. package/dist/falling-triplets/content.d.ts +60 -3
  19. package/dist/falling-triplets/content.js +60 -3
  20. package/dist/falling-triplets/engine.d.ts +122 -10
  21. package/dist/falling-triplets/engine.js +122 -10
  22. package/dist/falling-triplets/input.d.ts +61 -5
  23. package/dist/falling-triplets/input.js +61 -5
  24. package/dist/falling-triplets/match.d.ts +26 -2
  25. package/dist/falling-triplets/match.js +26 -2
  26. package/dist/falling-triplets/random.d.ts +34 -3
  27. package/dist/falling-triplets/random.js +34 -3
  28. package/dist/falling-triplets/types.d.ts +227 -3
  29. package/dist/gem-swap/content.d.ts +116 -0
  30. package/dist/gem-swap/content.js +72 -0
  31. package/dist/gem-swap/engine.d.ts +124 -9
  32. package/dist/gem-swap/engine.js +124 -9
  33. package/dist/gem-swap/persistence.d.ts +60 -4
  34. package/dist/gem-swap/persistence.js +60 -4
  35. package/dist/gem-swap/types.d.ts +336 -3
  36. package/dist/magnetic-blocks/content-types.d.ts +56 -0
  37. package/dist/magnetic-blocks/content.d.ts +91 -5
  38. package/dist/magnetic-blocks/content.js +91 -5
  39. package/dist/magnetic-blocks/engine.d.ts +63 -5
  40. package/dist/magnetic-blocks/engine.js +63 -5
  41. package/dist/magnetic-blocks/persistence.d.ts +36 -3
  42. package/dist/magnetic-blocks/persistence.js +36 -3
  43. package/dist/magnetic-blocks/physics.d.ts +176 -6
  44. package/dist/magnetic-blocks/physics.js +176 -6
  45. package/dist/magnetic-blocks/types.d.ts +185 -1
  46. package/dist/magnetic-blocks/validation.d.ts +12 -0
  47. package/dist/magnetic-blocks/validation.js +12 -0
  48. package/dist/nature/attraction.d.ts +24 -2
  49. package/dist/nature/attraction.js +24 -2
  50. package/dist/nature/environment.d.ts +200 -7
  51. package/dist/nature/environment.js +88 -7
  52. package/dist/nature/marking.d.ts +13 -1
  53. package/dist/nature/marking.js +13 -1
  54. package/dist/nature/rebound.d.ts +30 -2
  55. package/dist/nature/rebound.js +30 -2
  56. package/dist/nature/state.d.ts +11 -0
  57. package/dist/nature/state.js +11 -0
  58. package/dist/nature/types.d.ts +194 -1
  59. package/dist/nature/validation.d.ts +12 -0
  60. package/dist/nature/validation.js +12 -0
  61. package/dist/stone-collapse/content-types.d.ts +69 -0
  62. package/dist/stone-collapse/content.d.ts +60 -3
  63. package/dist/stone-collapse/content.js +60 -3
  64. package/dist/stone-collapse/engine.d.ts +99 -8
  65. package/dist/stone-collapse/engine.js +99 -8
  66. package/dist/stone-collapse/persistence.d.ts +36 -3
  67. package/dist/stone-collapse/persistence.js +36 -3
  68. package/dist/stone-collapse/types.d.ts +220 -3
  69. package/dist/stone-collapse/validation.d.ts +12 -1
  70. package/dist/stone-collapse/validation.js +12 -1
  71. package/package.json +34 -26
@@ -1,5 +1,25 @@
1
1
  import type { NatureEntity, NatureMove, NatureState } from './types.js';
2
+ /** The native fault, jumble or combined earthquake mode.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import type { EarthquakeKind } from "@johnmorrisdotca/houseki/nature";
7
+ *
8
+ * const value: EarthquakeKind = "fault";
9
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
10
+ * ```
11
+ */
2
12
  export type EarthquakeKind = 'fault' | 'jumble' | 'combined';
13
+ /** A periodic, one-turn or authored list of environment trigger turns.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import type { EnvironmentSchedule } from "@johnmorrisdotca/houseki/nature";
18
+ *
19
+ * const value: EnvironmentSchedule = {kind:"authored",turns:[2,4]};
20
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
21
+ * ```
22
+ */
3
23
  export type EnvironmentSchedule = {
4
24
  readonly kind: 'frequent';
5
25
  } | {
@@ -11,15 +31,47 @@ export type EnvironmentSchedule = {
11
31
  readonly kind: 'authored';
12
32
  readonly turns: readonly number[];
13
33
  };
34
+ /** The earthquake mode and optional enabled flag.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import type { EarthquakeOptions } from "@johnmorrisdotca/houseki/nature";
39
+ *
40
+ * const value: EarthquakeOptions = {kind:"fault"};
41
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
42
+ * ```
43
+ */
14
44
  export interface EarthquakeOptions {
15
45
  readonly kind: EarthquakeKind;
16
46
  readonly enabled?: boolean;
17
47
  }
48
+ /** Lightning enablement and explicit columns or a bounded column count.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import type { LightningOptions } from "@johnmorrisdotca/houseki/nature";
53
+ *
54
+ * const value: LightningOptions = {columns:[0]};
55
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
56
+ * ```
57
+ */
18
58
  export interface LightningOptions {
19
59
  readonly enabled?: boolean;
20
60
  readonly columns?: readonly number[];
21
61
  readonly columnCount?: 1 | 2 | 3;
22
62
  }
63
+ /** A pure earthquake fault path, removed ids and resulting occupants/passability mask.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import { createNatureState, previewFault } from "@johnmorrisdotca/houseki/nature";
68
+ * import type { FaultPreview } from "@johnmorrisdotca/houseki/nature";
69
+ *
70
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
71
+ * const value: FaultPreview = previewFault(state);
72
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
73
+ * ```
74
+ */
23
75
  export interface FaultPreview {
24
76
  readonly path: readonly number[];
25
77
  readonly fracturedCells: readonly number[];
@@ -28,6 +80,18 @@ export interface FaultPreview {
28
80
  readonly activeCells: readonly boolean[];
29
81
  readonly randomStateAfter: number;
30
82
  }
83
+ /** A pure eligible-patch shuffle and resulting occupants; reason explains when no patch exists.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { createNatureState, previewJumble } from "@johnmorrisdotca/houseki/nature";
88
+ * import type { JumblePreview } from "@johnmorrisdotca/houseki/nature";
89
+ *
90
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
91
+ * const value: JumblePreview = previewJumble(state);
92
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
93
+ * ```
94
+ */
31
95
  export interface JumblePreview {
32
96
  readonly patchCells: readonly number[];
33
97
  readonly moves: readonly NatureMove[];
@@ -44,6 +108,18 @@ export interface EarthquakePreview {
44
108
  readonly activeCells: readonly boolean[];
45
109
  readonly randomStateAfter: number;
46
110
  }
111
+ /** A pure selected-column removal and resulting occupants/random state.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { createNatureState, previewLightning } from "@johnmorrisdotca/houseki/nature";
116
+ * import type { LightningPreview } from "@johnmorrisdotca/houseki/nature";
117
+ *
118
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
119
+ * const value: LightningPreview = previewLightning(state,{columns:[0]});
120
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
121
+ * ```
122
+ */
47
123
  export interface LightningPreview {
48
124
  readonly columns: readonly number[];
49
125
  readonly removedCells: readonly number[];
@@ -51,7 +127,31 @@ export interface LightningPreview {
51
127
  readonly cells: readonly (NatureEntity | null)[];
52
128
  readonly randomStateAfter: number;
53
129
  }
130
+ /** A native earthquake or lightning preview before it is committed.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * import { createNatureState, previewLightning } from "@johnmorrisdotca/houseki/nature";
135
+ * import type { EnvironmentPreview } from "@johnmorrisdotca/houseki/nature";
136
+ *
137
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
138
+ * const value: EnvironmentPreview = previewLightning(state,{columns:[0]});
139
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
140
+ * ```
141
+ */
54
142
  export type EnvironmentPreview = EarthquakePreview | LightningPreview;
143
+ /** A committed earthquake or lightning event with its native preview fields.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * import { applyLightning, createNatureState } from "@johnmorrisdotca/houseki/nature";
148
+ * import type { EnvironmentEvent } from "@johnmorrisdotca/houseki/nature";
149
+ *
150
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
151
+ * const value: EnvironmentEvent = applyLightning(state,{columns:[0]}).events[0];
152
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
153
+ * ```
154
+ */
55
155
  export type EnvironmentEvent = {
56
156
  readonly type: 'fault-opened';
57
157
  readonly path: readonly number[];
@@ -69,23 +169,116 @@ export type EnvironmentEvent = {
69
169
  readonly removedCells: readonly number[];
70
170
  readonly removedIds: readonly number[];
71
171
  };
172
+ /** The committed environment state, event list and pure preview.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * import { applyLightning, createNatureState } from "@johnmorrisdotca/houseki/nature";
177
+ * import type { EnvironmentTransition } from "@johnmorrisdotca/houseki/nature";
178
+ *
179
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
180
+ * const value: EnvironmentTransition = applyLightning(state,{columns:[0]});
181
+ * console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);
182
+ * ```
183
+ */
72
184
  export interface EnvironmentTransition {
73
185
  readonly state: NatureState;
74
186
  readonly accepted: true;
75
187
  readonly events: readonly EnvironmentEvent[];
76
188
  readonly preview: EnvironmentPreview;
77
189
  }
78
- /** Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn. */
190
+ /** Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn.
191
+ *
192
+ * @param turn - The committed placement/turn number tested against the environment schedule.
193
+ * @param schedule - The native schedule with its authored or periodic trigger settings.
194
+ * @returns Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn.
195
+ * @example
196
+ * ```ts
197
+ * import { isEnvironmentTurnScheduled } from "@johnmorrisdotca/houseki/nature";
198
+ *
199
+ * console.log(isEnvironmentTurnScheduled(2,{kind:"authored",turns:[2,4]}));
200
+ * ```
201
+ */
79
202
  export declare function isEnvironmentTurnScheduled(turn: number, schedule: EnvironmentSchedule): boolean;
80
- /** Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side. */
203
+ /** Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side.
204
+ *
205
+ * @param state - The immutable native state to read or transition; the input is retained.
206
+ * @returns Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side.
207
+ * @example
208
+ * ```ts
209
+ * import { createNatureState, previewFault } from "@johnmorrisdotca/houseki/nature";
210
+ *
211
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
212
+ * console.log(previewFault(state).removedIds.length);
213
+ * ```
214
+ */
81
215
  export declare function previewFault(state: NatureState): FaultPreview;
82
- /** Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3. */
216
+ /** Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3.
217
+ *
218
+ * @param state - The immutable native state to read or transition; the input is retained.
219
+ * @returns Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3.
220
+ * @example
221
+ * ```ts
222
+ * import { createNatureState, previewJumble } from "@johnmorrisdotca/houseki/nature";
223
+ *
224
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
225
+ * console.log(previewJumble(state).changed);
226
+ * ```
227
+ */
83
228
  export declare function previewJumble(state: NatureState): JumblePreview;
84
- /** Preview an earthquake, with Combined always fracturing before its one jumble attempt. */
229
+ /** Preview an earthquake, with Combined always fracturing before its one jumble attempt.
230
+ *
231
+ * @param state - The immutable native state to read or transition; the input is retained.
232
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
233
+ * @returns Preview an earthquake, with Combined always fracturing before its one jumble attempt.
234
+ * @example
235
+ * ```ts
236
+ * import { createNatureState, previewEarthquake } from "@johnmorrisdotca/houseki/nature";
237
+ *
238
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
239
+ * console.log(previewEarthquake(state,{kind:"fault"}).kind);
240
+ * ```
241
+ */
85
242
  export declare function previewEarthquake(state: NatureState, options: EarthquakeOptions): EarthquakePreview;
86
- /** Commit one bounded environmental resolution; matching, gravity and score remain the host game's job. */
243
+ /** Commit one bounded environmental resolution; matching, gravity and score remain the host game's job.
244
+ *
245
+ * @param state - The immutable native state to read or transition; the input is retained.
246
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
247
+ * @returns Commit one bounded environmental resolution; matching, gravity and score remain the host game's job.
248
+ * @example
249
+ * ```ts
250
+ * import { applyEarthquake, createNatureState } from "@johnmorrisdotca/houseki/nature";
251
+ *
252
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
253
+ * console.log(applyEarthquake(state,{kind:"fault"}).accepted);
254
+ * ```
255
+ */
87
256
  export declare function applyEarthquake(state: NatureState, options: EarthquakeOptions): EnvironmentTransition;
88
- /** Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it. */
257
+ /** Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it.
258
+ *
259
+ * @param state - The immutable native state to read or transition; the input is retained.
260
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
261
+ * @returns Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it.
262
+ * @example
263
+ * ```ts
264
+ * import { createNatureState, previewLightning } from "@johnmorrisdotca/houseki/nature";
265
+ *
266
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
267
+ * console.log(previewLightning(state,{columns:[0]}).columns);
268
+ * ```
269
+ */
89
270
  export declare function previewLightning(state: NatureState, options?: LightningOptions): LightningPreview;
90
- /** Commit one lightning strike. It removes exposed stones only and consumes no scores or tools. */
271
+ /** Commit one lightning strike. It removes exposed stones only and consumes no scores or tools.
272
+ *
273
+ * @param state - The immutable native state to read or transition; the input is retained.
274
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
275
+ * @returns Commit one lightning strike. It removes exposed stones only and consumes no scores or tools.
276
+ * @example
277
+ * ```ts
278
+ * import { applyLightning, createNatureState } from "@johnmorrisdotca/houseki/nature";
279
+ *
280
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
281
+ * console.log(applyLightning(state,{columns:[0]}).accepted);
282
+ * ```
283
+ */
91
284
  export declare function applyLightning(state: NatureState, options?: LightningOptions): EnvironmentTransition;
@@ -14,7 +14,18 @@ function drawBelow(state, bound) {
14
14
  const [next, value] = nextNatureUint32(state);
15
15
  return [next, value % bound];
16
16
  }
17
- /** Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn. */
17
+ /** Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn.
18
+ *
19
+ * @param turn - The committed placement/turn number tested against the environment schedule.
20
+ * @param schedule - The native schedule with its authored or periodic trigger settings.
21
+ * @returns Pure one-based schedule lookup: frequent is every second turn; rare is every eighth turn.
22
+ * @example
23
+ * ```ts
24
+ * import { isEnvironmentTurnScheduled } from "@johnmorrisdotca/houseki/nature";
25
+ *
26
+ * console.log(isEnvironmentTurnScheduled(2,{kind:"authored",turns:[2,4]}));
27
+ * ```
28
+ */
18
29
  export function isEnvironmentTurnScheduled(turn, schedule) {
19
30
  if (!Number.isSafeInteger(turn) || turn < 1 || turn > 10_000_000 || !schedule || typeof schedule !== 'object' || Array.isArray(schedule))
20
31
  throw new NatureOptionsError('invalid-nature-options', 'Schedule turn and policy must be valid');
@@ -91,7 +102,18 @@ function faultPath(state) {
91
102
  }
92
103
  return [path, randomState];
93
104
  }
94
- /** Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side. */
105
+ /** Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side.
106
+ *
107
+ * @param state - The immutable native state to read or transition; the input is retained.
108
+ * @returns Preview a bounded top-to-bottom fracture. The path keeps at least one column active on each side.
109
+ * @example
110
+ * ```ts
111
+ * import { createNatureState, previewFault } from "@johnmorrisdotca/houseki/nature";
112
+ *
113
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
114
+ * console.log(previewFault(state).removedIds.length);
115
+ * ```
116
+ */
95
117
  export function previewFault(state) {
96
118
  validateState(state);
97
119
  const [path, randomStateAfter] = faultPath(state);
@@ -139,7 +161,18 @@ function candidatePatches(state) {
139
161
  }
140
162
  return patches;
141
163
  }
142
- /** Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3. */
164
+ /** Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3.
165
+ *
166
+ * @param state - The immutable native state to read or transition; the input is retained.
167
+ * @returns Preview one seeded, nontrivial stone permutation inside a fully active connected rectangle no larger than 3×3.
168
+ * @example
169
+ * ```ts
170
+ * import { createNatureState, previewJumble } from "@johnmorrisdotca/houseki/nature";
171
+ *
172
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
173
+ * console.log(previewJumble(state).changed);
174
+ * ```
175
+ */
143
176
  export function previewJumble(state) {
144
177
  validateState(state);
145
178
  const candidates = candidatePatches(state);
@@ -172,7 +205,19 @@ export function previewJumble(state) {
172
205
  cells[index] = null;
173
206
  return deepFreeze({ patchCells: patch.cells, moves, changed: moves.length > 0, cells, randomStateAfter: randomState });
174
207
  }
175
- /** Preview an earthquake, with Combined always fracturing before its one jumble attempt. */
208
+ /** Preview an earthquake, with Combined always fracturing before its one jumble attempt.
209
+ *
210
+ * @param state - The immutable native state to read or transition; the input is retained.
211
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
212
+ * @returns Preview an earthquake, with Combined always fracturing before its one jumble attempt.
213
+ * @example
214
+ * ```ts
215
+ * import { createNatureState, previewEarthquake } from "@johnmorrisdotca/houseki/nature";
216
+ *
217
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
218
+ * console.log(previewEarthquake(state,{kind:"fault"}).kind);
219
+ * ```
220
+ */
176
221
  export function previewEarthquake(state, options) {
177
222
  validateState(state);
178
223
  validateEarthquakeOptions(options);
@@ -194,7 +239,19 @@ export function previewEarthquake(state, options) {
194
239
  }
195
240
  return deepFreeze({ kind: options.kind, ...(fault ? { fault } : {}), ...(jumble ? { jumble } : {}), cells, activeCells, randomStateAfter });
196
241
  }
197
- /** Commit one bounded environmental resolution; matching, gravity and score remain the host game's job. */
242
+ /** Commit one bounded environmental resolution; matching, gravity and score remain the host game's job.
243
+ *
244
+ * @param state - The immutable native state to read or transition; the input is retained.
245
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
246
+ * @returns Commit one bounded environmental resolution; matching, gravity and score remain the host game's job.
247
+ * @example
248
+ * ```ts
249
+ * import { applyEarthquake, createNatureState } from "@johnmorrisdotca/houseki/nature";
250
+ *
251
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
252
+ * console.log(applyEarthquake(state,{kind:"fault"}).accepted);
253
+ * ```
254
+ */
198
255
  export function applyEarthquake(state, options) {
199
256
  const preview = previewEarthquake(state, options);
200
257
  if (options.enabled === false)
@@ -233,7 +290,19 @@ function chooseColumns(state, options) {
233
290
  }
234
291
  return [pool.slice(0, count).sort((a, b) => a - b), randomState];
235
292
  }
236
- /** Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it. */
293
+ /** Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it.
294
+ *
295
+ * @param state - The immutable native state to read or transition; the input is retained.
296
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
297
+ * @returns Preview seeded or explicitly selected columns; a mask gap or obstacle blocks the strike below it.
298
+ * @example
299
+ * ```ts
300
+ * import { createNatureState, previewLightning } from "@johnmorrisdotca/houseki/nature";
301
+ *
302
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
303
+ * console.log(previewLightning(state,{columns:[0]}).columns);
304
+ * ```
305
+ */
237
306
  export function previewLightning(state, options = {}) {
238
307
  validateState(state);
239
308
  validateLightningOptions(options, state.width);
@@ -258,7 +327,19 @@ export function previewLightning(state, options = {}) {
258
327
  }
259
328
  return deepFreeze({ columns, removedCells, removedIds, cells, randomStateAfter });
260
329
  }
261
- /** Commit one lightning strike. It removes exposed stones only and consumes no scores or tools. */
330
+ /** Commit one lightning strike. It removes exposed stones only and consumes no scores or tools.
331
+ *
332
+ * @param state - The immutable native state to read or transition; the input is retained.
333
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
334
+ * @returns Commit one lightning strike. It removes exposed stones only and consumes no scores or tools.
335
+ * @example
336
+ * ```ts
337
+ * import { applyLightning, createNatureState } from "@johnmorrisdotca/houseki/nature";
338
+ *
339
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
340
+ * console.log(applyLightning(state,{columns:[0]}).accepted);
341
+ * ```
342
+ */
262
343
  export function applyLightning(state, options = {}) {
263
344
  const preview = previewLightning(state, options);
264
345
  if (options.enabled === false)
@@ -1,3 +1,15 @@
1
1
  import type { MarkingOptions, NatureState, NatureTransition } from './types.js';
2
- /** Deterministically assign magnetic markings to settled stones without changing their IDs or colours. */
2
+ /** Deterministically assign magnetic markings to settled stones without changing their IDs or colours.
3
+ *
4
+ * @param state - The immutable native state to read or transition; the input is retained.
5
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
6
+ * @returns Deterministically assign magnetic markings to settled stones without changing their IDs or colours.
7
+ * @example
8
+ * ```ts
9
+ * import { createNatureState, markMagneticStones } from "@johnmorrisdotca/houseki/nature";
10
+ *
11
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
12
+ * console.log(markMagneticStones(state,{probability:0.25,maximum:2}).accepted);
13
+ * ```
14
+ */
3
15
  export declare function markMagneticStones(state: NatureState, options: MarkingOptions): NatureTransition;
@@ -1,7 +1,19 @@
1
1
  import { validateMarkingOptions, validateState } from './validation.js';
2
2
  import { freezeNatureState } from './state.js';
3
3
  import { nextNatureUnit } from './random.js';
4
- /** Deterministically assign magnetic markings to settled stones without changing their IDs or colours. */
4
+ /** Deterministically assign magnetic markings to settled stones without changing their IDs or colours.
5
+ *
6
+ * @param state - The immutable native state to read or transition; the input is retained.
7
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
8
+ * @returns Deterministically assign magnetic markings to settled stones without changing their IDs or colours.
9
+ * @example
10
+ * ```ts
11
+ * import { createNatureState, markMagneticStones } from "@johnmorrisdotca/houseki/nature";
12
+ *
13
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
14
+ * console.log(markMagneticStones(state,{probability:0.25,maximum:2}).accepted);
15
+ * ```
16
+ */
5
17
  export function markMagneticStones(state, options) {
6
18
  validateState(state);
7
19
  validateMarkingOptions(options);
@@ -1,5 +1,33 @@
1
1
  import type { NatureState, NatureTransition, PowerDropPreview, PowerDropRequest } from './types.js';
2
- /** Preview a single normal landing and, for a power drop, at most one validated one-cell rebound. */
2
+ /** Preview a single normal landing and, for a power drop, at most one validated one-cell rebound.
3
+ *
4
+ * @param state - The immutable native state to read or transition; the input is retained.
5
+ * @param request - The native falling piece, pivot id and power/rebound choice.
6
+ * @returns Preview a single normal landing and, for a power drop, at most one validated one-cell rebound.
7
+ * @example
8
+ * ```ts
9
+ * import { createNatureState, previewPowerDrop } from "@johnmorrisdotca/houseki/nature";
10
+ * import type { PowerDropRequest } from "@johnmorrisdotca/houseki/nature";
11
+ *
12
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
13
+ * const request:PowerDropRequest={piece:[{id:1,kind:"stone",colour:"red",x:1,y:0}],pivotId:1,power:true};
14
+ * console.log(previewPowerDrop(state,request).finalCells.length);
15
+ * ```
16
+ */
3
17
  export declare function previewPowerDrop(state: NatureState, request: PowerDropRequest): PowerDropPreview;
4
- /** Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched. */
18
+ /** Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
19
+ *
20
+ * @param state - The immutable native state to read or transition; the input is retained.
21
+ * @param request - The native falling piece, pivot id and power/rebound choice.
22
+ * @returns Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
23
+ * @example
24
+ * ```ts
25
+ * import { applyPowerDrop, createNatureState } from "@johnmorrisdotca/houseki/nature";
26
+ * import type { PowerDropRequest } from "@johnmorrisdotca/houseki/nature";
27
+ *
28
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
29
+ * const request:PowerDropRequest={piece:[{id:1,kind:"stone",colour:"red",x:1,y:0}],pivotId:1,power:true};
30
+ * console.log(applyPowerDrop(state,request).accepted);
31
+ * ```
32
+ */
5
33
  export declare function applyPowerDrop(state: NatureState, request: PowerDropRequest): NatureTransition;
@@ -44,7 +44,21 @@ function preferredDirection(state, request) {
44
44
  return [request.lastHorizontalDirection, state.randomState];
45
45
  return [state.committedPlacements % 2 === 0 ? 'left' : 'right', state.randomState];
46
46
  }
47
- /** Preview a single normal landing and, for a power drop, at most one validated one-cell rebound. */
47
+ /** Preview a single normal landing and, for a power drop, at most one validated one-cell rebound.
48
+ *
49
+ * @param state - The immutable native state to read or transition; the input is retained.
50
+ * @param request - The native falling piece, pivot id and power/rebound choice.
51
+ * @returns Preview a single normal landing and, for a power drop, at most one validated one-cell rebound.
52
+ * @example
53
+ * ```ts
54
+ * import { createNatureState, previewPowerDrop } from "@johnmorrisdotca/houseki/nature";
55
+ * import type { PowerDropRequest } from "@johnmorrisdotca/houseki/nature";
56
+ *
57
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
58
+ * const request:PowerDropRequest={piece:[{id:1,kind:"stone",colour:"red",x:1,y:0}],pivotId:1,power:true};
59
+ * console.log(previewPowerDrop(state,request).finalCells.length);
60
+ * ```
61
+ */
48
62
  export function previewPowerDrop(state, request) {
49
63
  validateState(state);
50
64
  validatePowerDropRequest(state, request);
@@ -81,7 +95,21 @@ export function previewPowerDrop(state, request) {
81
95
  }
82
96
  return freeze({ normalLanding: normal, attempts, rebound: selectedDirection !== undefined, ...(selectedDirection ? { selectedDirection } : {}), quarterTurn: selectedTurn, finalCells, moves: movesBetween(request.piece, finalCells), randomStateAfter });
83
97
  }
84
- /** Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched. */
98
+ /** Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
99
+ *
100
+ * @param state - The immutable native state to read or transition; the input is retained.
101
+ * @param request - The native falling piece, pivot id and power/rebound choice.
102
+ * @returns Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
103
+ * @example
104
+ * ```ts
105
+ * import { applyPowerDrop, createNatureState } from "@johnmorrisdotca/houseki/nature";
106
+ * import type { PowerDropRequest } from "@johnmorrisdotca/houseki/nature";
107
+ *
108
+ * const state=createNatureState({width:4,height:4,seed:"docs"});
109
+ * const request:PowerDropRequest={piece:[{id:1,kind:"stone",colour:"red",x:1,y:0}],pivotId:1,power:true};
110
+ * console.log(applyPowerDrop(state,request).accepted);
111
+ * ```
112
+ */
85
113
  export function applyPowerDrop(state, request) {
86
114
  const preview = previewPowerDrop(state, request);
87
115
  const cells = [...state.cells];
@@ -1,3 +1,14 @@
1
1
  import type { NatureOptions, NatureState } from './types.js';
2
2
  export declare function freezeNatureState(state: NatureState): NatureState;
3
+ /** Create a validated seeded native environment grid with fixed masks and mechanic switches.
4
+ *
5
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
6
+ * @returns Create a validated seeded native environment grid with fixed masks and mechanic switches.
7
+ * @example
8
+ * ```ts
9
+ * import { createNatureState } from "@johnmorrisdotca/houseki/nature";
10
+ *
11
+ * console.log(createNatureState({width:4,height:4,seed:"docs"}).width);
12
+ * ```
13
+ */
3
14
  export declare function createNatureState(options: NatureOptions): NatureState;
@@ -6,6 +6,17 @@ export function freezeNatureState(state) {
6
6
  const rules = Object.freeze({ ...state.rules });
7
7
  return Object.freeze({ ...state, cells, activeCells, rules });
8
8
  }
9
+ /** Create a validated seeded native environment grid with fixed masks and mechanic switches.
10
+ *
11
+ * @param options - Validated native creation, authored challenge, or environment options described by this signature.
12
+ * @returns Create a validated seeded native environment grid with fixed masks and mechanic switches.
13
+ * @example
14
+ * ```ts
15
+ * import { createNatureState } from "@johnmorrisdotca/houseki/nature";
16
+ *
17
+ * console.log(createNatureState({width:4,height:4,seed:"docs"}).width);
18
+ * ```
19
+ */
9
20
  export function createNatureState(options) {
10
21
  validateNatureOptions(options);
11
22
  const cells = options.cells ?? Array(options.width * options.height).fill(null);