Reference
Gin Rummy
import { … } from "@johnmorrisdotca/toranpu/gin-rummy";
3.8 kB minified and gzipped, with everything it imports (measured with esbuild)
Gin Rummy: its rules, its computer player and its saved-game format.
Exports
| Name | Kind | What it is |
|---|---|---|
bestLayout | function | The hand laid out to leave the least deadwood: the melds chosen, none sharing a card, and what is left. |
canKnockWith | function | Whether throwing this card, from a hand of eleven, leaves little enough deadwood to knock with. |
chooseThrow | function | The card to throw: the one leaving the least deadwood; of those, not a card the other player could use, and the highest. |
deadwoodIn | function | The deadwood left in a hand at its best. |
deadwoodOf | function | What a list of cards counts as deadwood, added up. |
deadwoodValue | function | A card's deadwood: an ace one, the numbers their number, a jack, queen or king ten. |
decodeGin | function | Text read back into the game of Gin Rummy it records, by playing every move again through the rules; null for anything they cannot play out. |
encodeGin | function | A game of Gin Rummy as text: its table, its seed and its moves, never a hand. |
GIN_BONUS | constant | The bonus for gin, and for an undercut. |
GIN_RUMMY_RULES | constant | Gin Rummy as one CardGameRules: everything a table asks of the game. |
GIN_SEATS | constant | How many play Gin Rummy: two. |
ginComputer | function | The move a computer in the seat to play makes: always one the rules allow. |
GinGame | type | A GAME OF GIN RUMMY: its table and moves (what is kept), and the hand they have reached. |
GinLayout | type | Each hand's player, laid out: their melds, and the cards left over. |
GinMeld | type | A meld: three or four of a rank, or a run of three or more in one suit. |
GinMove | type | A card drawn from the stock or taken from the discard pile, or a card thrown: laid on the pile, or face down to knock. |
ginMoves | function | Every move the seat to play may make now; none once the game is over. |
GinResult | type | How a hand ended: who scored and how much, and how each hand was laid down. |
ginSensible | function | 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. |
ginView | function | The part of the game the seat to play can see, which is all its computer is given. |
GinView | type | 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. |
ginWinners | function | The first to the game's total wins. |
isMeld | function | Whether these cards are a meld: three or four of a rank, or three or more in a row in one suit. |
KNOCK_MOST | constant | The most deadwood a player may knock with. |
layOff | function | The defender's side of a knock: their own melds first, then every card left that fits one of the knocker's melds laid off onto it — a run grown one card at a time, so a six can follow the five just laid. |
meldsIn | function | Every meld that can be made from these cards: each set of three or four, and each run of three or more. |
playGin | function | The game after that move, with the move added to its record, or null for a move the rules refuse. |
sortGin | function | A hand sorted as a player holds it: by suit (spades, hearts, clubs, diamonds, as the colours alternate), ace low. |
startGin | function | A new game of Gin Rummy for these players (one name a seat) at this size, dealt from the seed dealt, or null for a table Gin Rummy is not offered for. |
UNDERCUT_BONUS | constant | The bonus for an undercut: the defender has no more deadwood than the knocker. |
wanted | function | Whether the discard would go straight into a meld: the hand with it and its best throw has less deadwood than now. |