@tastic/cardtastic-engine 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 (87) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +68 -2
  3. package/dist/acesup.d.mts +17 -0
  4. package/dist/acesup.d.ts +17 -0
  5. package/dist/acesup.js +8 -0
  6. package/dist/acesup.mjs +8 -0
  7. package/dist/autoFoundation-CfnFNysj.d.ts +63 -0
  8. package/dist/autoFoundation-Ctp9LKa-.d.mts +63 -0
  9. package/dist/canfield.d.mts +64 -0
  10. package/dist/canfield.d.ts +64 -0
  11. package/dist/canfield.js +20 -0
  12. package/dist/canfield.mjs +20 -0
  13. package/dist/chunk-22DC2YH6.js +95 -0
  14. package/dist/chunk-3BMUGHKQ.mjs +95 -0
  15. package/dist/chunk-4HJ7QMYV.mjs +339 -0
  16. package/dist/chunk-4WAWIFQF.js +131 -0
  17. package/dist/chunk-5266UC2Q.mjs +271 -0
  18. package/dist/chunk-6JWUTZVU.mjs +214 -0
  19. package/dist/chunk-AY3CR5EH.mjs +212 -0
  20. package/dist/chunk-B56TRALO.js +23 -0
  21. package/dist/chunk-CV3VJX34.mjs +341 -0
  22. package/dist/chunk-FDHHAPZA.mjs +177 -0
  23. package/dist/chunk-FTR733R7.mjs +297 -0
  24. package/dist/chunk-GFP5NUYK.mjs +23 -0
  25. package/dist/chunk-IKLYXDG7.mjs +131 -0
  26. package/dist/chunk-LH3UZP7D.js +165 -0
  27. package/dist/chunk-LSS44UKH.js +22 -0
  28. package/dist/chunk-M37CNJHF.mjs +165 -0
  29. package/dist/chunk-PLSNST56.mjs +163 -0
  30. package/dist/chunk-PTRHGPCN.js +163 -0
  31. package/dist/chunk-S3WNVF2K.js +339 -0
  32. package/dist/chunk-SDZPP3HI.mjs +22 -0
  33. package/dist/chunk-SLQ7RGMZ.js +212 -0
  34. package/dist/chunk-TNMFNWEM.mjs +249 -0
  35. package/dist/chunk-VGJPT3CX.js +214 -0
  36. package/dist/chunk-W5CPH6TD.js +115 -0
  37. package/dist/chunk-WJGEX74V.js +341 -0
  38. package/dist/chunk-WKES4P36.js +297 -0
  39. package/dist/chunk-XPTQNUF3.js +348 -0
  40. package/dist/chunk-XSS5M6C7.mjs +115 -0
  41. package/dist/chunk-XTHDUWJF.js +271 -0
  42. package/dist/chunk-XV5OUPIW.js +177 -0
  43. package/dist/chunk-YKY4K67K.mjs +348 -0
  44. package/dist/chunk-ZMNGTXU5.js +249 -0
  45. package/dist/fortythieves.d.mts +50 -0
  46. package/dist/fortythieves.d.ts +50 -0
  47. package/dist/fortythieves.js +22 -0
  48. package/dist/fortythieves.mjs +22 -0
  49. package/dist/freecell.d.mts +30 -0
  50. package/dist/freecell.d.ts +30 -0
  51. package/dist/freecell.js +18 -0
  52. package/dist/freecell.mjs +18 -0
  53. package/dist/gameTypes-BnfLkwzA.d.mts +201 -0
  54. package/dist/gameTypes-BnfLkwzA.d.ts +201 -0
  55. package/dist/golf.d.mts +17 -0
  56. package/dist/golf.d.ts +17 -0
  57. package/dist/golf.js +7 -0
  58. package/dist/golf.mjs +7 -0
  59. package/dist/index.d.mts +176 -0
  60. package/dist/index.d.ts +176 -0
  61. package/dist/index.js +446 -0
  62. package/dist/index.mjs +446 -0
  63. package/dist/klondike.d.mts +25 -0
  64. package/dist/klondike.d.ts +25 -0
  65. package/dist/klondike.js +15 -0
  66. package/dist/klondike.mjs +15 -0
  67. package/dist/pyramid.d.mts +36 -0
  68. package/dist/pyramid.d.ts +36 -0
  69. package/dist/pyramid.js +16 -0
  70. package/dist/pyramid.mjs +16 -0
  71. package/dist/scorpion.d.mts +14 -0
  72. package/dist/scorpion.d.ts +14 -0
  73. package/dist/scorpion.js +9 -0
  74. package/dist/scorpion.mjs +9 -0
  75. package/dist/spider.d.mts +22 -0
  76. package/dist/spider.d.ts +22 -0
  77. package/dist/spider.js +11 -0
  78. package/dist/spider.mjs +11 -0
  79. package/dist/tripeaks.d.mts +43 -0
  80. package/dist/tripeaks.d.ts +43 -0
  81. package/dist/tripeaks.js +19 -0
  82. package/dist/tripeaks.mjs +19 -0
  83. package/dist/yukon.d.mts +24 -0
  84. package/dist/yukon.d.ts +24 -0
  85. package/dist/yukon.js +15 -0
  86. package/dist/yukon.mjs +15 -0
  87. package/package.json +187 -4
