Skip to the content

Kazu数

Generate checked Sudoku and logic puzzles, read native rules and hints, and draw or embed playable boards.

Kazu is the Japanese word 数 for number. About the name

Contents

Reference · Loop rules

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

NameTypeDescription
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"));

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kazu 2.1.0.