Algorithm Specificationlib/games/sudoku.ts

How Explainable Deduction Hints Work

Editorial Commitment & Unique Value: A technical overview of step-by-step logical reduction algorithms in lib/games/sudoku.ts and how hints teach rather than spoil.
Published: 2026-01-15Last reviewed: 2026-10-28Next review: 2027-01-28

Why Backtracking Solvers Make Terrible Hints

On most puzzle websites, clicking "Hint" simply peeks at the final solution array and fills in a random digit. This spoils the game and teaches you nothing: you have no idea why that number belongs there or what deduction you missed.

In contrast, Atelier Games executes a tiered logical reduction analyzer (implemented in getSudokuHint()). The engine inspects your exact current board state and attempts logical techniques in order of human difficulty:

Hint Evaluation Pipeline:
  1. Scan for Naked Singles: Does any cell have 8 distinct numbers in its row, column, and box?
  2. Scan for Hidden Singles: Is any number confined to a single cell in a 3×3 box, row, or column?
  3. Scan for Pointing Pairs / Locked Candidates: Are candidate notes restricted to a straight line?
  4. Scan for Naked Pairs: Do two cells share identical candidate subsets?

The Three-Step Hint Architecture

Every hint delivered to the player contains three structured components defined in the ExplainableHint type:

1. Target Location

Identifies the row, column, and 3×3 box without immediately giving away the digit.

2. Logical Reason

Explains the specific elimination rule (e.g. "Row 4 already contains 1, 2, 3, 5, 6, 7, 8, and 9").

3. Suggested Action

Optionally places the verified candidate or reveals candidate eliminations on demand.

Limitations: What If You Have Mistakes on the Board?

Because our hint generator evaluates your actual current grid state, an incorrectly placed number can create contradictions. Before providing a forward deduction, the engine first validates your existing numbers against the unique solution matrix. If an erroneous digit is detected, the hint flags the conflicting cell first so you can correct your premise before attempting further logic.

How Explainable Deduction Hints Work — Atelier Games