import type { CardId, CardRank } from "../card-games.types.ts"; import type { GoFishEvent, GoFishGame, GoFishMove } from "./go-fish.types.ts"; /** * A COMPUTER AT THE GO FISH TABLE, which remembers what was asked. * * Everything said at the table is in the game's log, and the computer reads * it the way a player with a good memory would: a player who asked for sevens * holds a seven; a player who handed over their sevens, or said "Go fish" to * a request for sevens, holds none — until they draw from the pond, when * anything may have come in; and a rank booked is gone for good. It asks * whoever it knows holds a rank it has, the rank it holds most of first, and * otherwise the rank it holds most of from the player with the most cards who * is not known to be without it. It never looks at a hand it is not holding. */ /** What one seat can see of a game of Go Fish: its own hand, the table, and what has been said and shown. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import type { GoFishView } from "@johnmorrisdotca/toranpu/go-fish"; * import { goFishView } from "@johnmorrisdotca/toranpu/go-fish"; * * const names = Array.from({ length: CARD_GAME_TABLES.goFish.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * const game = newGame("goFish", { players: names, seed: 42 })!; * const value: GoFishView = goFishView(game); * console.log(value.hand.length); * ``` */ export type GoFishView = { seat: number; hand: readonly CardId[]; targets: readonly number[]; ranks: readonly CardRank[]; counts: readonly number[]; log: readonly GoFishEvent[]; }; /** The part of the game the seat to play can see, which is all its computer is given. * * @param game - The current native game; applying a move returns a new state. * @returns The part of the game the seat to play can see, which is all its computer is given. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { goFishView } from "@johnmorrisdotca/toranpu/go-fish"; * * const names = Array.from({ length: CARD_GAME_TABLES.goFish.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("goFish", { players: names, seed: 42 })!; * console.log(goFishView(game)); * ``` */ export declare function goFishView(game: GoFishGame): GoFishView; /** What the table has said about each seat's hand: for each seat, the ranks it is known to hold and known to be without. * * @example * ```ts * import type { GoFishMemory } from "@johnmorrisdotca/toranpu/go-fish"; * import { goFishMemory } from "@johnmorrisdotca/toranpu/go-fish"; * * const value: GoFishMemory = goFishMemory([], 4); * console.log(value.holds.length); * ``` */ export type GoFishMemory = { holds: Set[]; lacks: Set[]; }; /** What the table's log says about every seat's hand, worked out from the asks, the answers and the books. * * @param log - The recorded moves to replay or format. * @param seats - The seat count or seat state supplied by this API. * @returns What the table's log says about every seat's hand, worked out from the asks, the answers and the books. * * @example * ```ts * import { goFishMemory } from "@johnmorrisdotca/toranpu/go-fish"; * * console.log(goFishMemory([], 4)); * ``` */ export declare function goFishMemory(log: readonly GoFishEvent[], seats: number): GoFishMemory; /** The move a computer in the seat to play makes: always one the rules allow. * * @param game - The current native game; applying a move returns a new state. * @returns The move a computer in the seat to play makes: always one the rules allow. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { goFishComputer } from "@johnmorrisdotca/toranpu/go-fish"; * * const names = Array.from({ length: CARD_GAME_TABLES.goFish.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("goFish", { players: names, seed: 42 })!; * console.log(goFishComputer(game)); * ``` */ export declare function goFishComputer(game: GoFishGame): GoFishMove;