@johnmorrisdotca/houseki 0.0.0-stage → 0.1.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +21 -0
  3. package/README.md +79 -2
  4. package/dist/colour-chains/challenge.d.ts +3 -0
  5. package/dist/colour-chains/challenge.js +120 -0
  6. package/dist/colour-chains/content-data.d.ts +2 -0
  7. package/dist/colour-chains/content-data.js +9534 -0
  8. package/dist/colour-chains/content-types.d.ts +80 -0
  9. package/dist/colour-chains/content-types.js +1 -0
  10. package/dist/colour-chains/content.d.ts +11 -0
  11. package/dist/colour-chains/content.js +28 -0
  12. package/dist/colour-chains/engine.d.ts +19 -0
  13. package/dist/colour-chains/engine.js +493 -0
  14. package/dist/colour-chains/input.d.ts +24 -0
  15. package/dist/colour-chains/input.js +77 -0
  16. package/dist/colour-chains/match.d.ts +5 -0
  17. package/dist/colour-chains/match.js +48 -0
  18. package/dist/colour-chains/persistence.d.ts +7 -0
  19. package/dist/colour-chains/persistence.js +96 -0
  20. package/dist/colour-chains/random.d.ts +7 -0
  21. package/dist/colour-chains/random.js +49 -0
  22. package/dist/colour-chains/types.d.ts +191 -0
  23. package/dist/colour-chains/types.js +1 -0
  24. package/dist/colour-chains/validation.d.ts +16 -0
  25. package/dist/colour-chains/validation.js +80 -0
  26. package/dist/colour-chains.d.ts +8 -0
  27. package/dist/colour-chains.js +7 -0
  28. package/dist/falling-triplets/content-data.d.ts +7258 -0
  29. package/dist/falling-triplets/content-data.js +18073 -0
  30. package/dist/falling-triplets/content-types.d.ts +72 -0
  31. package/dist/falling-triplets/content-types.js +1 -0
  32. package/dist/falling-triplets/content.d.ts +11 -0
  33. package/dist/falling-triplets/content.js +39 -0
  34. package/dist/falling-triplets/engine.d.ts +26 -0
  35. package/dist/falling-triplets/engine.js +541 -0
  36. package/dist/falling-triplets/input.d.ts +18 -0
  37. package/dist/falling-triplets/input.js +41 -0
  38. package/dist/falling-triplets/match.d.ts +9 -0
  39. package/dist/falling-triplets/match.js +45 -0
  40. package/dist/falling-triplets/random.d.ts +9 -0
  41. package/dist/falling-triplets/random.js +44 -0
  42. package/dist/falling-triplets/types.d.ts +134 -0
  43. package/dist/falling-triplets/types.js +1 -0
  44. package/dist/falling-triplets.d.ts +7 -0
  45. package/dist/falling-triplets.js +6 -0
  46. package/dist/gem-swap/black-hole.d.ts +7 -0
  47. package/dist/gem-swap/black-hole.js +54 -0
  48. package/dist/gem-swap/board.d.ts +25 -0
  49. package/dist/gem-swap/board.js +89 -0
  50. package/dist/gem-swap/content.d.ts +75 -0
  51. package/dist/gem-swap/content.js +68 -0
  52. package/dist/gem-swap/engine.d.ts +25 -0
  53. package/dist/gem-swap/engine.js +689 -0
  54. package/dist/gem-swap/persistence.d.ts +17 -0
  55. package/dist/gem-swap/persistence.js +107 -0
  56. package/dist/gem-swap/practice.d.ts +4 -0
  57. package/dist/gem-swap/practice.js +57 -0
  58. package/dist/gem-swap/random.d.ts +9 -0
  59. package/dist/gem-swap/random.js +32 -0
  60. package/dist/gem-swap/specials.d.ts +13 -0
  61. package/dist/gem-swap/specials.js +300 -0
  62. package/dist/gem-swap/tools.d.ts +3 -0
  63. package/dist/gem-swap/tools.js +20 -0
  64. package/dist/gem-swap/types.d.ts +200 -0
  65. package/dist/gem-swap/types.js +1 -0
  66. package/dist/gem-swap.d.ts +5 -0
  67. package/dist/gem-swap.js +3 -0
  68. package/dist/index.d.ts +7 -0
  69. package/dist/index.js +7 -0
  70. package/dist/magnetic-blocks/engine.d.ts +11 -0
  71. package/dist/magnetic-blocks/engine.js +263 -0
  72. package/dist/magnetic-blocks/persistence.d.ts +7 -0
  73. package/dist/magnetic-blocks/persistence.js +104 -0
  74. package/dist/magnetic-blocks/physics.d.ts +30 -0
  75. package/dist/magnetic-blocks/physics.js +155 -0
  76. package/dist/magnetic-blocks/random.d.ts +6 -0
  77. package/dist/magnetic-blocks/random.js +19 -0
  78. package/dist/magnetic-blocks/types.d.ts +158 -0
  79. package/dist/magnetic-blocks/types.js +1 -0
  80. package/dist/magnetic-blocks/validation.d.ts +23 -0
  81. package/dist/magnetic-blocks/validation.js +121 -0
  82. package/dist/magnetic-blocks.d.ts +5 -0
  83. package/dist/magnetic-blocks.js +4 -0
  84. package/dist/nature/attraction.d.ts +5 -0
  85. package/dist/nature/attraction.js +136 -0
  86. package/dist/nature/environment.d.ts +91 -0
  87. package/dist/nature/environment.js +272 -0
  88. package/dist/nature/marking.d.ts +3 -0
  89. package/dist/nature/marking.js +39 -0
  90. package/dist/nature/random.d.ts +3 -0
  91. package/dist/nature/random.js +19 -0
  92. package/dist/nature/rebound.d.ts +5 -0
  93. package/dist/nature/rebound.js +98 -0
  94. package/dist/nature/state.d.ts +3 -0
  95. package/dist/nature/state.js +22 -0
  96. package/dist/nature/types.d.ts +124 -0
  97. package/dist/nature/types.js +1 -0
  98. package/dist/nature/validation.d.ts +10 -0
  99. package/dist/nature/validation.js +117 -0
  100. package/dist/nature.d.ts +8 -0
  101. package/dist/nature.js +7 -0
  102. package/dist/stone-collapse/content-data.d.ts +14218 -0
  103. package/dist/stone-collapse/content-data.js +25217 -0
  104. package/dist/stone-collapse/content-types.d.ts +77 -0
  105. package/dist/stone-collapse/content-types.js +1 -0
  106. package/dist/stone-collapse/content.d.ts +11 -0
  107. package/dist/stone-collapse/content.js +28 -0
  108. package/dist/stone-collapse/engine.d.ts +19 -0
  109. package/dist/stone-collapse/engine.js +570 -0
  110. package/dist/stone-collapse/persistence.d.ts +7 -0
  111. package/dist/stone-collapse/persistence.js +230 -0
  112. package/dist/stone-collapse/types.d.ts +216 -0
  113. package/dist/stone-collapse/types.js +1 -0
  114. package/dist/stone-collapse/validation.d.ts +21 -0
  115. package/dist/stone-collapse/validation.js +135 -0
  116. package/dist/stone-collapse.d.ts +6 -0
  117. package/dist/stone-collapse.js +4 -0
  118. package/package.json +96 -4
