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 · Cribbage

CribbageViewtype

A COMPUTER AT THE CRIBBAGE TABLE. Laying away, it tries every two cards it could throw and keeps the four whose show is worth most on average over every starter it might be cut, adding what the two thrown are worth to its own crib or taking it off the other player's. Pegging, it takes the most points a card can make now, and otherwise keeps the count off five and twenty-one (a ten makes fifteen or thirty-one of them), leads low, and never leads a five.

It reads a view of the game (cribbageView): its own hand and what is on the table — nothing of the other hand, the crib, or the card to be cut.

Import it

import type { CribbageView } from "@johnmorrisdotca/toranpu/cribbage";

Definition

type CribbageView = {
    seat: number;
    dealer: number;
    phase: CribbageGame["phase"];
    hand: readonly CardId[];
    count: number;
    run: readonly CardId[];
};

Members

NameTypeDescription
seatnumber
dealernumber
phaseCribbagePhase
handreadonly string[]
countnumber
runreadonly string[]

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { CribbageView } from "@johnmorrisdotca/toranpu/cribbage";
import { cribbageView } from "@johnmorrisdotca/toranpu/cribbage";

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

What it prints (run when this page was built)

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