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
| Name | Type | Description |
|---|---|---|
hand | readonly 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)