本文へ移動

Kazu数

検証済みの数独や論理パズルを作り、標準の規則とヒントを読み、盤を描いたり埋め込んだりできます。

「数」は数字を表す言葉です。 名前について(英語)

目次

リファレンス · 遊べる数字の盤

KazuEventDetail型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

What every event tells of the board.

インポート

import type { KazuEventDetail } from "@johnmorrisdotca/kazu/play";

定義

type KazuEventDetail = {
    kind: KazuKind;
    size: number;
    level?: KazuLevel;
    seed?: number;
    run: string;
    notes: string;
    answer: string;
    progress: {
        filled: number;
        total: number;
    };
    elapsedMs: number;
    hints: number;
    checks: number;
    helped: boolean;
    solved: boolean;
    hint?: KazuHint;
};

メンバー

名前型説明
kind"number-place" | "jigsaw" | "diagonal" | "sum-cages" | "more-or-less" | "towers"
sizenumber
level (省略可)"easy" | "medium" | "hard" | undefined
seed (省略可)number | undefined
runstring

What the player has written, as a run's code (decodeRun brings it back): to keep a puzzle half done.

notesstring

The pencil marks, as a code (decodeNotes). Empty for none.

answerstring

The whole grid, printed numbers and the player's: what checkKazu takes as an answer.

progress{ filled: number; total: number; }
elapsedMsnumber

The time on the clock, in milliseconds.

hintsnumber

How many hints were taken, and how many times Check was pressed. A solve with any hint is a helped one.

checksnumber
helpedboolean
solvedboolean
hint (省略可)KazuHint | undefined

For kazu-hint: what the hint said.

例

import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { answerOf, decodeCells, encodeNotes, encodeRun, isSolved, kazuProgress, newKazuGame } from "@johnmorrisdotca/kazu";
import type { KazuEventDetail } from "@johnmorrisdotca/kazu/play";

const puzzle: KazuPuzzle = {"kind":"number-place","size":4,"level":"easy","seed":42,"givens":"14..2..1412.3..4","solution":"1432234141233214"};
const kind = puzzle.kind;
const size = puzzle.size;
const givens = puzzle.givens;
const answer = puzzle.solution;
const solution = decodeCells(answer,size)!;
const game = newKazuGame(kind,size,givens)!;
const value: KazuEventDetail = {kind,size,run:encodeRun(game.entries),notes:encodeNotes(game.notes),answer:answerOf(game),progress:kazuProgress(game),elapsedMs:0,hints:0,checks:0,helped:false,solved:isSolved(game)};
console.log(value);
{
  kind: 'number-place',
  size: 4,
  run: '................',
  notes: '',
  answer: '14..2..1412.3..4',
  progress: { filled: 9, total: 16 },
  elapsedMs: 0,
  hints: 0,
  checks: 0,
  helped: false,
  solved: false
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kazu 2.1.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。