Reference · Pipes, rules and solving
turnBlockfunction
The 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. A new array.
Import it
import { turnBlock } from "@johnmorrisdotca/suido";
Definition
function turnBlock(masks: readonly number[], block: Block, by?: number): number[]
Parameters
| Name | Type | Description |
|---|---|---|
masks | readonly number[] | Current pipe masks in row-major cell order. |
block | Block | The zero-based ladder block index, or decoded four-cell block specified by the signature. |
by (optional) | number | The signed number of quarter turns. |
Returns
number[]
The 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. A new array.
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { blockInfo, decodeLayout, turnBlock } from "@johnmorrisdotca/suido";
const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const blockLayout = {...layout,bigs:[0]};
const block = blockInfo(blockLayout).blocks[0];
console.log(turnBlock(blockLayout.cells,block).slice(0,10));[
10, 6, 10, 5, 2,
1, 10, 5, 9, 8
]What it prints (run when this page was built)