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

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

46.1 kB minified and gzipped, with everything it imports (measured with esbuild)

Pipe masks, board codes, water flow, game state, bounded solvers and seeded puzzle generation.

Exports

NameKindWhat it is
armsOffunctionHow many sides a piece opens on.
BIG_FAMILIESconstantThe families of BIG_SHAPES, each with how many shapes it holds, in the order they first appear there.
BIG_KIND_LISTconstantEvery kind of big piece, in the order the generator draws them, with how often each is drawn.
BIG_KINDSconstantTHE BIG PIECES: squares of four cells that are one piece (Layout.bigs).
BIG_MIXESconstantThe mixes a generator draws a plate from, plainest first.
BIG_PIECES_LARGESTconstantThe most, which scores full marks for size: a board of 20×20.
BIG_PIECES_SMALLESTconstantThe fewest pieces the water goes through that count for anything: a board of 5×5.
BIG_SCORE_WEIGHTSconstantThe weight of the size in the score, and of the tangle; they add to 1.
BIG_SHAPESconstantEvery big piece there is, up to turning (BigShape): 699, ordered by how many pipes they hold, then how many openings they have, then family.
BigKindtypeThe name of a kind of big piece.
bigKindOffunctionWhich kind of big piece four masks make, and the fewest quarters clockwise from facing north that bring it to them; null for four masks that are none of the five.
bigMasksOffunctionThe masks of a big piece's four cells (clockwise from the top left) once it has been turned quarters quarters clockwise from facing north.
BigMixtypeWhich big pieces a generator draws from, from the plainest to every one there is:
BigOnBoardtypeOne big piece on a board: its top left cell, which of the 699 shapes it is, and how many quarters clockwise from the shape's own facing it is turned.
bigScoreOffunctionHow hard a board is across the set, 1 to 100: a whole number.
BigShapetypeEVERY BIG PIECE THERE CAN BE.
bigShapeByIdfunctionThe shape with this id, or undefined for four masks that make none.
bigShapeOffunctionWhich shape four masks make, and the fewest quarters clockwise from the shape's own facing (BigShape.masks) that bring it to them; null for four masks that are none of the 699: a blank cell, a ring, a pipe with no opening to the outside.
bigShapesInfunctionThe big pieces of a board and which shape each is, read from masks (one for every cell of the board, as a board's pieces or an answer's stand): the board's pieces for the facing it starts in, an answer's for the facing the water needs.
blendBigScorefunctionThe score of a board of used pieces whose tangle (exactDifficultyOf, 1 to 100 among boards of its size) is tangle, before it is rounded.
blendOffunctionThe blend of a board's five percentiles against reference, 0 to 1, before it is ranked among the blends.
BlocktypeA block: its anchor (top left cell), whether it is a big piece, and its four cells clockwise from the top left.
blockAtfunctionThe block a cell is in, or null.
blockCellsfunctionThe four cells of the block whose top left cell is anchor, clockwise from it.
blockFacingsfunctionEvery distinct way a block can face, as the four masks of its cells (in Block.cells order), the turn of 0 quarters first.
blockInfofunctionThe blocks of a board and the block each cell is in; read once for a layout and kept.
BlockInfotypeThe blocks of a board, in the order of their anchors, and which block each cell is in (-1 for none).
blockQuartersBetweenfunctionHow many quarters clockwise, 0 to 3, make the block's pieces in from the ones in to; null when no turn does.
canTurnfunctionWhether a piece can be turned into a new facing: ground, and a cross, look the same turned any way.
canTurnAtfunctionWhether a tap on cell of a game turns anything.
canTurnBlockfunctionWhether turning a block changes anything: a block of four crosses, or four pieces that look alike all round, never does.
cellCharfunctionA cell's character: its piece, marked as a source or a drain if it is one.
checkSuidoAnswerfunctionWhether an answer solves a board: the check a page makes to say "solved" and a server makes before it trusts a solve.
countSolutionsfunctionHow many answers there are, counted up to limit.
coverageOffunctionThe share of a board's pieces the water goes through in an answer, 0 to 1: 1 for a network, which the water reaches every piece of.
decodeLayoutfunctionThe board a code stands for, or null when it is not one: a bad size, an unknown character, a source or drain on bare ground, or no source at all.
deducefunctionThe deductions of a board, in rounds.
DeductiontypeWhat a player can work out without guessing, as a person would: look at every piece, fix what is forced, and look again.
DIFFICULTY_SIDESconstantThe sizes (side of the board) there is a reference set for.
DIFFICULTY_WEIGHTSconstantThe weights of the measures in the blend, for each kind.
difficultyOffunctionHow hard a board is, 1 to 100 among boards of its size, from the board as given and one of its answers.
EASTconstantThe east opening bit of a pipe mask.
encodeLayoutfunctionThe code of a board.
exactBigScoreOffunctionHow hard a board is across the set, 1 to 100, before it is rounded: what the levels are put in order by.
exactDifficultyOffunctionThe same before it is rounded to a whole number, from 1 to 100: the order boards are put in.
exactScoreOffunctionThe score of a measure against a reference set before it is rounded, from 1 to 100: what boards are put in order by, so that two boards of one whole score still have an order.
FlowtypeWhere the water is on a board as it is turned: the whole picture, from the pump outwards.
flowOffunctionThe water on a board whose pieces face as masks say.
flowOfGamefunctionThe water on a game.
GametypeA game in play: the board as it was given, how every piece faces now, and how far each has been turned in all (kept as a count rather than a facing, so a drawing can turn a piece the way it was tapped, never the long way round).
gameCodefunctionThe game as a code, every piece facing as it does now: what to keep to come back to it, and what to send to be checked.
gameFromCodefunctionA game from a board's code and the code of the board as it was left (gameCode): every piece facing as the kept code says, with the fewest quarters clockwise that get each there.
gameFromProgressfunctionThe game a board's code and a kept gameProgress make, or null when the code is not a board or the progress is not one of that board's.
gameProgressfunctionA game half played, as a short string to keep: one digit for each piece (the quarter turns clockwise it has had from the way the board gave it, 0 to 3; the four pieces of a block have the digit of the block), a colon, and the number of taps made.
GuidePiecetypeOne piece of the guide.
guidePieceByIdfunctionThe entry with this id, or undefined.
guidePiecesOffunctionThe pieces of one group, in the order of the guide.
hasBlocksfunctionWhether a board has any block.
hintForfunctionA piece to turn, for a player who asks for help: the first piece that does not face as answer says, nearest the pump first (the water's own order), or null when every piece does.
inBigMixfunctionWhether a shape belongs to a mix of the shapes (BigMix, not five).
isGameSolvedfunctionWhether the game is solved: the same test the check makes of an answer.
isJoinedInsidefunctionWhether the inside of a big piece is as it must be: wherever two of its cells meet, either both open towards each other or neither does.
isLockedfunctionWhether a piece is locked on this board.
isSolvedfunctionWhether a board facing as masks say is solved.
isTwistedfunctionWhether a board has any twist.
KindtypeWhat a board asks of the water.
LayouttypeA board.
laySuidofunctionA board laid out and turned at random, with no promise about how many answers it has: the raw material makeSuido shapes.
MadetypeA new board: its code, the code of its one answer, and what it was made from.
MadeScoredtypeA new board with how hard it is.
MakeOptionstypeWhat a new board may be asked for.
makeSuidofunctionMakes a board with exactly one answer and says how hard it is.
makeUnscoredfunctionMakes a board that has exactly one answer.
MAX_SIDEconstantThe largest side a board may have.
MeasuretypeWhat is measured of one board.
MEASURE_NAMESconstantThe measures, in the order the reference lists them.
MeasureNametypeThe measures, by name.
measureSuidofunctionEvery measure of one board, from the board as given and one of its answers.
neighboursOffunctionWhich cell is next to each cell on each side: table[cell * 4 + side], or -1 where there is no cell (the edge of a board that does not wrap) or a wall.
newGamefunctionA game on a board, with every piece as given.
NORTHconstantA side of a cell.
oppositefunctionThe side a piece next door must open on to meet an opening on side side.
percentileInfunctionWhere value stands among sorted quantiles, 0 to 1: how far through them it is, by the share of the way between neighbours.
PIECE_GROUPSconstantThe groups, in the order a guide shows them.
PieceGrouptypeA GUIDE TO EVERY PIECE.
placeAfterfunctionWhere the piece that stood in cell when the board was given is now, once its block has been turned quarters times clockwise.
placeBlocksfunctionPlaces 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.
PlacedtypeA block placed on a board by the generator: kind is a kind of BIG_KINDS or the id of a BigShape, and null for a block that turns as one.
quantilesOffunctionQuantiles of a list of numbers, at points even steps from least to greatest, for a reference set.
quartersBetweenfunctionThe fewest quarter turns, clockwise, that make from into to; null when they are not the same shape.
RandomtypeA number in [0, 1), like Math.random, from a stream a seed fixes.
ReferencetypeA reference set of boards, as quantiles: every measure at 21 even steps from its least to its greatest, and the blend of the five at 101.
referenceForfunctionThe reference set a board is scored against: that of the board's side (the square root of its cells, to the nearest size there is a set for), kind and wrap.
referenceKeyfunctionThe key a reference set is kept under.
rotationsOffunctionEvery way a piece can face, each once and in order: one for a cross, two for a straight, four for the rest.
sameBlockfunctionWhether two cells of a board are in the same block.
scoreOffunctionThe score of a measure against a reference set: 1 (the plainest of its size) to 100.
seededRandomfunctionA stream of numbers in [0, 1) fixed by a seed.
ShapetypeWhat a piece is, by how many sides it opens on and where.
SHAPE_MASKSconstantA piece of each shape facing north, as the drawings and the tests name them.
shapeOffunctionThe shape of a piece, from the sides it opens on.
shuffledfunctionA copy of the list in a random order (Fisher–Yates); the list given is left alone.
SIDE_STEPSconstantThe step across each side, as columns and rows.
SIDESconstantThe four sides by number, 0 (north) to 3 (west): the bit of side i is 1 << i.
sizeTermOffunctionHow big a board is for scoring, 0 to 1: the pieces its answer uses, on a log scale from BIG_PIECES_SMALLEST to BIG_PIECES_LARGEST.
solvefunctionCounts the answers to a board, up to limit, stopping early when budget positions have been looked at.
SolveResulttypeWhat the solver found.
SOUTHconstantThe south opening bit of a pipe mask.
SUIDO_BIG_FAMILIES_GUIDEconstantONE BIG PIECE OF EACH FAMILY.
SUIDO_LEVEL_TWISTSconstantThe six twists the fixed levels have, in the order they teach them.
SUIDO_PIECE_GUIDEconstantEVERY PIECE, with a picture to draw it by.
SUIDO_TWISTSconstantEvery twist, the six the fixed levels teach in the order they teach them, then the two of boards made on request.
SuidoChecktypeWhat a check says: solved, or the first reason it is not.
symmetryKeyfunctionA board's identity up to turning and mirroring it: the smallest of the codes of its eight turns and mirrors, with every piece the water does not go through (it may face any way) set to one facing.
tapsBetweenfunctionThe taps it takes to face a piece the right way when a tap turns it one way only (both false) or either way (both true, the shorter of the two).
tapsToAnswerfunctionThe fewest taps that would turn every piece to face as answer says, when a tap turns a piece either way (both, the default) or clockwise only.
transformLayoutfunctionA board's cells, pumps, drains, locks, walls and blocks moved by one of the eight turns and mirrors: op 0 to 3 turn it a quarter at a time, 4 to 7 do so after a mirror.
turnfunctionA piece turned quarters quarter turns clockwise; a negative number turns it the other way.
turnAtfunctionA tap: the piece on cell turned a quarter, clockwise (by 1) or the other way (by -1); a cell in a block turns the whole block, its pieces moving round to the next cell as they turn.
turnBlockfunctionThe pieces of a board after a block is turned by quarters clockwise (a negative number turns it the other way): the piece in each cell of the block moves round to the next and turns with the block.
turnedToFaceAtfunctionWhat a Hint does: the piece at cell turned clockwise, as many taps as it takes, to face as answer says; a block, the whole block, whichever of its cells is named.
turnsFromAnswerfunctionThe turns a board needs, when taps turn a piece either way: how far it is from solved.
TwisttypeTHE TWISTS: what a board can ask of a player beyond turning every piece until the water reaches all of them.
twistsOffunctionThe twists a board has, in the order the levels teach them: none for a plain board.
usedPiecesOffunctionHow many pieces the water goes through in an answer.
VERSIONconstantThe package's version.
WESTconstantThe west opening bit of a pipe mask.
withMasksfunctionThe same board with its pieces facing as masks says, which is how a half-played board or an answer is kept.

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