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 · Gin Rummy

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

NameTypeDescription
handreadonly string[]
phase"over" | "discard" | "draw"
topstring | null

The card on top of the discard pile, if any.

takenstring | null

The card just taken from the pile, which may not go straight back.

theirPicksreadonly 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);
10

What it prints (run when this page was built)

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