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

Klondike

import { … } from "@johnmorrisdotca/toranpu/klondike";

3.9 kB minified and gzipped, with everything it imports (measured with esbuild)

Klondike, the Solitaire: its table, its rules, its moves written as text, a solver, and what a tap on the table means.

Exports

NameKindWhat it is
allFaceUpfunctionWhether every card on the columns is face up: from here the game plays itself out (autoFinish).
bestFirstfunctionA winning line from this table — every move a replay of it makes, the settling ones included — or null when none was found within budget tables.
BestFirstGametypeA BEST-FIRST SEARCH for a card game played alone, shared by FreeCell's solver and Spider's (freecell/solve.ts, spider/solve.ts).
carriedFromfunctionWhich card of a column a carry to to would take: the one face-up card whose run fits there, or null.
COLUMN_PILESconstantThe columns, as a move names them.
columnAtfunctionWhich column, from 0, a pile a move names is.
COLUMNSconstantHow many columns the tableau has.
dealKlondikefunctionDeal a deck (card numbers, the first dealt first) into a table: column by column along each row, as a dealer does.
dealOffunctionA deal string from card numbers.
dealOfSeedfunctionThe deal of a seed: the site's one shuffle (shuffledDeck), written down.
deckOffunctionThe deck a deal string names, as card numbers, or null for one that is not a whole deck.
decodeMovesfunctionA move list read back, or null for one with a character that is no move.
DRAW_CODEconstantThe letter a draw from the stock is written as, in a move list.
encodeMovefunctionOne move written as text: one or two letters.
encodeMovesfunctionA list of moves written as text, one after another with nothing between.
finishingMovesfunctionTHE GAME PLAYS ITSELF OUT once every card on the columns is face up: the moves that bring the rest home, found by the solver on a small budget (a table with nothing hidden is solved in a handful of tables), or null while a card is still face down or no way home is found — then the player goes on.
fitsColumnfunctionWhether a card may go onto a column: onto a card one higher of the other colour, or a King onto an empty one.
fitsFoundationfunctionWhether a card may go onto its suit's foundation now.
FOUNDATION_PILESconstantThe foundations' letters, in SUITS order (spades, hearts, diamonds, clubs), as a card id writes a suit.
foundationAtfunctionWhich foundation, from 0 in SUITS order, a pile a move names is.
foundationPileOffunctionThe foundation a card goes to.
homeMovefunctionThe move that sends a top card home, if it can go: what a double tap does.
isColumnPilefunctionWhether a pile a move names is a column.
isFoundationPilefunctionWhether a pile a move names is a suit's foundation.
isSafeHomefunctionWhether a card is one the solver treats as home safely: exported for its test.
KlondikeColumntypeOne of the seven columns: its cards from the bottom up, of which the first down lie face down.
KlondikeMovetypeOne move: turn cards from the stock (draw), turn the waste back over (recycle), or carry cards from one pile to another.
KlondikePiletypeA place on the table a move names: the stock s, the waste w, a suit's foundation by its letter (S H D C, as a card id writes a suit), or a column 1–7.
KlondikeRulestypeHow the game was set up: cards turned from the stock at a time, and how many times through the stock (Infinity for no limit).
KlondikeTabletypeA game of Klondike as it stands: every pile, and the rules it is played under.
klondikeWonfunctionWhether every card is home.
liftablefunctionThe cards a person can take hold of from a spot, the one held and every one on it, or none: the waste's top card, a foundation's top card, or any face-up card of a column with the run on top of it.
moveForfunctionThe move that carries the cards held at from to to, if the rules allow exactly those cards there.
movesFromfunctionEvery move the rules allow from this table, in a fixed order: to the foundations first, then onto the columns, then the stock.
pileCardsfunctionThe cards of a pile, bottom first, as the table holds them.
playKlondikefunctionThe table after a move, or null where the rules refuse it.
rankOffunctionA card's rank, 1 for an ace to 13 for a king.
RANKS_A_SUITconstantHow many ranks a suit has, ace to king.
RECYCLE_CODEconstantThe letter turning the waste back over is written as, in a move list.
recyclesLeftfunctionHow many times the waste may still be turned back: passes less one, less those already made.
redCardfunctionHearts and diamonds, the second and third suits.
replayfunctionA game played out from its deal: every table it passed through, the first the deal, or null where the deal is not a deck or a move is one the rules refuse.
solveKlondikefunctionA winning line from this table — every move, the safe ones home included, that a replay of it makes — or null when none was found within budget tables.
stockMovefunctionWhat a press on the stock does: turn it, or turn the waste back over, or nothing once the passes are spent.
stuckfunctionWhether nothing can be done but give up: no card can move anywhere, and the stock can be neither turned nor turned back.
suitOffunctionA card's suit, 0 to 3 in SUITS order.
TableSpottypeA card on the table, as a person points at it: the pile, and its place from the bottom (-1 for the pile's empty place).

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