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 · Klondike

bestFirstfunction

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.

Import it

import { bestFirst } from "@johnmorrisdotca/toranpu/klondike";

Also exported from: @johnmorrisdotca/toranpu/freecell, @johnmorrisdotca/toranpu/spider

Definition

function bestFirst<Table, Move>(game: BestFirstGame<Table, Move>, start: Table, budget: number): { moves: Move[] | null; tables: number; }

Parameters

NameTypeDescription
gameBestFirstGame<Table, Move>

The current native game; applying a move returns a new state.

startTable

The initial game or state before the recorded moves.

budgetnumber

Limits on the solver’s search work.

Returns

{ moves: Move[] | null; tables: number; }

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.

Examples

import { bestFirst } from "@johnmorrisdotca/toranpu/klondike";

console.log(bestFirst({ candidates: (at: number) => at < 3 ? [1] : [], play: (at: number, move: number) => at + move, won: (at: number) => at === 3, key: String, distance: (at: number) => 3 - at }, 0, 20));
{ moves: [ 1, 1, 1 ], tables: 3 }

What it prints (run when this page was built)

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