本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス · クロンダイク

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.

インポート

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

ほかのエクスポート元: @johnmorrisdotca/toranpu/freecell, @johnmorrisdotca/toranpu/spider

定義

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

引数

名前型説明
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.

戻り値

{ 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.

例

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 }

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/toranpu 2.15.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。