import type { CardId } from "../card-games.types.ts"; import type { HeartsGame, HeartsMove, HeartsPlay } from "./hearts.types.ts"; /** * A COMPUTER AT THE HEARTS TABLE, playing as a careful player does: pass the * queen of spades and the high cards that would catch her, and a short suit * so it can be thrown away; duck under a trick when it can, dump the queen on * somebody else the moment it is safe, and never lead a heart for nothing. * It does not try to shoot the moon. * * It reads a view of the game (`heartsView`) holding its own hand and what * the whole table has seen, and nothing else: it cannot look at a hand it is * not holding. */ /** What the seat to move can see: its own hand and the table. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import type { HeartsView } from "@johnmorrisdotca/toranpu/hearts"; * import { heartsView } from "@johnmorrisdotca/toranpu/hearts"; * * const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * const game = newGame("hearts", { players: names, seed: 42 })!; * const value: HeartsView = heartsView(game); * console.log(value.hand.length); * ``` */ export type HeartsView = { seat: number; seats: number; hand: readonly CardId[]; phase: HeartsGame["phase"]; trick: readonly HeartsPlay[]; /** Every card already played this deal, finished tricks and the one on the table. */ seen: ReadonlySet; playable: readonly CardId[]; }; /** 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 { heartsView } from "@johnmorrisdotca/toranpu/hearts"; * * const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("hearts", { players: names, seed: 42 })!; * console.log(heartsView(game)); * ``` */ export declare function heartsView(game: HeartsGame): HeartsView; /** 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 { heartsComputer } from "@johnmorrisdotca/toranpu/hearts"; * * const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("hearts", { players: names, seed: 42 })!; * console.log(heartsComputer(game)); * ``` */ export declare function heartsComputer(game: HeartsGame): HeartsMove; /** The three cards a computer passes from a hand of Hearts: the queen of spades and the high spades that catch her, high hearts, and cards from a short suit. * * @param hand - The player’s held cards, or the hand number for a deal. * @returns The three cards a computer passes from a hand of Hearts: the queen of spades and the high spades that catch her, high hearts, and cards from a short suit. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { choosePass } from "@johnmorrisdotca/toranpu/hearts"; * * const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("hearts", { players: names, seed: 42 })!; * console.log(choosePass(game.hands[0]!)); * ``` */ export declare function choosePass(hand: readonly CardId[]): CardId[];