本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス · ジンラミー

GinView型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 type { GinView } from "@johnmorrisdotca/toranpu/gin-rummy";

定義

type GinView = {
    hand: readonly CardId[];
    phase: GinGame["phase"];
    top: CardId | null;
    taken: CardId | null;
    theirPicks: readonly CardId[];
};

メンバー

名前型説明
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.

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/toranpu 2.15.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。