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

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

NameKindWhat it is
bestLayoutfunctionThe hand laid out to leave the least deadwood: the melds chosen, none sharing a card, and what is left.
canKnockWithfunctionWhether throwing this card, from a hand of eleven, leaves little enough deadwood to knock with.
chooseThrowfunctionThe card to throw: the one leaving the least deadwood; of those, not a card the other player could use, and the highest.
deadwoodInfunctionThe deadwood left in a hand at its best.
deadwoodOffunctionWhat a list of cards counts as deadwood, added up.
deadwoodValuefunctionA card's deadwood: an ace one, the numbers their number, a jack, queen or king ten.
decodeGinfunctionText 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.
encodeGinfunctionA game of Gin Rummy as text: its table, its seed and its moves, never a hand.
GIN_BONUSconstantThe bonus for gin, and for an undercut.
GIN_RUMMY_RULESconstantGin Rummy as one CardGameRules: everything a table asks of the game.
GIN_SEATSconstantHow many play Gin Rummy: two.
ginComputerfunctionThe move a computer in the seat to play makes: always one the rules allow.
GinGametypeA GAME OF GIN RUMMY: its table and moves (what is kept), and the hand they have reached.
GinLayouttypeEach hand's player, laid out: their melds, and the cards left over.
GinMeldtypeA meld: three or four of a rank, or a run of three or more in one suit.
GinMovetypeA card drawn from the stock or taken from the discard pile, or a card thrown: laid on the pile, or face down to knock.
ginMovesfunctionEvery move the seat to play may make now; none once the game is over.
GinResulttypeHow a hand ended: who scored and how much, and how each hand was laid down.
ginSensiblefunctionA 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.
ginViewfunctionThe part of the game the seat to play can see, which is all its computer is given.
GinViewtypeA 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.
ginWinnersfunctionThe first to the game's total wins.
isMeldfunctionWhether these cards are a meld: three or four of a rank, or three or more in a row in one suit.
KNOCK_MOSTconstantThe most deadwood a player may knock with.
layOfffunctionThe 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.
meldsInfunctionEvery meld that can be made from these cards: each set of three or four, and each run of three or more.
playGinfunctionThe game after that move, with the move added to its record, or null for a move the rules refuse.
sortGinfunctionA hand sorted as a player holds it: by suit (spades, hearts, clubs, diamonds, as the colours alternate), ace low.
startGinfunctionA 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_BONUSconstantThe bonus for an undercut: the defender has no more deadwood than the knocker.
wantedfunctionWhether the discard would go straight into a meld: the hand with it and its best throw has less deadwood than now.

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