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

FreeCell

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

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

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

Exports

NameKindWhat it is
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).
CELL_PILESconstantThe free cells, as a move names them: as many as the game is played with, from the first.
cellAtfunctionWhich free cell, from 0, a pile a move names is.
COLUMN_PILESconstantThe columns, as a move names them.
columnAtfunctionWhich column, from 0, a pile a move names is.
COLUMNSconstantHow many columns the tableau has.
countOntofunctionHow many cards a carry from one column to another takes, where it is not the player's to say: onto a card, the one count whose foot fits it.
dealFreeCellfunctionDeal a deck (card numbers, the first dealt first) into a table with so many free cells: one card to each column in turn.
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.
encodeMovefunctionOne move written as text: one or two letters.
encodeMovesfunctionA list of moves written as text, one after another with nothing between.
fitsFoundationfunctionWhether a card may go onto its suit's foundation now.
followsfunctionWhether upper may lie on lower in a column: one lower, of the other colour.
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.
FREECELL_PILESconstantEvery pile's letter, for a move written down to be read back.
freeCellFinishingMovesfunctionTHE GAME PLAYS ITSELF OUT once nothing is left to decide: when every card still out can go home in turn, the lowest first, the moves that take them there — or null while one cannot, and the player goes on.
freeCellHomeMovefunctionThe move that sends a top card home, if it can go: what a double tap does.
freeCellLiftablefunctionThe cards a person can take hold of from a spot, the one held and every one on it, or none: a free cell's card, or a column's card with the run in order on top of it.
FreeCellMovetypeOne move: count cards carried from one pile to another.
freeCellMoveForfunctionThe move that carries the cards held at from to to, if the rules allow exactly those cards there.
FreeCellPiletypeA place on the table a move names: a column 1–8, a free cell a–d, or a suit's foundation by its letter (S H D C, as a card id writes a suit).
freeCellPileCardsfunctionThe cards of a pile, bottom first, as the table holds them.
FreeCellSpottypeA 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).
freeCellStuckfunctionWhether nothing can be done but give up: no card can move anywhere.
FreeCellTabletypeA game of FreeCell as it stands: the columns, the free cells and the foundations.
freeCellWonfunctionWhether every card is home.
isCellPilefunctionWhether a pile a move names is a free cell.
isColumnPilefunctionWhether a pile a move names is a column.
isFoundationPilefunctionWhether a pile a move names is a suit's foundation.
mostCarriedfunctionThe most cards a carry may take, as though moved one at a time: one more than the empty free cells, doubled for every empty column but the one the cards are going to.
movesFromfunctionEvery move the rules allow from a table, one of each (the longest run into an empty column), for a stuck-game check.
playFreeCellfunctionThe 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.
redCardfunctionHearts and diamonds, the second and third suits.
replayFreeCellfunctionA 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.
runLengthfunctionHow many cards on top of a column are in order, each on the one under it: the most a single carry could ever take.
solveFreeCellfunctionA winning line from this table — every move a replay of it makes, the safe ones home included — or null when none was found within budget tables.
suitOffunctionA card's suit, 0 to 3 in SUITS order.
topOffunctionThe top card of a pile, or undefined where it holds none (a foundation's top is its suit at its count).

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