GinViewtype
A COMPUTER AT THE GIN RUMMY TABLE: it takes the discard only when the card goes straight into a meld, throws the card that leaves the least deadwood (the highest of those that tie, and never one the other player has shown they are collecting when another will do), and knocks the moment it can.
It reads a view of the game (ginView): its own hand, the discard pile and
what the other player took from it — and nothing of their hand or the stock.
Import it
import type { GinView } from "@johnmorrisdotca/toranpu/gin-rummy";
Definition
type GinView = {
hand: readonly CardId[];
phase: GinGame["phase"];
top: CardId | null;
taken: CardId | null;
theirPicks: readonly CardId[];
};
Members
| Name | Type | Description |
|---|---|---|
hand | readonly string[] | |
phase | "over" | "discard" | "draw" | |
top | string | null | The card on top of the discard pile, if any. |
taken | string | null | The card just taken from the pile, which may not go straight back. |
theirPicks | readonly string[] | Every card the other player has taken from the discard pile this hand and still holds: the table watched them take it. |
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { GinView } from "@johnmorrisdotca/toranpu/gin-rummy";
import { ginView } from "@johnmorrisdotca/toranpu/gin-rummy";
const names = Array.from({ length: CARD_GAME_TABLES.ginRummy.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("ginRummy", { players: names, seed: 42 })!;
const value: GinView = ginView(game);
console.log(value.hand.length);10What it prints (run when this page was built)