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
| Name | Kind | What it is |
|---|---|---|
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). |
CELL_PILES | constant | The free cells, as a move names them: as many as the game is played with, from the first. |
cellAt | function | Which free cell, from 0, a pile a move names is. |
COLUMN_PILES | constant | The columns, as a move names them. |
columnAt | function | Which column, from 0, a pile a move names is. |
COLUMNS | constant | How many columns the tableau has. |
countOnto | function | How 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. |
dealFreeCell | function | Deal a deck (card numbers, the first dealt first) into a table with so many free cells: one card to each column in turn. |
dealOfSeed | function | The deal of a seed: the site's one shuffle (shuffledDeck), written down. |
deckOf | function | The deck a deal string names, as card numbers, or null for one that is not a whole deck. |
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. |
fitsFoundation | function | Whether a card may go onto its suit's foundation now. |
follows | function | Whether upper may lie on lower in a column: one lower, of the other colour. |
FOUNDATION_PILES | constant | The foundations' letters, in SUITS order (spades, hearts, diamonds, clubs), as a card id writes a suit. |
foundationAt | function | Which foundation, from 0 in SUITS order, a pile a move names is. |
foundationPileOf | function | The foundation a card goes to. |
FREECELL_PILES | constant | Every pile's letter, for a move written down to be read back. |
freeCellFinishingMoves | function | THE 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. |
freeCellHomeMove | function | The move that sends a top card home, if it can go: what a double tap does. |
freeCellLiftable | function | The 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. |
FreeCellMove | type | One move: count cards carried from one pile to another. |
freeCellMoveFor | function | The move that carries the cards held at from to to, if the rules allow exactly those cards there. |
FreeCellPile | type | A 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). |
freeCellPileCards | function | The cards of a pile, bottom first, as the table holds them. |
FreeCellSpot | type | A 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). |
freeCellStuck | function | Whether nothing can be done but give up: no card can move anywhere. |
FreeCellTable | type | A game of FreeCell as it stands: the columns, the free cells and the foundations. |
freeCellWon | function | Whether every card is home. |
isCellPile | function | Whether a pile a move names is a free cell. |
isColumnPile | function | Whether a pile a move names is a column. |
isFoundationPile | function | Whether a pile a move names is a suit's foundation. |
mostCarried | function | The 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. |
movesFrom | function | Every move the rules allow from a table, one of each (the longest run into an empty column), for a stuck-game check. |
playFreeCell | 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. |
redCard | function | Hearts and diamonds, the second and third suits. |
replayFreeCell | function | A 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. |
runLength | function | How many cards on top of a column are in order, each on the one under it: the most a single carry could ever take. |
solveFreeCell | function | A 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. |
suitOf | function | A card's suit, 0 to 3 in SUITS order. |
topOf | function | The top card of a pile, or undefined where it holds none (a foundation's top is its suit at its count). |