Skip to main content

Crate pencil_puzzles

Crate pencil_puzzles 

Source
Expand description

Generators, solvers and difficulty raters for pencil puzzles.

Each genre is a module, behind a feature of the same name. All genres are enabled by default. To compile fewer genres, turn off default features and enable the ones you need.

use pencil_puzzles::Difficulty;
use pencil_puzzles::kakurasu::{self, GenerateOptions};

let mut options = GenerateOptions::new("6x6".parse().unwrap(), 42);
options.difficulty = Some(Difficulty::Hard);
let generated = kakurasu::generate(&options, &pencil_puzzles_core::Budget::unlimited()).unwrap();
assert_eq!(generated.rating.level, Difficulty::Hard);

§Features

  • all-genres (default): every genre.
  • One feature per genre, such as kakurasu.
  • serde: implements Serialize and Deserialize for each genre’s puzzles, solutions and ratings.

Re-exports§

pub use pencil_puzzles_fillomino as fillomino;
pub use pencil_puzzles_hashi as hashi;
pub use pencil_puzzles_hitori as hitori;
pub use pencil_puzzles_kakurasu as kakurasu;
pub use pencil_puzzles_kakuro as kakuro;
pub use pencil_puzzles_sudoku as sudoku;
pub use pencil_puzzles_nurikabe as nurikabe;

Modules§

grid
Rectangular grid helpers shared by genres (I5).
human
The human solve loop shared by every genre (docs/design/framework.md).
id
Puzzle IDs: short, one-line forms of puzzles for links and sharing (F9–F12 in the guidelines).
search
The generator loop shared by every genre (docs/design/framework.md).
text
The text format shared by every genre (F1–F8 in the guidelines).

Structs§

BlockCell
A shaded cell that holds no mark. When either label is non-empty, a diagonal from the top-left to the bottom-right corner splits it, with upper in the top-right half and lower in the bottom-left half.
Budget
A cap on the amount of work an operation may do, counted in basic operations (such as solving one row of a puzzle), not in time, so that the same budget gives the same result on every machine.
BudgetExceeded
An operation ran out of its work budget before finishing.
CandidateFact
Candidate information used as a premise of a human pattern.
ClueInput
A numeric clue input in a visual puzzle editor.
Generated
A generated text record and its full rating.
Generation
A generated record with complete rating and work statistics (P7).
Input
A validated input record and the registered genre that interprets it.
Literal
A statement that a variable has a value, such as “the cell in row 1, column 2 is shaded” (a literal, in the terms of docs/difficulty.md).
MarkOption
A cell or link mark offered by a genre.
Metadata
Metadata used by registries and tools (P1).
Metrics
Per-step measurements of a canonical solution path. Unstable; used by evaluation tools, not part of the difficulty definition.
ParseDifficultyError
An error from parsing a Difficulty that isn’t one of easy, medium, hard, expert or extreme.
ParseError
An error from reading text, a puzzle ID or JSON, saying what is wrong and where (G7).
PatternProof
One pattern inference in a replayable proof graph.
PuzzleEditor
A visual clue editor supplied by a genre, independent of browser code.
Rating
The rating of a puzzle: the human techniques its canonical solution path needs (docs/difficulty.md).
Record
A puzzle as read from text, with its solution and the other shared keys (F6), so that they can be written back unchanged (F8).
Rule
A numbered rule’s short name (P1).
SplitMix64
The SplitMix64 random number generator.
Step
One step of a rating, for hints and explanations (L19).
View
A rectangular board with labels outside its four sides and links between cells (I4).
ViewCell
One cell in row-major order.
ViewLink
A straight link between the centres of two cells in the same row or column, such as a Hashi bridge.
Violation
A broken rule instance, found by a checker (P8).

Enums§

Difficulty
How hard a puzzle is to solve, on a scale shared by every genre.
Hint
The next step for a player, given their partial answer (P9, L19).
Place
A place on a rectangular board, counted from 0 (D5). Used by violations (P8) and by the steps a rater lists (L19).
Position
Where in the input a ParseError was found.
RateError
An error from rating a puzzle.
Solutions
The solutions of a puzzle, as far as uniqueness is concerned (P5).

Traits§

DynGenre
An object-safe adapter. Text records carry shared metadata between operations. All parsing is validated, and never invokes a solver or rater (F6).
Genre
The typed interface implemented by every genre (I1).

Functions§

find
Find a genre by its canonical id or any alias (N2).
genres
Every compiled-in genre, in canonical id order (I1, K4).
read
Parse IDs, text records (including mixed-genre files), or F14 JSON envelopes. Text without a genre is rejected because the registry cannot infer it (I2).

Type Aliases§

RegistryError
Actionable failure from a type-erased operation.