@@ -0,0 +1,77 @@
1
+ import type { ChallengeGoal, Stone, StoneColour } from './types.js';
2
+ export interface LocalizedText {
3
+ readonly en: string;
4
+ readonly ja: string;
5
+ }
6
+ export interface CollapseDifficultyMetrics {
7
+ readonly seededPlayoutSamples: number;
8
+ readonly seededPlayoutSuccesses: number;
9
+ readonly seededPlayoutSuccessRate: number;
10
+ readonly legalGroupChoices: number;
11
+ readonly witnessedDecisionCount: number;
12
+ readonly sampledOrderFailureShare: number;
13
+ readonly forcedSafeGroupShare: number;
14
+ readonly averageGroupChoices: number;
15
+ readonly witnessMoves: number;
16
+ readonly moveBudgetSlack: number;
17
+ }
18
+ export interface CollapseCampaignLevel {
19
+ readonly id: string;
20
+ readonly number: number;
21
+ readonly title: LocalizedText;
22
+ readonly canonicalKeyHash: string;
23
+ readonly width: number;
24
+ readonly height: number;
25
+ readonly colourCount: 4;
26
+ readonly mask?: readonly boolean[];
27
+ readonly seed: string;
28
+ readonly board: readonly (Stone | null)[];
29
+ readonly goal: ChallengeGoal;
30
+ readonly moveLimit: number;
31
+ readonly witness: readonly (readonly number[])[];
32
+ readonly tags: readonly string[];
33
+ readonly rawMetrics: CollapseDifficultyMetrics;
34
+ readonly score: number;
35
+ readonly marks: 1 | 2 | 3 | 4 | 5;
36
+ readonly gradingVersion: string;
37
+ readonly proofStatus: 'engine-witness-verified';
38
+ readonly reviewStatus: 'human-review-pending';
39
+ }
40
+ export interface CollapseCampaignManifest {
41
+ readonly count: number;
42
+ readonly candidatePoolCount: number;
43
+ readonly generationRevision: string;
44
+ readonly gradingVersion: string;
45
+ readonly category: string;
46
+ readonly curationPolicy: string;
47
+ readonly orderingPolicy: string;
48
+ readonly grading: Readonly<Record<string, unknown>>;
49
+ readonly sampleBudget: number;
50
+ readonly checksum: string;
51
+ readonly levels: readonly CollapseCampaignLevel[];
52
+ }
53
+ export interface CollapseTutorialStep {
54
+ readonly instruction: LocalizedText;
55
+ readonly action: string;
56
+ }
57
+ export interface CollapseTutorialDefinition {
58
+ readonly id: string;
59
+ readonly title: LocalizedText;
60
+ readonly objective: LocalizedText;
61
+ readonly setup: {
62
+ readonly width: number;
63
+ readonly height: number;
64
+ readonly colourCount: 4;
65
+ readonly board: readonly (Stone | null)[];
66
+ readonly goal: ChallengeGoal;
67
+ readonly moveLimit?: number;
68
+ readonly witness: readonly (readonly number[])[];
69
+ };
70
+ readonly steps: readonly CollapseTutorialStep[];
71
+ readonly tags: readonly string[];
72
+ }
73
+ export interface CollapseContentData {
74
+ readonly campaign: CollapseCampaignManifest;
75
+ readonly tutorials: readonly CollapseTutorialDefinition[];
76
+ }
77
+ export type { ChallengeGoal, Stone, StoneColour };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { CollapseCampaignLevel, CollapseCampaignManifest, CollapseTutorialDefinition } from './content-types.js';
2
+ import type { GameState } from './types.js';
3
+ export declare const campaignManifest: CollapseCampaignManifest;
4
+ export declare const levelManifest: readonly CollapseCampaignLevel[];
5
+ export declare const tutorialManifest: readonly CollapseTutorialDefinition[];
6
+ /** Find a challenge by its persistent content ID or current one-based display number. */
7
+ export declare function getLevel(id: string | number): CollapseCampaignLevel | undefined;
8
+ /** Construct a fresh engine-validated challenge from a content ID or display number. */
9
+ export declare function createLevel(id: string | number): GameState;
10
+ /** Find a persistent interactive lesson by its stable ID. */
11
+ export declare function getTutorial(id: string): CollapseTutorialDefinition | undefined;
@@ -0,0 +1,28 @@
1
+ import { contentData } from './content-data.js';
2
+ import { createChallenge } from './engine.js';
3
+ function deepFreeze(value) {
4
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
5
+ Object.freeze(value);
6
+ for (const child of Object.values(value))
7
+ deepFreeze(child);
8
+ }
9
+ return value;
10
+ }
11
+ export const campaignManifest = deepFreeze(contentData.campaign);
12
+ export const levelManifest = campaignManifest.levels;
13
+ export const tutorialManifest = deepFreeze(contentData.tutorials);
14
+ /** Find a challenge by its persistent content ID or current one-based display number. */
15
+ export function getLevel(id) {
16
+ if (typeof id === 'number')
17
+ return Number.isInteger(id) ? levelManifest.find(level => level.number === id) : undefined;
18
+ return levelManifest.find(level => level.id === id);
19
+ }
20
+ /** Construct a fresh engine-validated challenge from a content ID or display number. */
21
+ export function createLevel(id) {
22
+ const level = getLevel(id);
23
+ if (!level)
24
+ throw new RangeError(`Unknown Stone Collapse level: ${String(id)}`);
25
+ return createChallenge({ id: level.id, seed: level.seed, width: level.width, height: level.height, colourCount: level.colourCount, ...(level.mask ? { mask: level.mask } : {}), initialBoard: level.board, goal: level.goal, moveLimit: level.moveLimit, witness: level.witness });
26
+ }
27
+ /** Find a persistent interactive lesson by its stable ID. */
28
+ export function getTutorial(id) { return tutorialManifest.find(tutorial => tutorial.id === id); }
@@ -0,0 +1,19 @@
1
+ import type { Action, ChallengeOptions, CreateOptions, GameState, GameStatus, Stone, Transition } from './types.js';
2
+ /** @internal Constructs the generator's bounded valid-pair fallback for direct invariant checks. */
3
+ export declare function fallbackBoard(mask: readonly boolean[], width: number, height: number, colourCount: number): readonly (Stone | null)[];
4
+ /** Creates a seeded full board; an all-singleton draw retries before using a checked adjacent pair. */
5
+ export declare function createGame(options?: CreateOptions): GameState;
6
+ /** Creates a fixed witnessed challenge after validating its board, objective, move budget, and every witness group. */
7
+ export declare function createChallenge(options: ChallengeOptions): GameState;
8
+ /** Applies a selection, confirmation, or cancellation without mutating its input. */
9
+ export declare function applyAction(state: GameState, action: Action): Transition;
10
+ /** Selects the next supplied witness group only while the run still matches its path; accepted hints mark the run assisted. */
11
+ export declare function requestHint(state: GameState): Transition;
12
+ /** Restores the full pre-move state in Relaxed or Challenge practice and permanently marks the attempt assisted. */
13
+ export declare function undo(state: GameState): Transition;
14
+ /** Advances the observable 7/6/9 tick removal and gravity stages, bounded to 3600 ticks. */
15
+ export declare function advanceTicks(state: GameState, ticks: number): Transition;
16
+ /** Lists every selection and confirmation currently accepted by the rules. */
17
+ export declare function legalActions(state: GameState): readonly Action[];
18
+ /** Returns the stable public game status and the remaining-stone count. */
19
+ export declare function statusOf(state: GameState): GameStatus;