package/dist/index.mjs ADDED
@@ -0,0 +1,446 @@
1
+ import {
2
+ createCanfieldController
3
+ } from "./chunk-YKY4K67K.mjs";
4
+ import {
5
+ createScorpionController
6
+ } from "./chunk-AY3CR5EH.mjs";
7
+ import {
8
+ createFortyThievesController
9
+ } from "./chunk-CV3VJX34.mjs";
10
+ import {
11
+ AcesUpController
12
+ } from "./chunk-PLSNST56.mjs";
13
+ import {
14
+ createKlondikeController
15
+ } from "./chunk-4HJ7QMYV.mjs";
16
+ import {
17
+ createSpiderController
18
+ } from "./chunk-TNMFNWEM.mjs";
19
+ import {
20
+ FreeCellController
21
+ } from "./chunk-FTR733R7.mjs";
22
+ import {
23
+ PyramidController
24
+ } from "./chunk-6JWUTZVU.mjs";
25
+ import {
26
+ createYukonController
27
+ } from "./chunk-5266UC2Q.mjs";
28
+ import {
29
+ findSafeAutoPlay,
30
+ isFullyAutoCompletable,
31
+ isFullyAutoCompletableWithDraws,
32
+ isSafeAutoPlay,
33
+ nextAutoCompleteMove,
34
+ nextAutoCompleteMoveWithDraws
35
+ } from "./chunk-3BMUGHKQ.mjs";
36
+ import {
37
+ FOUNDATION_LAYOUT,
38
+ FOUNDATION_SUITS,
39
+ canPlaceOnFoundation,
40
+ suitIndex
41
+ } from "./chunk-SDZPP3HI.mjs";
42
+ import {
43
+ pickBestTableauTarget
44
+ } from "./chunk-GFP5NUYK.mjs";
45
+ import {
46
+ HINT_SEARCH_BUDGET,
47
+ HINT_SEARCH_MAX_MS,
48
+ LOOKAHEAD_BUDGET,
49
+ LOOKAHEAD_MAX_MS,
50
+ ProgressSearch,
51
+ allDestinations,
52
+ columnsKey,
53
+ faceDownCount,
54
+ foundationDownMoves,
55
+ isConclusive,
56
+ pileKey
57
+ } from "./chunk-FDHHAPZA.mjs";
58
+ import {
59
+ createGolfController
60
+ } from "./chunk-IKLYXDG7.mjs";
61
+ import {
62
+ createTriPeaksController
63
+ } from "./chunk-M37CNJHF.mjs";
64
+ import {
65
+ SUITS,
66
+ alwaysValidRun,
67
+ buriedCount,
68
+ cardColor,
69
+ isDescendingAltColor,
70
+ isDescendingAnySuit,
71
+ isDescendingSameSuit,
72
+ isEmpty,
73
+ makeDeck,
74
+ mulberry32,
75
+ randomSeed,
76
+ runCountFrom,
77
+ shuffle,
78
+ shuffledDeck,
79
+ top
80
+ } from "./chunk-XSS5M6C7.mjs";
81
+
82
+ // src/engine/hint.ts
83
+ function refsEqual(a, b) {
84
+ return a.zone === b.zone && a.index === b.index;
85
+ }
86
+ function hintCountFor(hint, ref) {
87
+ if (!hint || hint.kind !== "move") return 0;
88
+ if (refsEqual(hint.move.from, ref)) return hint.move.count;
89
+ return 0;
90
+ }
91
+ function findHint(controller, state, skip = 0) {
92
+ const scored = scoredHint(controller, state, skip);
93
+ return searchedHint(controller, state, skip, scored) ?? scored;
94
+ }
95
+ var searchCache = /* @__PURE__ */ new WeakMap();
96
+ function cachedSearchOutcome(spec, state) {
97
+ return typeof state === "object" && state !== null ? searchCache.get(state)?.get(spec.id) : void 0;
98
+ }
99
+ function cacheSearchOutcome(spec, state, outcome) {
100
+ if (typeof state !== "object" || state === null) return;
101
+ let byRules = searchCache.get(state);
102
+ if (!byRules) searchCache.set(state, byRules = /* @__PURE__ */ new Map());
103
+ const known = byRules.get(spec.id);
104
+ if (!known || outcome.nodes >= known.nodes || isConclusive(outcome)) byRules.set(spec.id, outcome);
105
+ }
106
+ function hintSearchOutcome(controller, state) {
107
+ const spec = controller.progress;
108
+ if (!spec) return null;
109
+ const cached = cachedSearchOutcome(spec, state);
110
+ if (cached && (isConclusive(cached) || cached.nodes >= HINT_SEARCH_BUDGET)) return cached;
111
+ const outcome = new ProgressSearch(controller, spec, state, "hint").run(HINT_SEARCH_BUDGET, HINT_SEARCH_MAX_MS);
112
+ cacheSearchOutcome(spec, state, outcome);
113
+ return outcome;
114
+ }
115
+ var PLAN_MEMORY = 32;
116
+ var planBoards = [];
117
+ function rememberPlanStep(spec, next) {
118
+ if (next === null) return;
119
+ planBoards.push(`${spec.id}/${spec.key(next)}`);
120
+ if (planBoards.length > PLAN_MEMORY) planBoards.shift();
121
+ }
122
+ function searchedHint(controller, state, skip, scored) {
123
+ const spec = controller.progress;
124
+ const tryMove = controller.tryMove;
125
+ if (!spec || !tryMove) return null;
126
+ const searchController = controller;
127
+ const midPlan = planBoards.includes(`${spec.id}/${spec.key(state)}`);
128
+ const productive = !midPlan && scored.kind === "move" && (scored.move.to.zone === "foundation" || !controller.scoreHintMove || controller.scoreHintMove(state, scored.move) > 0);
129
+ const outcome = hintSearchOutcome(searchController, state);
130
+ if (!outcome) return null;
131
+ if (outcome.exhausted) {
132
+ if (!spec.drawIsStep && controller.drawStock && controller.drawStock(state) !== null) return { kind: "drawStock" };
133
+ if (spec.rescueMoves) {
134
+ const rescue = new ProgressSearch(searchController, spec, state, "alive").run(HINT_SEARCH_BUDGET, HINT_SEARCH_MAX_MS);
135
+ const step2 = rescue.firstSteps[0];
136
+ if (step2) return step2.kind === "draw" ? { kind: "drawStock" } : { kind: "move", move: step2.move, choices: 1 };
137
+ }
138
+ return { kind: "none" };
139
+ }
140
+ if (productive || outcome.found !== "progress") return null;
141
+ const steps = outcome.firstSteps;
142
+ const step = steps[skip % steps.length];
143
+ if (step.kind === "draw") {
144
+ rememberPlanStep(spec, controller.drawStock ? controller.drawStock(state) : null);
145
+ return { kind: "drawStock" };
146
+ }
147
+ rememberPlanStep(spec, tryMove(state, step.move));
148
+ return { kind: "move", move: step.move, choices: steps.length };
149
+ }
150
+ function scoredHint(controller, state, skip) {
151
+ const moves = controller.legalMoves(state);
152
+ if (moves.length > 0) {
153
+ const score = controller.scoreHintMove;
154
+ const foundationMoves = moves.filter((m) => m.to.zone === "foundation");
155
+ const otherMoves = moves.filter((m) => m.to.zone !== "foundation" && !(score && isShuffle(controller, state, m, score)));
156
+ const rankedOther = score ? [...otherMoves].sort((a, b) => score(state, b) - score(state, a)) : otherMoves;
157
+ if (score && foundationMoves.length === 0 && otherMoves.every((m) => score(state, m) <= 0) && controller.drawStock && controller.drawStock(state) !== null) {
158
+ return { kind: "drawStock" };
159
+ }
160
+ const ordered = [...foundationMoves, ...rankedOther];
161
+ if (ordered.length > 0) return { kind: "move", move: ordered[skip % ordered.length], choices: ordered.length };
162
+ }
163
+ if (controller.drawStock && controller.drawStock(state) !== null) {
164
+ return { kind: "drawStock" };
165
+ }
166
+ return { kind: "none" };
167
+ }
168
+ function isShuffle(controller, state, move, score) {
169
+ if (!controller.tryMove || score(state, move) > 0) return false;
170
+ const after = controller.tryMove(state, move);
171
+ return after !== null && controller.tryMove(after, { from: move.to, to: move.from, count: move.count }) !== null;
172
+ }
173
+
174
+ // src/engine/score.ts
175
+ function computeScore(moves, elapsedSeconds) {
176
+ return moves + elapsedSeconds;
177
+ }
178
+
179
+ // src/engine/variants.ts
180
+ var SOLITAIRE_GAME_IDS = ["klondike", "spider", "freecell", "pyramid", "yukon", "golf", "tripeaks", "canfield", "scorpion", "fortythieves", "acesup"];
181
+ var VARIANTS = [
182
+ { id: "klondike", game: "klondike", label: "Draw 1" },
183
+ { id: "klondike-draw3", game: "klondike", label: "Draw 3" },
184
+ { id: "spider", game: "spider", label: "1 Suit" },
185
+ { id: "spider-2suit", game: "spider", label: "2 Suits" },
186
+ { id: "spider-4suit", game: "spider", label: "4 Suits" },
187
+ { id: "freecell", game: "freecell", label: null },
188
+ { id: "pyramid", game: "pyramid", label: null },
189
+ { id: "yukon", game: "yukon", label: null },
190
+ { id: "golf", game: "golf", label: "No Wrap" },
191
+ { id: "golf-wrap", game: "golf", label: "K-A Wrap" },
192
+ { id: "tripeaks", game: "tripeaks", label: "No Wrap" },
193
+ { id: "tripeaks-wrap", game: "tripeaks", label: "K-A Wrap" },
194
+ { id: "canfield", game: "canfield", label: "Draw 3" },
195
+ { id: "canfield-draw1", game: "canfield", label: "Draw 1" },
196
+ { id: "scorpion", game: "scorpion", label: "Assisted" },
197
+ { id: "scorpion-classic", game: "scorpion", label: "Classic" },
198
+ { id: "fortythieves", game: "fortythieves", label: "Single Card" },
199
+ { id: "fortythieves-runs", game: "fortythieves", label: "Allow Runs" },
200
+ { id: "acesup", game: "acesup", label: null }
201
+ ];
202
+ var VARIANT_IDS = VARIANTS.map((v) => v.id);
203
+ var BY_ID = Object.fromEntries(VARIANTS.map((v) => [v.id, v]));
204
+ function variantInfo(id) {
205
+ return BY_ID[id];
206
+ }
207
+ function gameOfVariant(id) {
208
+ return BY_ID[id].game;
209
+ }
210
+ function variantsOfGame(game) {
211
+ return VARIANTS.filter((v) => v.game === game).map((v) => v.id);
212
+ }
213
+ var klondikeVariant = (draw) => draw === 3 ? "klondike-draw3" : "klondike";
214
+ var spiderVariant = (suits) => suits === 4 ? "spider-4suit" : suits === 2 ? "spider-2suit" : "spider";
215
+ var canfieldVariant = (draw) => draw === 1 ? "canfield-draw1" : "canfield";
216
+ var golfVariant = (rankWrap) => rankWrap ? "golf-wrap" : "golf";
217
+ var tripeaksVariant = (rankWrap) => rankWrap ? "tripeaks-wrap" : "tripeaks";
218
+ var scorpionVariant = (assistedStock) => assistedStock ? "scorpion" : "scorpion-classic";
219
+ var fortyThievesVariant = (runMoves) => runMoves ? "fortythieves-runs" : "fortythieves";
220
+
221
+ // src/replay.ts
222
+ var MAX_RUN_ACTIONS = 5e3;
223
+ var MAX_SEED = 2 ** 31 - 1;
224
+ var runMove = (move) => [move.from.zone, move.from.index, move.to.zone, move.to.index, move.count];
225
+ var moveOf = (action) => ({ from: { zone: action[0], index: action[1] }, to: { zone: action[2], index: action[3] }, count: action[4] });
226
+ function controllerFor(variant) {
227
+ switch (variant) {
228
+ case "klondike":
229
+ return createKlondikeController(1);
230
+ case "klondike-draw3":
231
+ return createKlondikeController(3);
232
+ case "spider":
233
+ return createSpiderController(1);
234
+ case "spider-2suit":
235
+ return createSpiderController(2);
236
+ case "spider-4suit":
237
+ return createSpiderController(4);
238
+ case "freecell":
239
+ return FreeCellController;
240
+ case "pyramid":
241
+ return PyramidController;
242
+ case "yukon":
243
+ return createYukonController();
244
+ case "golf":
245
+ return createGolfController(false);
246
+ case "golf-wrap":
247
+ return createGolfController(true);
248
+ case "tripeaks":
249
+ return createTriPeaksController(false);
250
+ case "tripeaks-wrap":
251
+ return createTriPeaksController(true);
252
+ case "canfield":
253
+ return createCanfieldController(3);
254
+ case "canfield-draw1":
255
+ return createCanfieldController(1);
256
+ case "scorpion":
257
+ return createScorpionController(true);
258
+ case "scorpion-classic":
259
+ return createScorpionController(false);
260
+ case "fortythieves":
261
+ return createFortyThievesController(false);
262
+ case "fortythieves-runs":
263
+ return createFortyThievesController(true);
264
+ case "acesup":
265
+ return AcesUpController;
266
+ }
267
+ }
268
+ var isVariantId = (value) => typeof value === "string" && VARIANT_IDS.includes(value);
269
+ var isSeed = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= MAX_SEED;
270
+ function piles(variant, state) {
271
+ switch (variantInfo(variant).game) {
272
+ case "klondike":
273
+ case "fortythieves":
274
+ return [...state.tableau, ...state.foundation, state.stock, state.waste];
275
+ case "spider":
276
+ return [...state.tableau, state.stock, ...state.completedRuns];
277
+ case "freecell":
278
+ return [...state.tableau, state.freecells, ...state.foundation];
279
+ case "pyramid":
280
+ return [state.pyramid, state.stock, state.waste, state.discard];
281
+ case "yukon":
282
+ return [...state.tableau, ...state.foundation];
283
+ case "golf":
284
+ return [...state.tableau, state.waste, state.stock];
285
+ case "tripeaks":
286
+ return [state.tableau, state.waste, state.stock];
287
+ case "canfield":
288
+ return [...state.tableau, ...state.foundation, state.reserve, state.stock, state.waste];
289
+ case "scorpion":
290
+ return [...state.tableau, state.stock];
291
+ case "acesup":
292
+ return [...state.piles, state.stock, state.discard];
293
+ }
294
+ }
295
+ function cardsOf(variant, state) {
296
+ const cards = /* @__PURE__ */ new Map();
297
+ let all;
298
+ try {
299
+ all = piles(variant, state);
300
+ } catch {
301
+ return null;
302
+ }
303
+ for (const pile of all) {
304
+ if (!Array.isArray(pile)) return null;
305
+ for (const card of pile) {
306
+ if (card === null) continue;
307
+ if (typeof card !== "object" || typeof card.id !== "string" || cards.has(card.id)) return null;
308
+ cards.set(card.id, card);
309
+ }
310
+ }
311
+ return cards;
312
+ }
313
+ function sameCards(dealt, now) {
314
+ if (!now || now.size !== dealt.size) return false;
315
+ for (const [id, card] of dealt) {
316
+ const other = now.get(id);
317
+ if (!other || other.suit !== card.suit || other.rank !== card.rank) return false;
318
+ }
319
+ return true;
320
+ }
321
+ var isIndex = (value, max) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= max;
322
+ var isZone = (value) => typeof value === "string" && /^[a-z]{1,16}$/.test(value);
323
+ function checkActions(input) {
324
+ if (!Array.isArray(input)) return { error: "The run has no actions" };
325
+ if (input.length === 0) return { error: "The run has no actions" };
326
+ if (input.length > MAX_RUN_ACTIONS) return { error: "The run is too long" };
327
+ for (let i = 0; i < input.length; i++) {
328
+ const action = input[i];
329
+ if (action === "d" || action === "u") continue;
330
+ if (!Array.isArray(action) || action.length !== 5) return { error: `Action ${i + 1} isn't a move, a draw or an undo` };
331
+ const [fromZone, fromIndex, toZone, toIndex, count] = action;
332
+ if (!isZone(fromZone) || !isZone(toZone) || !isIndex(fromIndex, 63) || !isIndex(toIndex, 63) || !isIndex(count, 104) || count === 0) {
333
+ return { error: `Action ${i + 1} isn't a move, a draw or an undo` };
334
+ }
335
+ }
336
+ return { ok: input };
337
+ }
338
+ function replayRun(variant, seed, input) {
339
+ if (!isVariantId(variant)) return { ok: false, error: "Unknown game", at: -1 };
340
+ if (!isSeed(seed)) return { ok: false, error: "Not a deal", at: -1 };
341
+ const checked = checkActions(input);
342
+ if ("error" in checked) return { ok: false, error: checked.error, at: -1 };
343
+ const controller = controllerFor(variant);
344
+ let state = controller.newGame(seed);
345
+ const dealt = cardsOf(variant, state);
346
+ if (!dealt) return { ok: false, error: "The deal is broken", at: -1 };
347
+ const history = [];
348
+ let moves = 0;
349
+ let undos = 0;
350
+ let won = false;
351
+ for (let at = 0; at < checked.ok.length; at++) {
352
+ const action = checked.ok[at];
353
+ if (won) return { ok: false, error: "The deal was already won", at };
354
+ if (action === "u") {
355
+ const previous = history.pop();
356
+ if (previous === void 0) return { ok: false, error: "Nothing to undo", at };
357
+ state = previous;
358
+ undos++;
359
+ continue;
360
+ }
361
+ let next;
362
+ try {
363
+ next = action === "d" ? controller.drawStock?.(state) ?? null : controller.tryMove(state, moveOf(action));
364
+ } catch {
365
+ next = null;
366
+ }
367
+ if (next === null || next === void 0) return { ok: false, error: action === "d" ? "Can't draw" : "Can't make that move", at };
368
+ if (!sameCards(dealt, cardsOf(variant, next))) return { ok: false, error: "Can't make that move", at };
369
+ history.push(state);
370
+ state = next;
371
+ moves++;
372
+ won = controller.isWon(state);
373
+ }
374
+ return { ok: true, won, moves, undos, state };
375
+ }
376
+
377
+ // src/version.ts
378
+ var RULES_VERSION = "0.1.0";
379
+ export {
380
+ FOUNDATION_LAYOUT,
381
+ FOUNDATION_SUITS,
382
+ HINT_SEARCH_BUDGET,
383
+ HINT_SEARCH_MAX_MS,
384
+ LOOKAHEAD_BUDGET,
385
+ LOOKAHEAD_MAX_MS,
386
+ MAX_RUN_ACTIONS,
387
+ MAX_SEED,
388
+ ProgressSearch,
389
+ RULES_VERSION,
390
+ SOLITAIRE_GAME_IDS,
391
+ SUITS,
392
+ VARIANTS,
393
+ VARIANT_IDS,
394
+ allDestinations,
395
+ alwaysValidRun,
396
+ buriedCount,
397
+ cacheSearchOutcome,
398
+ cachedSearchOutcome,
399
+ canPlaceOnFoundation,
400
+ canfieldVariant,
401
+ cardColor,
402
+ checkActions,
403
+ columnsKey,
404
+ computeScore,
405
+ controllerFor,
406
+ faceDownCount,
407
+ findHint,
408
+ findSafeAutoPlay,
409
+ fortyThievesVariant,
410
+ foundationDownMoves,
411
+ gameOfVariant,
412
+ golfVariant,
413
+ hintCountFor,
414
+ hintSearchOutcome,
415
+ isConclusive,
416
+ isDescendingAltColor,
417
+ isDescendingAnySuit,
418
+ isDescendingSameSuit,
419
+ isEmpty,
420
+ isFullyAutoCompletable,
421
+ isFullyAutoCompletableWithDraws,
422
+ isSafeAutoPlay,
423
+ isSeed,
424
+ isVariantId,
425
+ klondikeVariant,
426
+ makeDeck,
427
+ moveOf,
428
+ mulberry32,
429
+ nextAutoCompleteMove,
430
+ nextAutoCompleteMoveWithDraws,
431
+ pickBestTableauTarget,
432
+ pileKey,
433
+ randomSeed,
434
+ replayRun,
435
+ runCountFrom,
436
+ runMove,
437
+ scorpionVariant,
438
+ shuffle,
439
+ shuffledDeck,
440
+ spiderVariant,
441
+ suitIndex,
442
+ top,
443
+ tripeaksVariant,
444
+ variantInfo,
445
+ variantsOfGame
446
+ };
@@ -0,0 +1,25 @@
1
+ import { FinishMove } from './index.mjs';
2
+ import { Card, GameController } from './index.mjs';
3
+
4
+ interface KlondikeState {
5
+ /** 7 tableau columns. */
6
+ tableau: Card[][];
7
+ /** 4 foundation piles, indexed to match engine/foundation's FOUNDATION_SUITS order (spades, diamonds, clubs, hearts). */
8
+ foundation: Card[][];
9
+ stock: Card[];
10
+ waste: Card[];
11
+ }
12
+ declare function createKlondikeController(drawCount: 1 | 3): GameController<KlondikeState>;
13
+ /** True once the board is SOLVED, so the finish (games/shared/useAutoFinish) may file the rest away on its own: not won yet,
14
+ * nothing hidden (no face-down tableau card, an empty stock and waste) and every remaining card able to go up by foundation
15
+ * moves alone. The hidden-card checks are not redundant: isFullyAutoCompletable is also true with face-down cards under the
16
+ * cards that go up (they turn over on the way), and the draws-aware version with cards still in the stock - the finish must
17
+ * never start on a card the player hasn't seen. A won board is false too (isFullyAutoCompletable is true there), so the
18
+ * finish ends after its last card. `controller` is the screen's live one (it is recreated on New Game and restore), though
19
+ * nothing read here depends on its draw count. */
20
+ declare function canAutoFinish(controller: GameController<KlondikeState>, state: KlondikeState): boolean;
21
+ /** The next card the finish should send up, and its own suit's foundation - null unless canAutoFinish. */
22
+ declare function nextFinishMove(controller: GameController<KlondikeState>, state: KlondikeState): FinishMove | null;
23
+
24
+ export { canAutoFinish, createKlondikeController, nextFinishMove };
25
+ export type { KlondikeState };
@@ -0,0 +1,25 @@
1
+ import { FinishMove } from './index.js';
2
+ import { Card, GameController } from './index.js';
3
+
4
+ interface KlondikeState {
5
+ /** 7 tableau columns. */
6
+ tableau: Card[][];
7
+ /** 4 foundation piles, indexed to match engine/foundation's FOUNDATION_SUITS order (spades, diamonds, clubs, hearts). */
8
+ foundation: Card[][];
9
+ stock: Card[];
10
+ waste: Card[];
11
+ }
12
+ declare function createKlondikeController(drawCount: 1 | 3): GameController<KlondikeState>;
13
+ /** True once the board is SOLVED, so the finish (games/shared/useAutoFinish) may file the rest away on its own: not won yet,
14
+ * nothing hidden (no face-down tableau card, an empty stock and waste) and every remaining card able to go up by foundation
15
+ * moves alone. The hidden-card checks are not redundant: isFullyAutoCompletable is also true with face-down cards under the
16
+ * cards that go up (they turn over on the way), and the draws-aware version with cards still in the stock - the finish must
17
+ * never start on a card the player hasn't seen. A won board is false too (isFullyAutoCompletable is true there), so the
18
+ * finish ends after its last card. `controller` is the screen's live one (it is recreated on New Game and restore), though
19
+ * nothing read here depends on its draw count. */
20
+ declare function canAutoFinish(controller: GameController<KlondikeState>, state: KlondikeState): boolean;
21
+ /** The next card the finish should send up, and its own suit's foundation - null unless canAutoFinish. */
22
+ declare function nextFinishMove(controller: GameController<KlondikeState>, state: KlondikeState): FinishMove | null;
23
+
24
+ export { canAutoFinish, createKlondikeController, nextFinishMove };
25
+ export type { KlondikeState };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkS3WNVF2Kjs = require('./chunk-S3WNVF2K.js');
6
+ require('./chunk-22DC2YH6.js');
7
+ require('./chunk-LSS44UKH.js');
8
+ require('./chunk-B56TRALO.js');
9
+ require('./chunk-XV5OUPIW.js');
10
+ require('./chunk-W5CPH6TD.js');
11
+
12
+
13
+
14
+
15
+ exports.canAutoFinish = _chunkS3WNVF2Kjs.canAutoFinish; exports.createKlondikeController = _chunkS3WNVF2Kjs.createKlondikeController; exports.nextFinishMove = _chunkS3WNVF2Kjs.nextFinishMove;
@@ -0,0 +1,15 @@
1
+ import {
2
+ canAutoFinish,
3
+ createKlondikeController,
4
+ nextFinishMove
5
+ } from "./chunk-4HJ7QMYV.mjs";
6
+ import "./chunk-3BMUGHKQ.mjs";
7
+ import "./chunk-SDZPP3HI.mjs";
8
+ import "./chunk-GFP5NUYK.mjs";
9
+ import "./chunk-FDHHAPZA.mjs";
10
+ import "./chunk-XSS5M6C7.mjs";
11
+ export {
12
+ canAutoFinish,
13
+ createKlondikeController,
14
+ nextFinishMove
15
+ };
@@ -0,0 +1,36 @@
1
+ import { GameController, Card, PileRef } from './index.mjs';
2
+
3
+ interface PyramidState {
4
+ /** Flat 28-slot triangle; `null` once that card has been removed. */
5
+ pyramid: (Card | null)[];
6
+ stock: Card[];
7
+ waste: Card[];
8
+ /** Every card ever removed via a pair or solo King, oldest first (array end = top, same
9
+ * convention as stock/waste). Always face-up once here, regardless of its prior faceUp. Once the
10
+ * pyramid is cleared, sweepRemainderOnWin also appends whatever was left in waste/stock, so a
11
+ * won game's discard always holds all 52 cards. */
12
+ discard: Card[];
13
+ /** How many cards have been consumed via a pair or solo King, from either the pyramid or the
14
+ * waste (NOT specifically pyramid cards - see isWon, which checks the triangle directly rather
15
+ * than this counter, since a card can be consumed from waste too). Kept purely as a move-size
16
+ * stat; nothing reads it to determine whether the game is won. */
17
+ removedCount: number;
18
+ }
19
+ /** Flat array index for the card at (row, col), 0-indexed, col from 0..row. */
20
+ declare function flatIndex(row: number, col: number): number;
21
+ /** Inverse of flatIndex: which (row, col) a flat index corresponds to. */
22
+ declare function rowColOf(index: number): {
23
+ row: number;
24
+ col: number;
25
+ };
26
+ /**
27
+ * A pyramid card at (row, col) is exposed (removable) once the (up to) two
28
+ * cards resting on it in the row below have both already been removed.
29
+ * Row 6 (the bottom row) is always exposed if occupied.
30
+ */
31
+ declare function isExposed(pyramid: (Card | null)[], row: number, col: number): boolean;
32
+ declare function cardAt(state: PyramidState, ref: PileRef): Card | null;
33
+ declare const PyramidController: GameController<PyramidState>;
34
+
35
+ export { PyramidController, cardAt, flatIndex, isExposed, rowColOf };
36
+ export type { PyramidState };
@@ -0,0 +1,36 @@
1
+ import { GameController, Card, PileRef } from './index.js';
2
+
3
+ interface PyramidState {
4
+ /** Flat 28-slot triangle; `null` once that card has been removed. */
5
+ pyramid: (Card | null)[];
6
+ stock: Card[];
7
+ waste: Card[];
8
+ /** Every card ever removed via a pair or solo King, oldest first (array end = top, same
9
+ * convention as stock/waste). Always face-up once here, regardless of its prior faceUp. Once the
10
+ * pyramid is cleared, sweepRemainderOnWin also appends whatever was left in waste/stock, so a
11
+ * won game's discard always holds all 52 cards. */
12
+ discard: Card[];
13
+ /** How many cards have been consumed via a pair or solo King, from either the pyramid or the
14
+ * waste (NOT specifically pyramid cards - see isWon, which checks the triangle directly rather
15
+ * than this counter, since a card can be consumed from waste too). Kept purely as a move-size
16
+ * stat; nothing reads it to determine whether the game is won. */
17
+ removedCount: number;
18
+ }
19
+ /** Flat array index for the card at (row, col), 0-indexed, col from 0..row. */
20
+ declare function flatIndex(row: number, col: number): number;
21
+ /** Inverse of flatIndex: which (row, col) a flat index corresponds to. */
22
+ declare function rowColOf(index: number): {
23
+ row: number;
24
+ col: number;
25
+ };
26
+ /**
27
+ * A pyramid card at (row, col) is exposed (removable) once the (up to) two
28
+ * cards resting on it in the row below have both already been removed.
29
+ * Row 6 (the bottom row) is always exposed if occupied.
30
+ */
31
+ declare function isExposed(pyramid: (Card | null)[], row: number, col: number): boolean;
32
+ declare function cardAt(state: PyramidState, ref: PileRef): Card | null;
33
+ declare const PyramidController: GameController<PyramidState>;
34
+
35
+ export { PyramidController, cardAt, flatIndex, isExposed, rowColOf };
36
+ export type { PyramidState };
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkVGJPT3CXjs = require('./chunk-VGJPT3CX.js');
8
+ require('./chunk-XV5OUPIW.js');
9
+ require('./chunk-W5CPH6TD.js');
10
+
11
+
12
+
13
+
14
+
15
+
16
+ exports.PyramidController = _chunkVGJPT3CXjs.PyramidController; exports.cardAt = _chunkVGJPT3CXjs.cardAt; exports.flatIndex = _chunkVGJPT3CXjs.flatIndex; exports.isExposed = _chunkVGJPT3CXjs.isExposed; exports.rowColOf = _chunkVGJPT3CXjs.rowColOf;
@@ -0,0 +1,16 @@
1
+ import {
2
+ PyramidController,
3
+ cardAt,
4
+ flatIndex,
5
+ isExposed,
6
+ rowColOf
7
+ } from "./chunk-6JWUTZVU.mjs";
8
+ import "./chunk-FDHHAPZA.mjs";
9
+ import "./chunk-XSS5M6C7.mjs";
10
+ export {
11
+ PyramidController,
12
+ cardAt,
13
+ flatIndex,
14
+ isExposed,
15
+ rowColOf
16
+ };
@@ -0,0 +1,14 @@
1
+ import { Card, GameController } from './index.mjs';
2
+
3
+ interface ScorpionState {
4
+ /** 7 tableau columns. Columns 0-3 start 3 face-down + 4 face-up; columns 4-6 start all face-up
5
+ * (7 or 8 cards each, depending on the assisted-stock variant - see this file's header comment). */
6
+ tableau: Card[][];
7
+ /** The assisted variant's one-shot held-back stock: 3 cards, or empty (classic variant, or
8
+ * already dealt out - see drawStock). */
9
+ stock: Card[];
10
+ }
11
+ declare function createScorpionController(assistedStock: boolean): GameController<ScorpionState>;
12
+
13
+ export { createScorpionController };
14
+ export type { ScorpionState };
@@ -0,0 +1,14 @@
1
+ import { Card, GameController } from './index.js';
2
+
3
+ interface ScorpionState {
4
+ /** 7 tableau columns. Columns 0-3 start 3 face-down + 4 face-up; columns 4-6 start all face-up
5
+ * (7 or 8 cards each, depending on the assisted-stock variant - see this file's header comment). */
6
+ tableau: Card[][];
7
+ /** The assisted variant's one-shot held-back stock: 3 cards, or empty (classic variant, or
8
+ * already dealt out - see drawStock). */
9
+ stock: Card[];
10
+ }
11
+ declare function createScorpionController(assistedStock: boolean): GameController<ScorpionState>;
12
+
13
+ export { createScorpionController };
14
+ export type { ScorpionState };
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkSLQ7RGMZjs = require('./chunk-SLQ7RGMZ.js');
4
+ require('./chunk-B56TRALO.js');
5
+ require('./chunk-XV5OUPIW.js');
6
+ require('./chunk-W5CPH6TD.js');
7
+
8
+
9
+ exports.createScorpionController = _chunkSLQ7RGMZjs.createScorpionController;