Skip to the content

Suido水道

Turn pipes to connect the pumps and drains, through fixed levels or seeded puzzles.

Suido means water supply in Japanese. About the name

Contents

Reference · Pipes, rules and solving

solvefunction

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 it

import { solve } from "@johnmorrisdotca/suido";

Definition

function solve(layout: Layout, limit?: number, budget?: number): SolveResult

Parameters

NameTypeDescription
layoutLayout

The decoded board with its dimensions, pipe masks and rule settings.

limit (optional)number

Stop after finding this many solutions.

budget (optional)number

The maximum search-node budget; exhaustion is inconclusive.

Returns

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.

Examples

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
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/suido 1.7.0.