Applied Artificial Intelligence

AI Constraint-Satisfaction Sudoku Solver

An interactive browser edition of a graduate artificial intelligence project exploring constraint satisfaction, depth-first search, recursive backtracking, and candidate reasoning.

Objective

Identify valid candidates for open cells, provide a correct value for a selected square as a hint, or solve the complete puzzle on demand.

Logic Core

Constraint checking, AC-3 propagation, minimum-remaining-values selection, depth-first search, and recursive backtracking enforce Sudoku's row, column, and 3×3 sub-grid rules.

Architecture

The original layered Python/Flask application separated UI, controller, constraint, search, and API responsibilities. This edition retains that separation in a static browser implementation.

TRY THE SUDOKU SOLVER ↓

Interactive Demo

Try the solver

Select a difficulty, enter values directly, inspect possible candidates, request a hint for the selected cell, or let the algorithm complete the puzzle.

Preparing puzzle…

Algorithmic Approach

Search deeply. Reject early. Backtrack intelligently.

A brute-force search can explore every candidate, but constraint checking makes the search practical by abandoning invalid paths as soon as they violate the puzzle rules. AC-3 propagation reduces candidate domains before and during search, while the minimum-remaining-values heuristic chooses the most constrained open cell first.

When a branch reaches a contradiction or dead end, recursive backtracking returns to the last valid decision point and explores an alternate value. The same search process is used to solve entered puzzles and to verify that generated puzzles have a unique solution.

Original Implementation

  • Python puzzle generation and search logic
  • Constraint-satisfaction and recursive backtracking engine
  • Flask REST API for puzzle, solve, hint, and candidate requests
  • JavaScript rendering and browser interaction
  • HTML/CSS user interface