@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/golf.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import {
2
+ createGolfController
3
+ } from "./chunk-IKLYXDG7.mjs";
4
+ import "./chunk-XSS5M6C7.mjs";
5
+ export {
6
+ createGolfController
7
+ };
@@ -0,0 +1,176 @@
1
+ export { A as AutoCompleteStep, F as FinishMove, f as findSafeAutoPlay, i as isFullyAutoCompletable, a as isFullyAutoCompletableWithDraws, b as isSafeAutoPlay, n as nextAutoCompleteMove, c as nextAutoCompleteMoveWithDraws } from './autoFoundation-Ctp9LKa-.mjs';
2
+ import { C as Card, S as Suit, M as Move, a as ProgressSpec, b as SearchOutcome, G as GameController, P as PileRef } from './gameTypes-BnfLkwzA.mjs';
3
+ export { A as AccessibleCard, c as Color, H as HINT_SEARCH_BUDGET, d as HINT_SEARCH_MAX_MS, L as LOOKAHEAD_BUDGET, e as LOOKAHEAD_MAX_MS, f as ProgressSearch, R as Rank, g as SUITS, h as SearchMode, i as SearchStep, j as allDestinations, k as cardColor, l as columnsKey, m as faceDownCount, n as foundationDownMoves, o as isConclusive, p as pileKey } from './gameTypes-BnfLkwzA.mjs';
4
+
5
+ /** A tableau pile under consideration as an auto-move destination. */
6
+ interface TableauCandidate {
7
+ index: number;
8
+ pile: Card[];
9
+ }
10
+ /**
11
+ * Pick the best of several already-legal tableau destinations: fewest buried cards first, then
12
+ * the largest pile, then leftmost (lowest index) to break any remaining tie. `candidates` must be
13
+ * given in ascending index order - on an exact tie we keep whichever was found first, which is
14
+ * how "leftmost" falls out without a separate comparison.
15
+ *
16
+ * An empty pile is a strict last resort: it always scores 0 buried (there's nothing there to
17
+ * bury), which would otherwise let it beat a non-empty pile that legally accepts the card but
18
+ * buries one - even though building onto an existing, visible stack is usually what a player
19
+ * actually wants. So non-empty candidates are considered first, and an empty pile is only picked
20
+ * when no non-empty candidate is legal at all.
21
+ */
22
+ declare function pickBestTableauTarget<T extends TableauCandidate>(candidates: T[], isValidRun: (cards: Card[]) => boolean): T | null;
23
+
24
+ /** One standard 52-card deck, all face down. `deckIndex` keeps ids unique across multi-deck games. */
25
+ declare function makeDeck(deckIndex?: number): Card[];
26
+ /**
27
+ * A shuffled deck for a given game `seed`, using `numDecks` standard decks
28
+ * (Spider uses 2). Pass `suitFilter` to restrict to a subset of suits, then
29
+ * the result is duplicated up to `numDecks` copies of that filtered set
30
+ * (used by 1-suit / 2-suit Spider).
31
+ */
32
+ declare function shuffledDeck(seed: number, numDecks?: number, suitFilter?: Card['suit'][]): Card[];
33
+
34
+ /** The suit each foundation slot is locked to, left to right: new deck order (and the app icon's), so the colors
35
+ * alternate. Deliberately NOT the deck's own SUITS order (clubs, diamonds, hearts, spades), which builds every deck:
36
+ * changing that would change every seeded deal. Saves from before this order are remapped as they load
37
+ * (stores/gameInProgress.ts's remapLegacyFoundations). */
38
+ declare const FOUNDATION_SUITS: readonly Suit[];
39
+ /** The stamp every saved game carries (SavedGame's foundationLayout) once its foundation slots follow FOUNDATION_SUITS. A
40
+ * save without it was made while the slots followed the deck's SUITS order. */
41
+ declare const FOUNDATION_LAYOUT = 1;
42
+ declare function canPlaceOnFoundation(dest: Card[], moving: Card): boolean;
43
+ declare function suitIndex(suit: Suit): number;
44
+
45
+ /** A 'move' hint carries `choices`: how many moves Hint cycles through on this board (`skip` wraps at it), so a held Hint
46
+ * button knows whether there's a next one to show (see components/hintHold.ts). */
47
+ type HintResult = {
48
+ kind: 'move';
49
+ move: Move;
50
+ choices: number;
51
+ } | {
52
+ kind: 'drawStock';
53
+ } | {
54
+ kind: 'none';
55
+ };
56
+ /**
57
+ * How many of this pile's own top cards a screen should ring for the current hint: the source pile
58
+ * rings the run being suggested (`move.count`), every other pile nothing. The destination is shown
59
+ * by the hint's glide (games/shared/useHintGlide.ts), not a second ring, so the ring only ever
60
+ * marks what to pick up. 0 when there's no active move-shaped hint (a `kind: 'drawStock'`/`'none'`
61
+ * hint has no `move` to match against - see each screen's own stock-pile highlighting instead).
62
+ */
63
+ declare function hintCountFor(hint: HintResult | null, ref: PileRef): number;
64
+ /**
65
+ * The move (or draw) the Hint button suggests. A game that says what progress is gets the look-ahead's answer (searchedHint
66
+ * below); any other game, or a board the look-ahead ran out of room on, the scored hint (scoredHint).
67
+ *
68
+ * `skip` cycles through the suggestions - each screen bumps it by one on a repeated Hint press against an unchanged board
69
+ * (see e.g. KlondikeScreen's own handleHint), wrapping back to the start once every one has been shown; a move hint's
70
+ * `choices` says how many there are. Holding the Hint button steps through the same cycle (see components/hintHold.ts).
71
+ */
72
+ declare function findHint<TState>(controller: Pick<GameController<TState>, 'legalMoves' | 'drawStock' | 'scoreHintMove'> & Partial<Pick<GameController<TState>, 'tryMove' | 'progress'>>, state: TState, skip?: number): HintResult;
73
+ declare function cachedSearchOutcome<TState>(spec: ProgressSpec<TState>, state: TState): SearchOutcome | undefined;
74
+ declare function cacheSearchOutcome<TState>(spec: ProgressSpec<TState>, state: TState, outcome: SearchOutcome): void;
75
+ /** The look-ahead's outcome for this board (engine/progressSearch.ts): the background's if it has one, else a short one of
76
+ * its own (HINT_SEARCH_BUDGET, HINT_SEARCH_MAX_MS). */
77
+ declare function hintSearchOutcome<TState>(controller: Pick<GameController<TState>, 'tryMove'> & Partial<Pick<GameController<TState>, 'drawStock' | 'scoreHintMove' | 'progress'>>, state: TState): SearchOutcome | null;
78
+
79
+ declare function top<T>(pile: T[]): T | undefined;
80
+ declare function isEmpty<T>(pile: T[]): boolean;
81
+ /** True if `cards` (top-to-bottom order not assumed - checked as dealt order, ascending index = deeper in pile)
82
+ * form a valid descending, alternating-color run, e.g. black-8, red-7, black-6 (used by Klondike/FreeCell). */
83
+ declare function isDescendingAltColor(cards: Card[]): boolean;
84
+ /** True if `cards` form a valid descending same-suit run (used by Spider completed-sequence detection). */
85
+ declare function isDescendingSameSuit(cards: Card[]): boolean;
86
+ /** True if `cards` form a descending run regardless of suit/color (used by Spider's "movable sequence" rule,
87
+ * which is looser than the "completed set" rule above). */
88
+ declare function isDescendingAnySuit(cards: Card[]): boolean;
89
+ /** Always true - the `isValidRun` predicate Yukon passes to buriedCount/runCountFrom/
90
+ * pickBestTableauTarget. Unlike Klondike/FreeCell (isDescendingAltColor) or Spider
91
+ * (isDescendingSameSuit), Yukon has no run-validity requirement at all: any face-up card, plus
92
+ * everything stacked above it, is always a legal group to move together. */
93
+ declare function alwaysValidRun(): boolean;
94
+ /**
95
+ * How many cards in `pile` sit below its current movable top run - i.e. aren't reachable as a
96
+ * single unit right now, whether because they're face-down (Klondike/Spider) or face-up but not
97
+ * part of a well-formed run continuing from the top (FreeCell/Spider, where cards can be visible
98
+ * yet still buried under an unrelated run). `isValidRun` is the game's own run-validity check
99
+ * (`isDescendingAltColor` for Klondike/FreeCell, `isDescendingSameSuit` for Spider). Used to rank
100
+ * candidate auto-move destinations: a pile that buries fewer cards is the "less committed" choice.
101
+ */
102
+ declare function buriedCount(pile: Card[], isValidRun: (cards: Card[]) => boolean): number;
103
+ /** True if the top `indexFromTop + 1` cards of `pile` are all face-up and (when more than one)
104
+ * form a valid run per `isValidRun` - i.e. legally draggable as one unit starting at that depth.
105
+ * Returns that run length if so, 0 otherwise. Shared by Klondike/FreeCell (isValidRun =
106
+ * isDescendingAltColor) and Spider (isValidRun = isDescendingSameSuit) for their drag-config
107
+ * getRunCount callbacks - Pyramid has no multi-card tableau runs, so N/A there. The face-up check
108
+ * is a no-op for FreeCell (whose whole tableau is always face-up), but must stay unconditional:
109
+ * Klondike has genuine face-down cards, and a run dipping into one is never draggable. */
110
+ declare function runCountFrom(pile: Card[], indexFromTop: number, isValidRun: (cards: Card[]) => boolean): number;
111
+
112
+ type RandomFn = () => number;
113
+ /** mulberry32 - small, fast, good-enough PRNG for shuffling. */
114
+ declare function mulberry32(seed: number): RandomFn;
115
+ /** Fisher-Yates shuffle using an injected RNG (never mutates the input array). */
116
+ declare function shuffle<T>(items: T[], rng: RandomFn): T[];
117
+ /** A fresh, non-reproducible seed for "New Game" (not for use inside tests). */
118
+ declare function randomSeed(): number;
119
+
120
+ declare function computeScore(moves: number, elapsedSeconds: number): number;
121
+
122
+ type SolitaireGameId = 'klondike' | 'spider' | 'freecell' | 'pyramid' | 'yukon' | 'golf' | 'tripeaks' | 'canfield' | 'scorpion' | 'fortythieves' | 'acesup';
123
+ declare const SOLITAIRE_GAME_IDS: SolitaireGameId[];
124
+ type VariantId = 'klondike' | 'klondike-draw3' | 'spider' | 'spider-2suit' | 'spider-4suit' | 'freecell' | 'pyramid' | 'yukon' | 'golf' | 'golf-wrap' | 'tripeaks' | 'tripeaks-wrap' | 'canfield' | 'canfield-draw1' | 'scorpion' | 'scorpion-classic' | 'fortythieves' | 'fortythieves-runs' | 'acesup';
125
+ interface VariantInfo {
126
+ id: VariantId;
127
+ game: SolitaireGameId;
128
+ /** The rule's name as its Settings row shows it, or null for a game with only one rule set. */
129
+ label: string | null;
130
+ }
131
+ /** Every variant, grouped by game in SOLITAIRE_GAME_IDS order, each game's default first. */
132
+ declare const VARIANTS: VariantInfo[];
133
+ declare const VARIANT_IDS: VariantId[];
134
+ declare function variantInfo(id: VariantId): VariantInfo;
135
+ declare function gameOfVariant(id: VariantId): SolitaireGameId;
136
+ declare function variantsOfGame(game: SolitaireGameId): VariantId[];
137
+ declare const klondikeVariant: (draw: 1 | 3) => VariantId;
138
+ declare const spiderVariant: (suits: 1 | 2 | 4) => VariantId;
139
+ declare const canfieldVariant: (draw: 1 | 3) => VariantId;
140
+ declare const golfVariant: (rankWrap: boolean) => VariantId;
141
+ declare const tripeaksVariant: (rankWrap: boolean) => VariantId;
142
+ declare const scorpionVariant: (assistedStock: boolean) => VariantId;
143
+ declare const fortyThievesVariant: (runMoves: boolean) => VariantId;
144
+
145
+ type RunMove = [fromZone: string, fromIndex: number, toZone: string, toIndex: number, count: number];
146
+ type RunAction = RunMove | 'd' | 'u';
147
+ declare const MAX_RUN_ACTIONS = 5000;
148
+ declare const MAX_SEED: number;
149
+ declare const runMove: (move: Move) => RunMove;
150
+ declare const moveOf: (action: RunMove) => Move;
151
+ type AnyController = GameController<any>;
152
+ declare function controllerFor(variant: VariantId): AnyController;
153
+ declare const isVariantId: (value: unknown) => value is VariantId;
154
+ declare const isSeed: (value: unknown) => value is number;
155
+ declare function checkActions(input: unknown): {
156
+ ok: RunAction[];
157
+ } | {
158
+ error: string;
159
+ };
160
+ type ReplayResult = {
161
+ ok: true;
162
+ won: boolean;
163
+ moves: number;
164
+ undos: number;
165
+ state: unknown;
166
+ } | {
167
+ ok: false;
168
+ error: string;
169
+ at: number;
170
+ };
171
+ declare function replayRun(variant: unknown, seed: unknown, input: unknown): ReplayResult;
172
+
173
+ declare const RULES_VERSION = "0.1.0";
174
+
175
+ export { Card, FOUNDATION_LAYOUT, FOUNDATION_SUITS, GameController, MAX_RUN_ACTIONS, MAX_SEED, Move, PileRef, ProgressSpec, RULES_VERSION, SOLITAIRE_GAME_IDS, SearchOutcome, Suit, VARIANTS, VARIANT_IDS, alwaysValidRun, buriedCount, cacheSearchOutcome, cachedSearchOutcome, canPlaceOnFoundation, canfieldVariant, checkActions, computeScore, controllerFor, findHint, fortyThievesVariant, gameOfVariant, golfVariant, hintCountFor, hintSearchOutcome, isDescendingAltColor, isDescendingAnySuit, isDescendingSameSuit, isEmpty, isSeed, isVariantId, klondikeVariant, makeDeck, moveOf, mulberry32, pickBestTableauTarget, randomSeed, replayRun, runCountFrom, runMove, scorpionVariant, shuffle, shuffledDeck, spiderVariant, suitIndex, top, tripeaksVariant, variantInfo, variantsOfGame };
176
+ export type { HintResult, RandomFn, ReplayResult, RunAction, RunMove, SolitaireGameId, TableauCandidate, VariantId, VariantInfo };
@@ -0,0 +1,176 @@
1
+ export { A as AutoCompleteStep, F as FinishMove, f as findSafeAutoPlay, i as isFullyAutoCompletable, a as isFullyAutoCompletableWithDraws, b as isSafeAutoPlay, n as nextAutoCompleteMove, c as nextAutoCompleteMoveWithDraws } from './autoFoundation-CfnFNysj.js';
2
+ import { C as Card, S as Suit, M as Move, a as ProgressSpec, b as SearchOutcome, G as GameController, P as PileRef } from './gameTypes-BnfLkwzA.js';
3
+ export { A as AccessibleCard, c as Color, H as HINT_SEARCH_BUDGET, d as HINT_SEARCH_MAX_MS, L as LOOKAHEAD_BUDGET, e as LOOKAHEAD_MAX_MS, f as ProgressSearch, R as Rank, g as SUITS, h as SearchMode, i as SearchStep, j as allDestinations, k as cardColor, l as columnsKey, m as faceDownCount, n as foundationDownMoves, o as isConclusive, p as pileKey } from './gameTypes-BnfLkwzA.js';
4
+
5
+ /** A tableau pile under consideration as an auto-move destination. */
6
+ interface TableauCandidate {
7
+ index: number;
8
+ pile: Card[];
9
+ }
10
+ /**
11
+ * Pick the best of several already-legal tableau destinations: fewest buried cards first, then
12
+ * the largest pile, then leftmost (lowest index) to break any remaining tie. `candidates` must be
13
+ * given in ascending index order - on an exact tie we keep whichever was found first, which is
14
+ * how "leftmost" falls out without a separate comparison.
15
+ *
16
+ * An empty pile is a strict last resort: it always scores 0 buried (there's nothing there to
17
+ * bury), which would otherwise let it beat a non-empty pile that legally accepts the card but
18
+ * buries one - even though building onto an existing, visible stack is usually what a player
19
+ * actually wants. So non-empty candidates are considered first, and an empty pile is only picked
20
+ * when no non-empty candidate is legal at all.
21
+ */
22
+ declare function pickBestTableauTarget<T extends TableauCandidate>(candidates: T[], isValidRun: (cards: Card[]) => boolean): T | null;
23
+
24
+ /** One standard 52-card deck, all face down. `deckIndex` keeps ids unique across multi-deck games. */
25
+ declare function makeDeck(deckIndex?: number): Card[];
26
+ /**
27
+ * A shuffled deck for a given game `seed`, using `numDecks` standard decks
28
+ * (Spider uses 2). Pass `suitFilter` to restrict to a subset of suits, then
29
+ * the result is duplicated up to `numDecks` copies of that filtered set
30
+ * (used by 1-suit / 2-suit Spider).
31
+ */
32
+ declare function shuffledDeck(seed: number, numDecks?: number, suitFilter?: Card['suit'][]): Card[];
33
+
34
+ /** The suit each foundation slot is locked to, left to right: new deck order (and the app icon's), so the colors
35
+ * alternate. Deliberately NOT the deck's own SUITS order (clubs, diamonds, hearts, spades), which builds every deck:
36
+ * changing that would change every seeded deal. Saves from before this order are remapped as they load
37
+ * (stores/gameInProgress.ts's remapLegacyFoundations). */
38
+ declare const FOUNDATION_SUITS: readonly Suit[];
39
+ /** The stamp every saved game carries (SavedGame's foundationLayout) once its foundation slots follow FOUNDATION_SUITS. A
40
+ * save without it was made while the slots followed the deck's SUITS order. */
41
+ declare const FOUNDATION_LAYOUT = 1;
42
+ declare function canPlaceOnFoundation(dest: Card[], moving: Card): boolean;
43
+ declare function suitIndex(suit: Suit): number;
44
+
45
+ /** A 'move' hint carries `choices`: how many moves Hint cycles through on this board (`skip` wraps at it), so a held Hint
46
+ * button knows whether there's a next one to show (see components/hintHold.ts). */
47
+ type HintResult = {
48
+ kind: 'move';
49
+ move: Move;
50
+ choices: number;
51
+ } | {
52
+ kind: 'drawStock';
53
+ } | {
54
+ kind: 'none';
55
+ };
56
+ /**
57
+ * How many of this pile's own top cards a screen should ring for the current hint: the source pile
58
+ * rings the run being suggested (`move.count`), every other pile nothing. The destination is shown
59
+ * by the hint's glide (games/shared/useHintGlide.ts), not a second ring, so the ring only ever
60
+ * marks what to pick up. 0 when there's no active move-shaped hint (a `kind: 'drawStock'`/`'none'`
61
+ * hint has no `move` to match against - see each screen's own stock-pile highlighting instead).
62
+ */
63
+ declare function hintCountFor(hint: HintResult | null, ref: PileRef): number;
64
+ /**
65
+ * The move (or draw) the Hint button suggests. A game that says what progress is gets the look-ahead's answer (searchedHint
66
+ * below); any other game, or a board the look-ahead ran out of room on, the scored hint (scoredHint).
67
+ *
68
+ * `skip` cycles through the suggestions - each screen bumps it by one on a repeated Hint press against an unchanged board
69
+ * (see e.g. KlondikeScreen's own handleHint), wrapping back to the start once every one has been shown; a move hint's
70
+ * `choices` says how many there are. Holding the Hint button steps through the same cycle (see components/hintHold.ts).
71
+ */
72
+ declare function findHint<TState>(controller: Pick<GameController<TState>, 'legalMoves' | 'drawStock' | 'scoreHintMove'> & Partial<Pick<GameController<TState>, 'tryMove' | 'progress'>>, state: TState, skip?: number): HintResult;
73
+ declare function cachedSearchOutcome<TState>(spec: ProgressSpec<TState>, state: TState): SearchOutcome | undefined;
74
+ declare function cacheSearchOutcome<TState>(spec: ProgressSpec<TState>, state: TState, outcome: SearchOutcome): void;
75
+ /** The look-ahead's outcome for this board (engine/progressSearch.ts): the background's if it has one, else a short one of
76
+ * its own (HINT_SEARCH_BUDGET, HINT_SEARCH_MAX_MS). */
77
+ declare function hintSearchOutcome<TState>(controller: Pick<GameController<TState>, 'tryMove'> & Partial<Pick<GameController<TState>, 'drawStock' | 'scoreHintMove' | 'progress'>>, state: TState): SearchOutcome | null;
78
+
79
+ declare function top<T>(pile: T[]): T | undefined;
80
+ declare function isEmpty<T>(pile: T[]): boolean;
81
+ /** True if `cards` (top-to-bottom order not assumed - checked as dealt order, ascending index = deeper in pile)
82
+ * form a valid descending, alternating-color run, e.g. black-8, red-7, black-6 (used by Klondike/FreeCell). */
83
+ declare function isDescendingAltColor(cards: Card[]): boolean;
84
+ /** True if `cards` form a valid descending same-suit run (used by Spider completed-sequence detection). */
85
+ declare function isDescendingSameSuit(cards: Card[]): boolean;
86
+ /** True if `cards` form a descending run regardless of suit/color (used by Spider's "movable sequence" rule,
87
+ * which is looser than the "completed set" rule above). */
88
+ declare function isDescendingAnySuit(cards: Card[]): boolean;
89
+ /** Always true - the `isValidRun` predicate Yukon passes to buriedCount/runCountFrom/
90
+ * pickBestTableauTarget. Unlike Klondike/FreeCell (isDescendingAltColor) or Spider
91
+ * (isDescendingSameSuit), Yukon has no run-validity requirement at all: any face-up card, plus
92
+ * everything stacked above it, is always a legal group to move together. */
93
+ declare function alwaysValidRun(): boolean;
94
+ /**
95
+ * How many cards in `pile` sit below its current movable top run - i.e. aren't reachable as a
96
+ * single unit right now, whether because they're face-down (Klondike/Spider) or face-up but not
97
+ * part of a well-formed run continuing from the top (FreeCell/Spider, where cards can be visible
98
+ * yet still buried under an unrelated run). `isValidRun` is the game's own run-validity check
99
+ * (`isDescendingAltColor` for Klondike/FreeCell, `isDescendingSameSuit` for Spider). Used to rank
100
+ * candidate auto-move destinations: a pile that buries fewer cards is the "less committed" choice.
101
+ */
102
+ declare function buriedCount(pile: Card[], isValidRun: (cards: Card[]) => boolean): number;
103
+ /** True if the top `indexFromTop + 1` cards of `pile` are all face-up and (when more than one)
104
+ * form a valid run per `isValidRun` - i.e. legally draggable as one unit starting at that depth.
105
+ * Returns that run length if so, 0 otherwise. Shared by Klondike/FreeCell (isValidRun =
106
+ * isDescendingAltColor) and Spider (isValidRun = isDescendingSameSuit) for their drag-config
107
+ * getRunCount callbacks - Pyramid has no multi-card tableau runs, so N/A there. The face-up check
108
+ * is a no-op for FreeCell (whose whole tableau is always face-up), but must stay unconditional:
109
+ * Klondike has genuine face-down cards, and a run dipping into one is never draggable. */
110
+ declare function runCountFrom(pile: Card[], indexFromTop: number, isValidRun: (cards: Card[]) => boolean): number;
111
+
112
+ type RandomFn = () => number;
113
+ /** mulberry32 - small, fast, good-enough PRNG for shuffling. */
114
+ declare function mulberry32(seed: number): RandomFn;
115
+ /** Fisher-Yates shuffle using an injected RNG (never mutates the input array). */
116
+ declare function shuffle<T>(items: T[], rng: RandomFn): T[];
117
+ /** A fresh, non-reproducible seed for "New Game" (not for use inside tests). */
118
+ declare function randomSeed(): number;
119
+
120
+ declare function computeScore(moves: number, elapsedSeconds: number): number;
121
+
122
+ type SolitaireGameId = 'klondike' | 'spider' | 'freecell' | 'pyramid' | 'yukon' | 'golf' | 'tripeaks' | 'canfield' | 'scorpion' | 'fortythieves' | 'acesup';
123
+ declare const SOLITAIRE_GAME_IDS: SolitaireGameId[];
124
+ type VariantId = 'klondike' | 'klondike-draw3' | 'spider' | 'spider-2suit' | 'spider-4suit' | 'freecell' | 'pyramid' | 'yukon' | 'golf' | 'golf-wrap' | 'tripeaks' | 'tripeaks-wrap' | 'canfield' | 'canfield-draw1' | 'scorpion' | 'scorpion-classic' | 'fortythieves' | 'fortythieves-runs' | 'acesup';
125
+ interface VariantInfo {
126
+ id: VariantId;
127
+ game: SolitaireGameId;
128
+ /** The rule's name as its Settings row shows it, or null for a game with only one rule set. */
129
+ label: string | null;
130
+ }
131
+ /** Every variant, grouped by game in SOLITAIRE_GAME_IDS order, each game's default first. */
132
+ declare const VARIANTS: VariantInfo[];
133
+ declare const VARIANT_IDS: VariantId[];
134
+ declare function variantInfo(id: VariantId): VariantInfo;
135
+ declare function gameOfVariant(id: VariantId): SolitaireGameId;
136
+ declare function variantsOfGame(game: SolitaireGameId): VariantId[];
137
+ declare const klondikeVariant: (draw: 1 | 3) => VariantId;
138
+ declare const spiderVariant: (suits: 1 | 2 | 4) => VariantId;
139
+ declare const canfieldVariant: (draw: 1 | 3) => VariantId;
140
+ declare const golfVariant: (rankWrap: boolean) => VariantId;
141
+ declare const tripeaksVariant: (rankWrap: boolean) => VariantId;
142
+ declare const scorpionVariant: (assistedStock: boolean) => VariantId;
143
+ declare const fortyThievesVariant: (runMoves: boolean) => VariantId;
144
+
145
+ type RunMove = [fromZone: string, fromIndex: number, toZone: string, toIndex: number, count: number];
146
+ type RunAction = RunMove | 'd' | 'u';
147
+ declare const MAX_RUN_ACTIONS = 5000;
148
+ declare const MAX_SEED: number;
149
+ declare const runMove: (move: Move) => RunMove;
150
+ declare const moveOf: (action: RunMove) => Move;
151
+ type AnyController = GameController<any>;
152
+ declare function controllerFor(variant: VariantId): AnyController;
153
+ declare const isVariantId: (value: unknown) => value is VariantId;
154
+ declare const isSeed: (value: unknown) => value is number;
155
+ declare function checkActions(input: unknown): {
156
+ ok: RunAction[];
157
+ } | {
158
+ error: string;
159
+ };
160
+ type ReplayResult = {
161
+ ok: true;
162
+ won: boolean;
163
+ moves: number;
164
+ undos: number;
165
+ state: unknown;
166
+ } | {
167
+ ok: false;
168
+ error: string;
169
+ at: number;
170
+ };
171
+ declare function replayRun(variant: unknown, seed: unknown, input: unknown): ReplayResult;
172
+
173
+ declare const RULES_VERSION = "0.1.0";
174
+
175
+ export { Card, FOUNDATION_LAYOUT, FOUNDATION_SUITS, GameController, MAX_RUN_ACTIONS, MAX_SEED, Move, PileRef, ProgressSpec, RULES_VERSION, SOLITAIRE_GAME_IDS, SearchOutcome, Suit, VARIANTS, VARIANT_IDS, alwaysValidRun, buriedCount, cacheSearchOutcome, cachedSearchOutcome, canPlaceOnFoundation, canfieldVariant, checkActions, computeScore, controllerFor, findHint, fortyThievesVariant, gameOfVariant, golfVariant, hintCountFor, hintSearchOutcome, isDescendingAltColor, isDescendingAnySuit, isDescendingSameSuit, isEmpty, isSeed, isVariantId, klondikeVariant, makeDeck, moveOf, mulberry32, pickBestTableauTarget, randomSeed, replayRun, runCountFrom, runMove, scorpionVariant, shuffle, shuffledDeck, spiderVariant, suitIndex, top, tripeaksVariant, variantInfo, variantsOfGame };
176
+ export type { HintResult, RandomFn, ReplayResult, RunAction, RunMove, SolitaireGameId, TableauCandidate, VariantId, VariantInfo };