Skip to content

Latest commit

 

History

History
64 lines (33 loc) · 2.77 KB

File metadata and controls

64 lines (33 loc) · 2.77 KB

Description of the problem

Theoretical foundations for the solution

The Sudoku is a puzzle played on a partially filled 9x9 grid. The task is to complete the assignment using numbers from 1 to 9 such that the entries in each row, each column and each major 3x3 block are pairwise different. Like for many logical puzzles the challenge in Sudoku does not just lie in finding a solution. Well posed puzzles have a unique solution and the task is to find it without guessing. There are going to be an agent that will solve Sudokus created before and exported in a plain text

Block and/or flow diagram

alt text

Technical specifications of the implemented technique

There are several ways to solve Sudoku as there are several difficulties in this for example the difficulty easy can be solved by pruning the most complex need of backtracking as there are various numbers that match in two or more box; the algorithm is responsible for test the check with the lowest domain (less constraint) if there is any constraint returned in the assignment of numbers and test again until find a solution.

For the CSP we have:

Variables: The blocks of the sudoku, The columns are define with letters from A to I, the rows are listed from 1 to 9

Domains: Numbers from 1 to 9

Restrictions: We use a dictionary that has the relations of each box for example: A1 is related to the row 1, the column A and the blocks B2,B3,C2,C3.

Screenshots

alt text

alt text

alt text

alt text

Link to project’s YouTube video

Youtube Video

Dependencies and instructions to run the Project

The only external libraries that we're going to use are pygame and numpy; To run the program just use the command

phyton lab.py 

In the file called test_boards.py you can find 7 boards which can be loaded in the main program something like:

board = board0 

Resources

Sudoku as a Constraint Problem

The most difficult Sudoku puzzles are quickly solved by a straightforward depth-first search algorithm.

Sudoku as a CSP

Made by

Santiago Barragan - Carolina Gomez