solve関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Counts the answers to a board, up to limit, stopping early when budget
positions have been looked at. One answer is the whole point of a board:
count === 1 && complete is the proof.
A network is solved as a puzzle of what each piece may face: every piece
starts with its rotations, and a piece's opening on a side must be matched by
its neighbour's opening back (and an absence by an absence) until nothing
more can be removed; the search then picks the piece with fewest ways left
and tries each. Pieces the water could never reach, in any way the rest could
still face, end that branch at once. A drains board is solved the other way
round, because a spare piece may face any way: it grows a network from the
sources and the drains, settling what its openings force and trying what they
do not, and counts each distinct network once. An inlet-outlet board is solved
as a drains board in which a piece the water goes through opens on two sides
at most. Locked pieces have the one way they are given, and walls are edges the
neighbour table does not cross, so neither needs a rule of its own. A network
is solved in units (units.ts): a single piece is one, and a block that turns
as one is one, with its four turns for its facings.
インポート
import { solve } from "@johnmorrisdotca/suido";
定義
function solve(layout: Layout, limit?: number, budget?: number): SolveResult
引数
| 名前 | 型 | 説明 |
|---|---|---|
layout | Layout | The decoded board with its dimensions, pipe masks and rule settings. |
limit (省略可) | number | Stop after finding this many solutions. |
budget (省略可) | number | The maximum search-node budget; exhaustion is inconclusive. |
戻り値
SolveResult
Counts the answers to a board, up to limit, stopping early when budget positions have been looked at. One answer is the whole point of a board: count === 1 && complete is the proof.
例
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, solve } from "@johnmorrisdotca/suido";
const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
console.log(solve(layout,2,20000));{
count: 1,
solutions: [
[
6, 10, 10, 10, 8, 5, 2, 10,
12, 4, 7, 14, 10, 15, 13, 5,
3, 8, 1, 5, 3, 10, 10, 8,
1
]
],
nodes: 1,
branches: 0,
forced: 25,
complete: true
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。