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

bestLayoutfunction

The hand laid out to leave the least deadwood: the melds chosen, none sharing a card, and what is left. Searched exhaustively over the cards as a bitmask, which for eleven cards at most is quick.

Import it

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

Definition

function bestLayout(hand: readonly CardId[]): GinLayout

Parameters

NameTypeDescription
handreadonly string[]

The player’s held cards, or the hand number for a deal.

Returns

GinLayout

The hand laid out to leave the least deadwood: the melds chosen, none sharing a card, and what is left. Searched exhaustively over the cards as a bitmask, which for eleven cards at most is quick.

Examples

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

console.log(bestLayout(["3H", "4H", "5H", "AS"]));
{ melds: [ [ '3H', '4H', '5H' ] ], deadwood: [ 'AS' ] }

What it prints (run when this page was built)

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