Reference · Rules, solvers and generation
windingLinesfunction
Every cell of the board in lines of at least three cells, none beside itself: one winding path, cut as it grows. When a line stops, the next starts beside its tip if a cell is free there, and otherwise in the tightest place left. A piece too short to be a line is handed to a line beside it; failing that the last few lines are taken back and grown again. Null where that did not settle.
Import it
import { windingLines } from "@johnmorrisdotca/tsunagi";
Definition
function windingLines(board: TsunagiBoard, random: Random, longest: number): number[][] | null
Parameters
| Name | Type | Description |
|---|---|---|
board | TsunagiBoard | The board as a graph. |
random | Random | A reproducible random source returning values in [0,1). |
longest | number | The longest a line may grow, in cells. |
Returns
number[][] | null
The lines, as lists of cells, or null.
Examples
import { seededRandom, squareBoard, windingLines } from "@johnmorrisdotca/tsunagi";
console.log(windingLines(squareBoard(5),seededRandom(42),15)?.flat().length);25What it prints (run when this page was built)