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
| Name | Type | Description |
|---|---|---|
seat | number | |
dealer | number | |
hand | readonly string[] | |
phase | EuchrePhase | |
upcard | string | |
trump | CardSuit | null | |
maker | number | null | |
trick | readonly EuchrePlay[] | |
tricks | readonly number[] | |
seen | ReadonlySet<string> | |
playable | readonly 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);5What it prints (run when this page was built)