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

placeBlocksfunction

Places blocks on a board of width by height, where near is the table of neighbours with no walls (neighboursOf): bigs big pieces, each of a kind drawn at random facing a way that has no opening off the edge of the board, and turning blocks that turn as one. No two overlap, no big piece touches another big piece along a side, and none stands across the edge of a board that wraps. Fewer are placed where the board has no room for them.

Import it

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

Definition

function placeBlocks(near: Int32Array, width: number, height: number, bigs: number, turning: number, random: Random, mix?: BigMix): Placed[]

Parameters

NameTypeDescription
nearInt32Array<ArrayBufferLike>

The board neighbour table.

widthnumber

The board width in cells.

heightnumber

The board height in cells.

bigsnumber

The desired number of big pieces.

turningnumber

The desired number of blocks that turn together.

randomRandom

A random source returning values in [0,1).

mix (optional)BigMix

The supported big-piece family mix.

Returns

Placed[]

Places blocks on a board of width by height, where near is the table of neighbours with no walls (neighboursOf): bigs big pieces, each of a kind drawn at random facing a way that has no opening off the edge of the board, and turning blocks that turn as one. No two overlap, no big piece touches another big piece along a side, and none stands across the edge of a board that wraps. Fewer are placed where the board has no room for them.

Examples

import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, neighboursOf, placeBlocks, seededRandom } from "@johnmorrisdotca/suido";

const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
console.log(placeBlocks(neighboursOf(layout),layout.width,layout.height,1,0,seededRandom(42)));

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