リファレンス
クロンダイク
import { … } from "@johnmorrisdotca/toranpu/klondike";
最小化と gzip 圧縮をしたサイズは 3.9 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Klondike, the Solitaire: its table, its rules, its moves written as text, a solver, and what a tap on the table means.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
allFaceUp | 関数 | Whether every card on the columns is face up: from here the game plays itself out (autoFinish). |
bestFirst | 関数 | 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 | 型 | A BEST-FIRST SEARCH for a card game played alone, shared by FreeCell's solver and Spider's (freecell/solve.ts, spider/solve.ts). |
carriedFrom | 関数 | Which card of a column a carry to to would take: the one face-up card whose run fits there, or null. |
COLUMN_PILES | 定数 | The columns, as a move names them. |
columnAt | 関数 | Which column, from 0, a pile a move names is. |
COLUMNS | 定数 | How many columns the tableau has. |
dealKlondike | 関数 | Deal a deck (card numbers, the first dealt first) into a table: column by column along each row, as a dealer does. |
dealOf | 関数 | A deal string from card numbers. |
dealOfSeed | 関数 | The deal of a seed: the site's one shuffle (shuffledDeck), written down. |
deckOf | 関数 | The deck a deal string names, as card numbers, or null for one that is not a whole deck. |
decodeMoves | 関数 | A move list read back, or null for one with a character that is no move. |
DRAW_CODE | 定数 | The letter a draw from the stock is written as, in a move list. |
encodeMove | 関数 | One move written as text: one or two letters. |
encodeMoves | 関数 | A list of moves written as text, one after another with nothing between. |
finishingMoves | 関数 | THE 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. |
fitsColumn | 関数 | Whether a card may go onto a column: onto a card one higher of the other colour, or a King onto an empty one. |
fitsFoundation | 関数 | Whether a card may go onto its suit's foundation now. |
FOUNDATION_PILES | 定数 | The foundations' letters, in SUITS order (spades, hearts, diamonds, clubs), as a card id writes a suit. |
foundationAt | 関数 | Which foundation, from 0 in SUITS order, a pile a move names is. |
foundationPileOf | 関数 | The foundation a card goes to. |
homeMove | 関数 | The move that sends a top card home, if it can go: what a double tap does. |
isColumnPile | 関数 | Whether a pile a move names is a column. |
isFoundationPile | 関数 | Whether a pile a move names is a suit's foundation. |
isSafeHome | 関数 | Whether a card is one the solver treats as home safely: exported for its test. |
KlondikeColumn | 型 | One of the seven columns: its cards from the bottom up, of which the first down lie face down. |
KlondikeMove | 型 | One move: turn cards from the stock (draw), turn the waste back over (recycle), or carry cards from one pile to another. |
KlondikePile | 型 | A 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. |
KlondikeRules | 型 | How the game was set up: cards turned from the stock at a time, and how many times through the stock (Infinity for no limit). |
KlondikeTable | 型 | A game of Klondike as it stands: every pile, and the rules it is played under. |
klondikeWon | 関数 | Whether every card is home. |
liftable | 関数 | The 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. |
moveFor | 関数 | The move that carries the cards held at from to to, if the rules allow exactly those cards there. |
movesFrom | 関数 | Every move the rules allow from this table, in a fixed order: to the foundations first, then onto the columns, then the stock. |
pileCards | 関数 | The cards of a pile, bottom first, as the table holds them. |
playKlondike | 関数 | The table after a move, or null where the rules refuse it. |
rankOf | 関数 | A card's rank, 1 for an ace to 13 for a king. |
RANKS_A_SUIT | 定数 | How many ranks a suit has, ace to king. |
RECYCLE_CODE | 定数 | The letter turning the waste back over is written as, in a move list. |
recyclesLeft | 関数 | How many times the waste may still be turned back: passes less one, less those already made. |
redCard | 関数 | Hearts and diamonds, the second and third suits. |
replay | 関数 | 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. |
solveKlondike | 関数 | A 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. |
stockMove | 関数 | What a press on the stock does: turn it, or turn the waste back over, or nothing once the passes are spent. |
stuck | 関数 | Whether nothing can be done but give up: no card can move anywhere, and the stock can be neither turned nor turned back. |
suitOf | 関数 | A card's suit, 0 to 3 in SUITS order. |
TableSpot | 型 | 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). |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。