An intelligent Sudoku solver and visualizer built in Python. This project frames Sudoku as a Constraint Satisfaction Problem (CSP) and implements various foundational Artificial Intelligence search algorithms to solve puzzles of varying difficulties efficiently.
It features a modern Graphical User Interface (GUI) and a built-in performance evaluator to benchmark the speed and step counts of different algorithms.
- Play or Watch: Manually solve Sudoku puzzles or watch the AI solve them in real-time.
- Multiple AI Algorithms: Compare different search strategies on the same puzzle.
- Modern GUI: A sleek, interactive interface built with
CustomTkinter. - Performance Evaluation: Generates comparative graphs using
Matplotlibto visualize how each algorithm performs based on time and computational steps. - Puzzle Generation: Generates valid Sudoku puzzles for testing.
This project implements the following Constraint Satisfaction Problem (CSP) algorithms from scratch:
- Backtracking Search: A naive depth-first search approach that tries all possibilities.
- Forward Checking: An optimization over backtracking that keeps track of remaining legal values for unassigned variables to catch failures early.
- AC-3 with MRV (Minimum Remaining Values): Uses Arc Consistency to reduce the search space and the MRV heuristic to always choose the variable with the fewest legal options next, significantly improving performance.
- Local Search: An iterative approach that starts with a complete (but flawed) assignment and makes local modifications to reduce the number of constraint violations.
- Python 3
- CustomTkinter: For building the modern graphical interface.
- Matplotlib: For plotting algorithm performance comparisons.
- Clone the repository (or download the source code):
git clone https://github.com/YOUR_USERNAME/Sudoku-AI-Solver.git
- Navigate to the project directory:
cd Sudoku-AI-Solver/AI(main)/AI(main) - Install the required dependencies:
pip install -r requirements.txt
- Run the game:
python Game.py