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

ginSensiblefunction

A player a test can play at random who still ends a hand: a random draw and a random throw, but a knock whenever the card thrown allows one. A player choosing every move uniformly would almost never knock, and hand after hand would run the stock down to a draw with nobody scoring.

Import it

import { ginSensible } from "@johnmorrisdotca/toranpu/gin-rummy";

Definition

function ginSensible(game: GinGame, random: () => number): GinMove

Parameters

NameTypeDescription
gameGinGame

The current native game; applying a move returns a new state.

random() => number

A source of numbers in [0, 1), such as seededRandom(seed).

Returns

GinMove

A player a test can play at random who still ends a hand: a random draw and a random throw, but a knock whenever the card thrown allows one. A player choosing every move uniformly would almost never knock, and hand after hand would run the stock down to a draw with nobody scoring.

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { ginSensible } from "@johnmorrisdotca/toranpu/gin-rummy";
import { seededRandom } from "@johnmorrisdotca/toranpu/deck";

const names = Array.from({ length: CARD_GAME_TABLES.ginRummy.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("ginRummy", { players: names, seed: 42 })!;
console.log(ginSensible(game, seededRandom(42)));
{ draw: 'discard' }

What it prints (run when this page was built)

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