generateLoopfunction
Makes a seeded puzzle and proves it has one answer. A random winding loop is grown cell by cell, every square is numbered with how many of its edges the loop uses, and then numbers are taken away for as long as the puzzle can still be solved the way the level asks: easy and medium by the rules alone (easy keeps most numbers), hard by supposing one edge at a time, extra-hard the most-supposing of several such boards. Numbers that say 0 are taken away first, because they say least. If no board of the level is found within the attempts the next level down is tried, and the first generator, which cannot fail, is the last.
Import it
import { generateLoop } from "@johnmorrisdotca/kazu/loop";
Also exported from: @johnmorrisdotca/kazu
Definition
function generateLoop(width?: number, height?: number, seed?: number, level?: LoopLevel): LoopPuzzle
Parameters
| Name | Type | Description |
|---|---|---|
width (optional) | number | The supported board width in cells. |
height (optional) | number | The supported board height in cells. |
seed (optional) | number | The reproducible native puzzle seed. |
level (optional) | LoopLevel | The requested native difficulty tier. |
Returns
LoopPuzzle
Makes a seeded puzzle and proves it has one answer. A random winding loop is grown cell by cell, every square is numbered with how many of its edges the loop uses, and then numbers are taken away for as long as the puzzle can still be solved the way the level asks: easy and medium by the rules alone (easy keeps most numbers), hard by supposing one edge at a time, extra-hard the most-supposing of several such boards. Numbers that say 0 are taken away first, because they say least. If no board of the level is found within the attempts the next level down is tried, and the first generator, which cannot fail, is the last.
Examples
import { generateLoop } from "@johnmorrisdotca/kazu/loop";
console.log(generateLoop(5,5,42,"easy"));