import type { KlondikeMove, KlondikeTable } from "./klondike.types.ts"; /** * A KLONDIKE SOLVER, in the browser: it finds a winning line for a deal, or * gives up after a fixed number of tables, never after a fixed time — so the * same deal gets the same answer on a phone, a desk and the server, and a seed * that was winnable yesterday is winnable today. * * Depth first, with three things that make it quick enough: * - SAFE MOVES ARE MADE AT ONCE, without branching: a card goes home when no * card left on the table could ever want to be put on it (both foundations * of the other colour are within one of it), or it is an Ace or a Two. * - TABLES ARE SEEN ONCE: every table is remembered by what matters — the * foundations, the stock and waste, the passes used, and the columns in any * order, since two tables whose columns are the same seven in another order * are the same game. * - THE LIKELY MOVES ARE TRIED FIRST: home, then a move that turns a card over * (the column with most still face down first), then the waste onto a * column, then a column emptied or a card freed for home, and the stock last. * * It does not try every legal move — a run moved for no reason, a foundation * card brought down without a use for it — so it can miss a win that needs * one. That makes it a finder of wins, never a judge of losses: "winnable" * here means it found the line, and it is only ever said of a deal it has. */ /** Whether a card may go home now with nothing on the table ever wanting it. */ declare function safeHome(card: number, foundation: readonly number[]): boolean; /** * A winning line from this table — every move, the safe ones home included, * that a replay of it makes — or null when none was found within `budget` * tables. `budget` is a count, never a time, so every browser agrees. * * @param start - The initial game or state before the recorded moves. * @param budget - Limits on the solver’s search work. * @returns A winning line from this table — every move, the safe ones home included, that a replay of it makes — or null when none was found within `budget` tables. `budget` is a count, never a time, so every browser agrees. * * @example * ```ts no-run * import { dealKlondike, dealOfSeed, deckOf, solveKlondike } from "@johnmorrisdotca/toranpu/klondike"; * * const table = dealKlondike(deckOf(dealOfSeed(42))!, { draw: 3, passes: 3 }); * console.log(solveKlondike(table, 100)); * ``` */ export declare function solveKlondike(start: KlondikeTable, budget?: number): { moves: KlondikeMove[] | null; tables: number; }; /** Whether a card is one the solver treats as home safely: exported for its test. * * @param card - The packed card number from 0 to 51. * @param foundation - The foundation index or state being checked. * @returns Whether a card is one the solver treats as home safely: exported for its test. * * @example * ```ts * import { isSafeHome } from "@johnmorrisdotca/toranpu/klondike"; * * console.log(isSafeHome(0, [0, 0, 0, 0])); * ``` */ export declare const isSafeHome: typeof safeHome; export {};