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
| Name | Type | Description |
|---|---|---|
seat | number | |
dealer | number | |
phase | CribbagePhase | |
hand | readonly string[] | |
count | number | |
run | readonly 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);6What it prints (run when this page was built)