import type { CardId } from "../card-games.types.ts"; import type { SpadesGame, SpadesMove, SpadesPlay } from "./spades.types.ts"; /** * A COMPUTER AT THE SPADES TABLE, bidding and playing as a steady partner: * it bids the tricks its hand is worth — aces, guarded kings, long and high * spades, the short suits it can trump — and nil only with a hand of nothing. * Playing, it takes the tricks its partnership still needs as cheaply as it * can, leaves a trick its partner is winning alone, ducks once the contract * is made (every overtrick is a bag), keeps out of the tricks when it bid nil, * and covers its partner's nil. * * It reads a view of the game (`spadesView`) holding its own hand, the bids * 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, every bid, the tricks taken and the cards played. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import type { SpadesView } from "@johnmorrisdotca/toranpu/spades"; * import { spadesView } from "@johnmorrisdotca/toranpu/spades"; * * const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * const game = newGame("spades", { players: names, seed: 42 })!; * const value: SpadesView = spadesView(game); * console.log(value.hand.length); * ``` */ export type SpadesView = { seat: number; hand: readonly CardId[]; phase: SpadesGame["phase"]; bids: readonly (number | null)[]; tricks: readonly number[]; trick: readonly SpadesPlay[]; /** 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 { spadesView } from "@johnmorrisdotca/toranpu/spades"; * * const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("spades", { players: names, seed: 42 })!; * console.log(spadesView(game)); * ``` */ export declare function spadesView(game: SpadesGame): SpadesView; /** 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 { spadesComputer } from "@johnmorrisdotca/toranpu/spades"; * * const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("spades", { players: names, seed: 42 })!; * console.log(spadesComputer(game)); * ``` */ export declare function spadesComputer(game: SpadesGame): SpadesMove; /** The tricks a hand is worth, counted as a card player counts them before bidding. * * @param hand - The player’s held cards, or the hand number for a deal. * @returns The tricks a hand is worth, counted as a card player counts them before bidding. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { handWorth } from "@johnmorrisdotca/toranpu/spades"; * * const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("spades", { players: names, seed: 42 })!; * console.log(handWorth(game.hands[0]!)); * ``` */ export declare function handWorth(hand: readonly CardId[]): number; /** Nil for a hand of nothing (and never beside a partner's nil); otherwise what the hand is worth, at least one. * * @param hand - The player’s held cards, or the hand number for a deal. * @param partnerBid - The partner’s bid. * @returns Nil for a hand of nothing (and never beside a partner's nil); otherwise what the hand is worth, at least one. * * @example * ```ts * import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu"; * import { chooseBid } from "@johnmorrisdotca/toranpu/spades"; * * const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`); * let game = newGame("spades", { players: names, seed: 42 })!; * console.log(chooseBid(game.hands[0]!, 3)); * ``` */ export declare function chooseBid(hand: readonly CardId[], partnerBid: number | null): number;