本文へ移動

Toranpuトランプ

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

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

目次

リファレンス · オーヘル

OH_HELL_RULES定数

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

Oh Hell as one CardGameRules: everything a table asks of the game.

インポート

import { OH_HELL_RULES } from "@johnmorrisdotca/toranpu/oh-hell";

定義

const OH_HELL_RULES: CardGameRules<OhHellGame, OhHellMove> = {
    start: startOhHell,
    moves: ohHellMoves,
    play: playOhHell,
    over: (game) => game.phase === "over",
    winners: ohHellWinners,
    encode: encodeOhHell,
    decode: decodeOhHell,
    toPlay: (game) => game.toPlay,
    computer: ohHellComputer,
    seats: (game) => ({ players: game.players, computers: game.computers }),
}

メンバー

名前型説明
start(size: number, players: readonly string[], _reserved?: unknown, seed?: number, computers?: readonly boolean[]) => OhHellGame | null

A new game for these players (one name a seat) at this size, or null for a table the game is not offered for. size is how long the game lasts in its own terms (CARD_GAME_TABLES). The deal is shuffled from seed, so a seed and the moves make the same game again anywhere; computers says, one a seat, which seats a computer plays. The third argument is unused and reserved: it keeps the signature of a table of games that are played in a language (a word game), so these rules sit in such a table unchanged.

moves(game: OhHellGame) => readonly OhHellMove[]

Every move the player to move may make now; none once the game is over.

play(game: OhHellGame, move: OhHellMove) => OhHellGame | null

The game after that move, or null for a move that may not be made.

over(game: OhHellGame) => boolean
winners(game: OhHellGame) => readonly number[]

On a game that is over, every seat that won: more than one for a partnership or a tie.

encode(game: OhHellGame) => string

The game as text: its table, seed and moves, never a hand (cardGameCodec).

decode(text: string | null) => OhHellGame | null

Text read back into the game it records, or null for anything these rules cannot play out again.

toPlay(game: OhHellGame) => number | null

The seat to move, or null once the game is over.

computer(game: OhHellGame) => OhHellMove

The move a computer in the seat to move makes: always one of moves(game).

seats(game: OhHellGame) => CardSeats

Who sits where, and which seats a computer plays.

sensible (省略可)((game: OhHellGame, random: () => number) => OhHellMove) | undefined

For a game a player choosing uniformly at random would almost never finish (Gin Rummy, where random play rarely knocks), a random move a sensible player might make, for tests and simulations. Always one of moves(game). Absent where random play ends by itself.

例

import { OH_HELL_RULES } from "@johnmorrisdotca/toranpu/oh-hell";
console.log(Object.keys(OH_HELL_RULES));
[
  'start',    'moves',
  'play',     'over',
  'winners',  'encode',
  'decode',   'toPlay',
  'computer', 'seats'
]

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

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

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