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
| Name | Kind | What it is |
|---|---|---|
allShowing | function | Whether every card is dealt and face up: from here the game plays itself out, where it can (finishingMoves). |
bestFirst | function | A 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. |
BestFirstGame | type | A BEST-FIRST SEARCH for a card game played alone, shared by FreeCell's solver and Spider's (freecell/solve.ts, spider/solve.ts). |
canDeal | function | Whether the stock can deal now: cards left, and no column empty. |
COLUMNS | constant | How many columns the tableau has. |
countOnto | function | How 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_CODE | constant | The letter dealing a card to every column is written as, in a move list. |
dealSpider | function | Deal a shuffled deck (card numbers, the first dealt first) into a table. |
DEALT | constant | Cards dealt to the columns before play; the rest are the stock. |
DECK_SIZE | constant | How many cards two decks hold, which Spider is played with at any number of suits. |
decodeMoves | function | A move list read back, or null for one with a character that is no move. |
encodeMove | function | One move written as text: one or two letters. |
encodeMoves | function | A list of moves written as text, one after another with nothing between. |
movesFrom | function | Every move the rules allow from a table, one of each (the whole run into an empty column), for a stuck-game check. |
playSpider | function | The table after a move, or null where the rules refuse it. |
rankOf | function | A card's rank, 1 for an ace to 13 for a king. |
RANKS_A_SUIT | constant | How many ranks a suit has, ace to king. |
replaySpider | function | A 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. |
runLength | function | How many cards on top of a column are one suit and in order, all face up: the most a carry can take. |
RUNS_TO_WIN | constant | Full runs to make: two decks of four suits. |
solveSpider | function | A winning line from this table, or null when none was found within budget tables. |
spiderBestMove | function | What 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. |
SpiderColumn | type | One of the ten columns: its cards from the bottom up, of which the first down lie face down. |
spiderColumnOf | function | The column a pile names, or null for the stock and the made runs. |
spiderDealMove | function | What a press on the stock does: deal, or nothing while a column is empty or the stock is spent. |
spiderDealOfSeed | function | The deal of a seed at so many suits: the site's one shuffle (shuffled) of both decks, written down. |
spiderDeck | function | The hundred and four cards of a game of so many suits, sorted: each suit's thirteen, as many times as fill two decks. |
spiderDeckOf | function | The cards a deal string names, or null for one that is not both decks of a game of so many suits. |
spiderFinishingMoves | function | THE 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. |
spiderLiftable | function | The 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. |
SpiderMove | type | One move: deal a card from the stock onto every column (deal), or carry count cards from the top of one column onto another. |
spiderMoveFor | function | The move that carries the cards held at from onto the column to, if the rules allow exactly those cards there. |
SpiderSpot | type | A place a tap lands on the table: the pile, and which card in it from the bottom. |
spiderStuck | function | Whether nothing can be done but give up: no card can move and the stock cannot deal. |
SpiderTable | type | A game of Spider as it stands: the columns, the cards still to deal, and the runs sent home. |
spiderWon | function | Whether all eight runs are made. |
suitOf | function | A card's suit, 0 to 3 in SUITS order. |
suitsFor | function | The suits a game of so many suits is played with, in SUITS order: spades; spades and hearts; all four. |