本文へ移動

Tsunagi繋ぎ

同じ印の2つを別々の線で結び、盤を埋めます。収録された問題やシード付きの問題で遊べます。

「つなぎ」は、物をつなぐことを表す言葉です。 名前について(英語)

目次

リファレンス

ルール・解法・生成

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

最小化と gzip 圧縮をしたサイズは 22.4 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Tsunagi: join each pair of marbles with a line, every line its own, filling the board. The layouts and answers as codes, the rules a line must keep, a solver that counts answers, a generator, the twists (walls, bridges, waypoints, hexagons), the difficulty measure, and the level ladder. The levels themselves are data, imported a size at a time (@johnmorrisdotca/tsunagi/levels-7) or all through @johnmorrisdotca/tsunagi/levels.

エクスポート

名前種類概要
allJoined関数Solved: every pair joined, every open cell on a line, and every bridge gone over both ways.
answerOf関数The answer the lines make, in the answer's spelling (encodeAnswer).
blockOf関数The block a level is in, from 1.
blockRange関数A block's first and last level, the last no further than the size has.
blocksIn関数How many blocks a size of count levels has.
bridgeAndWallCandidate関数A board with bridges and the walls it needs besides: both twists at once, for the blocks after both are taught.
bridgeCandidate関数A board with want bridges, or null where this filling offers no place for them or the board has more than one answer.
bridgesOf関数The bridges of a board.
candidate関数One candidate level, or null: a filling, its layout, and the solver's proof that the layout has exactly one answer — the filling's own.
CAPITAL_PAIRS定数How many of PAIR_LETTERS are not small letters: a board that uses all of them has small letters for stones.
CELL_BLOCKED定数The decoded blocked-cell sentinel.
CELL_BRIDGE定数The decoded bridge-cell sentinel.
CELL_EMPTY定数A cell in a decoded layout: an empty cell, a blocked one, or a stone of pair n (0 for A).
Challenge型A challenge a board can have.
CHALLENGES定数WHAT A TSUNAGI LEVEL ASKS OF A PLAYER, read from its board: the challenges on it, where it sits in its block's lesson, and how hard it measured.
challengesOf関数The challenges on a board, in the order the ladder teaches them.
cheatGame関数Cheat: one unfinished line drawn as the answer has it, anything in its way cut back.
cheatLine関数CHEAT: one unfinished line drawn for the player, correctly.
checkGame関数Check: the pairs not joined yet are flagged, and how many cells are still empty is said.
checkTsunagiAnswer関数Validate that an answer fills this board with legal, separate lines connecting every pair.
compareEdges関数Edges in the one order a layout writes them: by their first cell, then their second.
countSolutions関数Count valid complete answers up to a limit within a bounded search budget.
countSolutionsOfLevel関数How a level is proved and measured: countSolutions for a board the search of this file has always counted (4×4 to 15×15, no portals), and for a bigger one, or one with portals, the SAT search started from the level's own answer (countSolutionsSat, binary pairs).
countSolutionsSat関数Counts a layout's answers by SAT, up to limit.
dailyTsunagiLevel関数The level of the day at a size: a whole number from 1 to that size's count of levels, or null for a size there are no levels of.
decodeLayout関数A layout read from its code, or null for a string that is not one: the wrong length, a stray character, a letter used other than twice, or letters not named in reading order.
decodeLines関数Lines read back from a progress code against the layout they were drawn on, or null for a code that does not describe lines on it: a start that is not a stone, a step from nowhere, a line through another pair's stone, a cell two lines claim.
DIFFICULTY_WEIGHTS定数The weights of the four measures in the score.
difficultyScores関数Each level's score, 0 (easiest) to 100 (hardest), as the blend of its four percentiles among measures — one size's levels.
dragFinger関数A finger over finger, drawing the line of pair, with the reach it had: the lines after it and the reach now.
dragGame関数The finger carried into a cell: the line grows, shortens or cuts another back, as the rules say.
dragThrough関数A drag that jumped several cells between two pointer events (a quick flick): walked one cell at a time along the row, then the column, so a fast finger draws what a slow one would.
dragTo関数A drag of the pair being drawn into cell: one step, as the finger enters a cell.
edgeKey関数An edge between two neighbouring cells, the same whichever way round they are named.
edgeModel関数A layout written down as clauses (see the top of this file), or null where it cannot be solved at all: a stone its pair does not name, or a cell with too few ways in and out to hold a line.
EdgeModel型The clauses a layout comes to, ready to be searched.
edgeOpen関数Whether a line may step from cell a to its neighbour b: no wall between them.
encodeAnswer関数A finished grid's code: the letter of the line through each cell, # where blocked, + on a bridge.
encodeLayout関数A layout's code, from its cells, walls, waypoints and whether it wraps: the inverse of decodeLayout.
encodeLines関数Encode current lines as native resumable progress for this layout.
encodePortals関数The portals as a layout writes them, after wrap: each pair as its smaller cell and its larger, the pairs in order; nothing where there are none.
encodeWalls関数The walls as a layout writes them, after the cells: nothing where there are none.
Explosion型EXPLOSIONS: every so many strokes, a drawn line is broken.
explosionAfter関数What the stroke-th stroke sets off, from the lines as it left them; null when it sets nothing off: a board without explosions, a stroke between them, or no line drawn to break.
explosionsAsChosen関数A level's explosions as the player chose to play them at set-up: as made, SOFTENED — a boom in place of a blast, and half as often — or OFF.
filled関数How many open cells have a line through them or a stone on them, and how many there are: a bridge counts twice, once each way over it.
FillingStyle型How a filling is laid, where it need not be the way it always was: how often a line takes its tightest way on, and whether it may start beside the tightest cell as well as on it.
firstUnsolvedTsunagiLevel関数The lowest level not yet solved, or null when every level of the size is.
forcedShare関数The share of a layout's empty cells filled by forced moves alone: each line's two ends are grown while one of them has exactly one empty neighbour to go to, until a pair's ends meet or no end has only one way on.
gameOver関数Whether the game takes no more strokes: solved, or out of strokes.
helpOf関数The help a game has used so far, the one that costs more where it used two; null for none.
helpOpensNext関数Whether a solve with this help (or none) opens what a solve opens: every help but explosions off, whose block's lesson was not played.
hexCandidate関数A HEXAGON: the board as Hexversi's honeycomb, the square's corners off the board, filled with lines that may step along either slant as well as the four ways a square allows (hexNeighboursOf).
hexNeighboursOf関数The six neighbours of a cell on the hexagon lattice, as indexes; fewer at an edge of the square (the hexagon's own edge is its # cells).
hexNeighbourTable関数Every cell's six neighbours on the hexagon lattice, worked out once for a size.
hexRadius関数The hexagon's radius on a board of this side: R, for a side of 2R + 1.
inHex関数Whether a cell of the square is inside the hexagon: at most R lattice steps from the middle.
isTsunagiDay関数Whether a text is a real date written YYYY-MM-DD: 2026-02-30 is not.
isTsunagiLevel関数Whether a number is a level this size has.
isTwist関数Whether a board is a twist: any challenge on it.
joined関数Whether a pair's line runs from one of its stones to the other.
layoutCells関数A layout's cells without its walls or wrap: the part of the code one character a cell.
layoutNeighbours関数Each cell's neighbours a line may step to on this board: the four around it, less any across a wall.
layoutOf関数The layout and answer the lines leave: their ends as stones, lettered in reading order, with whatever else the board has — blocked cells, bridges (in two lines' paths, drawn +) and walls.
layoutStep関数A layout's step from a to its neighbour b (stepBetween on its own kind of board), or 0.
letGo関数Letting go: a line of only its stone is no line (a tap on a stone clears it), and a line ends before a bridge it stopped on.
levelCountOf関数How many levels a size has in a set; zero for a size the set has none at.
LevelMeasure型What is measured of one level.
LevelRow型One level: its layout and its one answer, each a code (code.ts).
levelSeed関数The number a record keeps a level by: its own for the first set, TSUNAGI_PORTAL_SEED and its number for the portals.
liftGame関数The finger lifted: the stroke is counted if it changed the board, the board may be solved, and an explosion may go off.
Lines型THE LINES A PLAYER HAS DRAWN, and what a press and a drag do to them.
linesCodeFits関数Whether a progress code has the shape of one: a size's cells in the progress alphabet.
linesOfAnswer関数A level's answer drawn back as lines: each pair's cells, in order, from its first marble to its second.
LINK_BLOCKED定数The blocked-cell marker in a layout code.
LINK_BRIDGE定数The bridge-cell marker in a layout code.
LINK_EMPTY定数TSUNAGI, WRITTEN DOWN: a level's layout and a finished grid, as the strings every puzzle travels as (puzzleCode.ts is the spelling of the number grids; this is the spelling of this one).
LINK_HEX定数The segment after the cells that makes a board a hexagon of hexagons.
LINK_PORTALS定数The word after the cells that begins a list of portals, each as its two cells.
LINK_SPARSE定数The segment after the cells that says a board has few, long lines.
LINK_WALLS定数Where the walls start, after the cells.
LINK_WRAP定数The segment after the cells that makes a board wrap.
LinkCandidate型One candidate: its layout and answer codes, and what the solver said about it.
LinkExtras型What a board has besides its lines: the cells no line enters, the bridges two lines cross, and the walls between cells.
LinkLayout型A decoded board with pairs, cells, walls, waypoints, wrapping, portals and optional limits.
measureLevel関数Every measure of one level, from its layout and answer; null for a layout that does not read as one of this size.
measureSolved関数The same measures from a solve already made — how many positions and branches the solver took — so a caller that has just proved a level (the level tests) does not solve it a second time to measure it.
MOST_PAIRS定数The most lines a board can have: as many as there are characters to name them.
neighboursOf関数The four neighbours of a cell on a square grid, as indexes; fewer at an edge.
neighbourTable関数Every cell's neighbours, worked out once for a size.
newTsunagiGame関数A game on a layout code, or null for a code that is no layout at that size.
nextTsunagiLevel関数The level to open on: the first open one not yet solved, or the last open one when every open level is solved.
NO_REACH定数No distance: the finger draws toward the cell it is over.
noLines関数The initial lines rooted at each pair’s first endpoint.
openTsunagiLevels関数The levels that are open, given the ones solved: the first block of sixteen always, and each block after it once every level of the block before is solved.
orderByDifficulty関数The order to play a size's levels in: easiest first, by score, and among equal scores by their order in levels so the ranking is the same every time it is made.
outOfStrokes関数Whether the game is out of strokes before it is solved: it takes nothing more until restartGame.
overBridge関数The pair going over a bridge each way, or -1: across (left to right) and down.
ownersOf関数The pair whose line (or stone) holds each cell, CELL_EMPTY for none, CELL_BLOCKED where blocked, CELL_BRIDGE on a bridge (two lines may be there).
PAIR_LETTERS定数The characters a pair may be named by, in order: the capital letters, the digits, the small letters, then twenty punctuation marks, eighty-two in all, enough for a 30×30 board with as many lines to the cell as a 15×15 has.
portalExit関数The cell a line comes out at after stepping from from into portal cell into: beyond the other portal, the same way on; -1 where there is none (off the board, or across a wall).
portalsAreAmbiguous関数Whether two ways for a line to go from one cell to another exist on a board with portals (a portal and a step beside it, or two portals, or one in two directions), which an answer's cells could not tell apart.
pressAt関数A press: the lines after it, and the pair now being drawn, or null where the press draws nothing.
pressGame関数A finger down on a cell: starts a line from a marble, or carries on from a line's cell.
Random型A number in [0, 1), like Math.random, from a stream a seed fixes.
randomFilling関数Grid lines that fill every cell, as lists of cells; null when this attempt painted itself into a corner.
Reach型HOW FAR A FINGER IS FROM THE END OF THE LINE IT DRAWS, in rows and columns, once that line has been through a portal.
reducedCandidate関数One board made by taking clues away, or null.
ReducedCandidate型What a made board has besides its lines.
ReduceOptions型Budgets and geometry choices for generating a puzzle by reducing clues.
relettered関数A code's letters renamed in reading order of first appearance: the one spelling of a layout or answer.
renumberedRecord関数A RECORD KEPT BY LEVEL NUMBER, MOVED TO THE NUMBERS THE LEVELS HAVE NOW.
repairedCandidate関数One candidate level made by MENDING rather than by luck, for boards too big for luck (12×12): a filling whose layout has a second answer is mended where the two answers differ — the line through a cell they disagree on is cut in two there, which adds a pair of stones the second answer cannot honour — and solved again, until it has exactly one answer, its own.
restartGame関数Restart: every line cleared and the strokes counted again (Undo can bring the lines back).
SAT_BINARY_FROM_SIZE定数From which side the SAT solver writes a cell's pair as a binary number rather than a variable for each pair, which a board of dozens of pairs needs: every level to 15×15 was proved the first way and keeps its counts.
SAT_FROM_SIZE定数From which side of the board a layout is counted by solveSat.ts rather than by the search below.
SatColours型How a cell's pair is written as variables: a variable for each pair (the way every level to 15×15 was proved), or a binary number, which a board of many pairs can afford.
seededRandom関数A stream of numbers in [0, 1) fixed by a seed.
setOfSeed関数The set and the number in it a record's number names.
shuffled関数A copy of the list in a random order (Fisher–Yates); the list given is left alone.
SolveCount型THE TSUNAGI SOLVER: how many ways a layout can be joined, up to a limit, and how much trying it took.
sparseCandidate関数One sparse candidate level, or null.
sparseMost関数The most lines a sparse board of this side has: two thirds of the side — six on a 9×9, where nine is usual.
Step型WHERE A LINE MAY GO NEXT, on one board: the rules of a single step, which the solver, the check, the drawing and the answer's lines all read, so a bridge or a wall means the same thing everywhere.
stepBetween関数The way from a to its neighbour b as a step (-1, +1, -size, +size), counting a step across a wrapped edge as the step it is — right off the right edge is +1, though the cells' numbers differ by size - 1.
stepTable関数Every cell's steps on a board, worked out once.
stoneLetters関数The characters that name pairs in a layout's cells: the first thirty-six (capitals and digits), or all eighty-two where the board uses every one of the thirty-six, which is when its small letters are stones and not waypoints.
strokesToExplosion関数Strokes left before the next explosion: 1 means the next stroke sets one off.
strongestTsunagiHelp関数Of several helps, the one a solve is kept with: explosions off, then Cheat, then explosions softened.
symmetryKey関数The least spelling of a layout over its eight turns and mirrors: equal keys are the same board.
tailWord関数Which of the tail's words a segment is, and what it says; null for none of them (the walls list).
transformed関数A layout code turned or mirrored: turn quarter turns, then a mirror across the vertical when mirror.
TSUNAGI_BLOCK定数TSUNAGI'S BLOCKS: its levels come sixteen at a time.
TSUNAGI_DAILY_STRIDE定数Each day moves this many levels along a size's ladder, round to the start when it runs out.
TSUNAGI_LEVEL_COUNTS定数How many levels each size has, read without loading the size.
TSUNAGI_PORTAL_COUNTS定数The number of portal levels available at each supported size.
TSUNAGI_PORTAL_SEED定数A portal level's number in a record that keeps a level by one number: this and its number in its own set, past every level of the first.
TSUNAGI_PORTAL_SIZES定数A second set of levels, boards with portals (code.ts): a line goes in at one ring and out of the other.
TSUNAGI_SIZES定数TSUNAGI'S LEVELS, COUNTED: which sizes there are, how many levels each has, and which of them a player has opened.
tsunagiBand関数Which third of a size a level sits in: its first third easy, its middle medium, its last hard.
TsunagiBand型The third of a size a level sits in.
TsunagiCheck型What a check says: joined, or the first reason it is not.
tsunagiDay関数The day a moment falls on, in UTC, or the same day if it is already written as one.
TsunagiDay型A calendar date, YYYY-MM-DD.
TsunagiExplosionChoice型How a board's explosions are played: as made, softened (a boom for a blast, half as often) or not at all.
TsunagiGame型The complete immutable puzzle state, current stroke, undo history and assistance flags.
TsunagiGameOptions型What a game is told when it starts.
TsunagiHelp型The help a solve used: Cheat drew a line, or explosions were softened or turned off.
tsunagiMarks関数A level's measured difficulty, 1 (easiest) to 5, or null for a level the marks do not have.
tsunagiProgress関数Read the native completion, strokes, explosions and help status of a game.
TsunagiProgress型What a game stands at: for a status line under the board.
tsunagiRole関数A level's part in its block's lesson, from the data the level script wrote (marks.data.ts), without its size's boards; null for none.
TsunagiSet型Which set of levels: the ones from 4×4 up, or the ones with portals.
turnsIn関数How many times an answer's lines turn a corner, over all of them: a line going straight over a bridge turns nowhere on it.
TwistCandidate型MAKING TSUNAGI'S TWISTS, on a desk: boards with bridges, and boards with walls and blocked cells (John, 2026-09-26, both chosen from the brainstorm; bridges first).
twistRole関数A level's part in its block's lesson, or null for a level that has none (1 to 14, or a 15th or 16th left plain because somebody had played it).
TwistRole型Where a level sits in its block's lesson: its 15th teaches the block's twist, its 16th tests it.
undoGame関数Undo: the lines as they were before the last stroke.
unjoinedPairs関数The pairs not joined yet, for Check: every pair whose line does not run from one of its marbles to the other — a line stopped beside its partner looks joined and is not.
VERSION定数The package's version.
wallCandidate関数A board with blockedWanted blocked cells and as many walls as it needs (at most mostWalls) to have one answer, or null.
WAYPOINT_LETTERS定数The waypoints a layout may carry: a pair's capital in lower case, so only the first twenty-six pairs can have one.
waypointCandidate関数WAYPOINTS.
withoutPortalTail関数A line with the portal cells taken off its end, if it ends on any: a line is never left inside a portal.
withPortals関数A filling with portals put in: each portal is made by joining two lines into one that goes into a ring and out of another, and the two cells it takes are the portal.
wrapCandidate関数WRAP.
wrappedStep関数The cell beside at one step by (-1, +1, -size, +size) on a board that wraps: off one edge and in at the other.

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

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