Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
Constraint satisfaction

constraint-search

Finite-domain constraint satisfaction for puzzles and deduction games: check that a puzzle has one solution, give human-style hints and grade difficulty, infer hidden facts, with propagation, all-different reasoning, backtracking and solution counting

cargo add constraint-search

Who it is for

  • Puzzle generators and solvers (Sudoku and its variants, nonograms, Minesweeper, Kakuro, logic grids): uniqueness checks stop at the second solution, and the human-style rules grade difficulty by the costliest technique a solve needs and give the next hint step.
  • Tutoring, hint and explainable configuration tools, and small scheduling or allocation models: rules carry names, and Trace::why_removed says which deduction ruled a value out, so "why can't I choose this?" has an answer next to the solution.
  • Game AI with hidden information, such as card locations or unrevealed Minesweeper cells: the backbone gives the certain facts, marginals the probability of each value, and sampling draws consistent hidden states to plan with, without enumerating worlds by hand.
  • Embedded and no_std users: the core needs only alloc, and parallel search is an opt-in std feature.
  • For large industrial models, optimisation objectives or huge domains, use OR-Tools CP-SAT, Gecode or a MIP solver. For search over the moves of an adversarial game, use game-tree-search; for shortest paths and state-space search with costs, heuristic-search; for planning when the outcomes of actions are uncertain, rather than facts hidden, stochastic-search.

Algorithms 10