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
| Name | Type | Description |
|---|---|---|
near | Int32Array<ArrayBufferLike> | The board neighbour table. |
width | number | The board width in cells. |
height | number | The board height in cells. |
bigs | number | The desired number of big pieces. |
turning | number | The desired number of blocks that turn together. |
random | Random | 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)));