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

Spider

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

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

Spider: its table at one, two or four suits, its rules, its moves written as text, a solver, and what a tap on the table means.

Exports

NameKindWhat it is
allShowingfunctionWhether every card is dealt and face up: from here the game plays itself out, where it can (finishingMoves).
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).
canDealfunctionWhether the stock can deal now: cards left, and no column empty.
COLUMNSconstantHow many columns the tableau has.
countOntofunctionHow many cards a carry from one column onto another takes, where it is not the player's to say: onto a card, the one count whose foot is one lower.
DEAL_CODEconstantThe letter dealing a card to every column is written as, in a move list.
dealSpiderfunctionDeal a shuffled deck (card numbers, the first dealt first) into a table.
DEALTconstantCards dealt to the columns before play; the rest are the stock.
DECK_SIZEconstantHow many cards two decks hold, which Spider is played with at any number of suits.
decodeMovesfunctionA move list read back, or null for one with a character that is no move.
encodeMovefunctionOne move written as text: one or two letters.
encodeMovesfunctionA list of moves written as text, one after another with nothing between.
movesFromfunctionEvery move the rules allow from a table, one of each (the whole run into an empty column), for a stuck-game check.
playSpiderfunctionThe 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.
replaySpiderfunctionA game played out from its deal: every table it passed through, the first the deal, or null where the deal is not two decks or a move is one the rules refuse.
runLengthfunctionHow many cards on top of a column are one suit and in order, all face up: the most a carry can take.
RUNS_TO_WINconstantFull runs to make: two decks of four suits.
solveSpiderfunctionA winning line from this table, or null when none was found within budget tables.
spiderBestMovefunctionWhat a double tap does in Spider, where no card goes home by itself: the run carried to the best column that takes it — one whose top is its own suit, else any card one higher, else an empty column.
SpiderColumntypeOne of the ten columns: its cards from the bottom up, of which the first down lie face down.
spiderColumnOffunctionThe column a pile names, or null for the stock and the made runs.
spiderDealMovefunctionWhat a press on the stock does: deal, or nothing while a column is empty or the stock is spent.
spiderDealOfSeedfunctionThe deal of a seed at so many suits: the site's one shuffle (shuffled) of both decks, written down.
spiderDeckfunctionThe hundred and four cards of a game of so many suits, sorted: each suit's thirteen, as many times as fill two decks.
spiderDeckOffunctionThe cards a deal string names, or null for one that is not both decks of a game of so many suits.
spiderFinishingMovesfunctionTHE GAME PLAYS ITSELF OUT once every card is dealt and face up: the moves that make the runs left, found by the solver on a small budget, or null while a card is hidden or no way is found — then the player goes on.
spiderLiftablefunctionThe cards a person can take hold of from a spot: a face-up card with the run of its own suit, in order, on top of it.
SpiderMovetypeOne move: deal a card from the stock onto every column (deal), or carry count cards from the top of one column onto another.
spiderMoveForfunctionThe move that carries the cards held at from onto the column to, if the rules allow exactly those cards there.
SpiderSpottypeA place a tap lands on the table: the pile, and which card in it from the bottom.
spiderStuckfunctionWhether nothing can be done but give up: no card can move and the stock cannot deal.
SpiderTabletypeA game of Spider as it stands: the columns, the cards still to deal, and the runs sent home.
spiderWonfunctionWhether all eight runs are made.
suitOffunctionA card's suit, 0 to 3 in SUITS order.
suitsForfunctionThe suits a game of so many suits is played with, in SUITS order: spades; spades and hearts; all four.

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