Elegant, fast, and thoughtfully engineered N-Puzzle solvers in Rust. The repository contains two focused crates that share the same spirit—clarity, performance, and great developer ergonomics—while targeting different scopes.
mandatory: A* solver with solid heuristics and a friendly TUI wizardbonus: Everything inmandatoryplus extra search modes (Uniform-cost, Greedy)
mandatory/— crate namenpuzzlebonus/— crate namenpuzzle-bonus
Both crates include:
- An interactive mode designed for smooth exploration
- A
generatesubcommand to create solvable sample inputs ininputs/ - Heuristics: Manhattan, Manhattan + Linear Conflict (default), Misplaced tiles
- Optional summary output and a Markdown report at
target/npuzzle_report.md
• mandatory (crate: npuzzle)
- Core: A* search with rigorously chosen heuristics
- Experience: Friendly interactive wizard, readable colored output
- Deliverable: A compact, reliable solver that showcases informed search done right
• bonus (crate: npuzzle-bonus)
- Exploration: Compare search strategies side-by-side (A*, Uniform-cost, Greedy)
- Insight: Designed for experiments, profiling, and "why this path?" reasoning
- Everything from
mandatorywith the breadth to study trade-offs
- Search built for insight: clear separation of
grid,heuristic,a_star, andsolvermodules. Each piece does one job well. - Heuristics that matter:
- Manhattan distance
- Manhattan + Linear Conflict (default for balance of speed and admissibility)
- Misplaced tiles (didactic baseline)
- Deterministic input generation: reproducible, guaranteed-solvable instances for 3×3, 4×4, and 5×5 in
inputs/. - Thoughtful reporting: a concise Markdown report is written to
target/npuzzle_report.mdwith timing, memory, expansions, and the move sequence. - Ergonomic UX: an interactive wizard that guides you from choosing an input to selecting a heuristic or search mode.
- Rust-first performance: tight release settings, zero-unsafe code, and
rustc-hashfor fast closed-set lookups.
- State model: canonical goal layout and robust parity checks ensure solvability guarantees for generated puzzles.
- Priority-queue search: A* uses f(n) = g(n) + h(n) with careful tie-breaking to reduce churn in open sets.
- Memory efficiency: compact nodes, stable hashing, and measured peak memory in reports for practical comparisons.
- Bonus strategy matrix: Uniform-cost (pure g), Greedy (pure h), and A* (g+h) make the trade-space tangible—optimality vs. expansion vs. speed.
- Inputs: text files under
inputs/(and any custom file you provide). The interactive flow will list what it finds and accept manual paths. - Outputs: a human-friendly summary on screen and a Markdown report at
target/npuzzle_report.mdfor durable artifacts and sharing.
mandatorycaptures the essence: a sharp A* implementation with high-signal defaults and minimal ceremony.bonusopens the lab doors: flip a search mode, swap heuristics, and learn by comparing—without compromising on code quality.
- Strict compile settings, clippy on warnings-as-errors, and tuned release profiles ensure consistency and speed.
- Clear module boundaries invite reading the code—
a_star.rs,heuristic.rs,grid.rs, andsolver.rsare intentionally approachable.
If you’re here to study search, this codebase is a friendly place to start; if you’re here to ship, it’s already fast.