Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Euchre

EuchreViewtype

A COMPUTER AT THE EUCHRE TABLE. Making trumps, it weighs its hand in each suit — the bowers, the trump ace and king, the aces outside and the suits it is short in — and orders up or names a suit only with a hand that should take three tricks with its partner's help, counting the turned card for its own side when it or its partner deals. Stuck as dealer, it names its best. Playing, it leads its best trump when its side made them, cashes aces, leaves a trick its partner has won alone, and takes a trick as cheaply as it can.

It reads a view of the game (euchreView): its own hand, the card turned up, the making so far and the cards played — nothing of another hand.

Import it

import type { EuchreView } from "@johnmorrisdotca/toranpu/euchre";

Definition

type EuchreView = {
    seat: number;
    dealer: number;
    hand: readonly CardId[];
    phase: EuchreGame["phase"];
    upcard: CardId;
    trump: CardSuit | null;
    maker: number | null;
    trick: readonly EuchrePlay[];
    tricks: readonly number[];
    seen: ReadonlySet<CardId>;
    playable: readonly CardId[];
};

Members

NameTypeDescription
seatnumber
dealernumber
handreadonly string[]
phaseEuchrePhase
upcardstring
trumpCardSuit | null
makernumber | null
trickreadonly EuchrePlay[]
tricksreadonly number[]
seenReadonlySet<string>
playablereadonly string[]

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { EuchreView } from "@johnmorrisdotca/toranpu/euchre";
import { euchreView } from "@johnmorrisdotca/toranpu/euchre";

const names = Array.from({ length: CARD_GAME_TABLES.euchre.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("euchre", { players: names, seed: 42 })!;
const value: EuchreView = euchreView(game);
console.log(value.hand.length);
5

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.