![]() If a box has a value, then all the boxes in the same row, same column, or same 3x3 square cannot have that same value.The detailed rules can be found, for example, here. Sudoku consists of a 9x9 grid, and the objective is to fill the grid with digits in such a way that each row, each column, and each of the 9 principal 3x3 subsquares contains all of the digits from 1 to 9. To activate an Anaconda environment (OS X or Unix/Linux), use: It is available in the AIND environment or installed separately from here. pygame is needed to see the visualization.The AIND environment provided in the Anaconda lesson of Udacity's AIND Nanodegree (also available in this repo aind-universal.yml).Anaconda, a pre-packaged Python distribution that contains all of the necessary libraries and software for this project.They are not to be run separately, but will be called when running solution.py. PySudoku.py and visualize.py- Helper files for visualizing the solution.solution.py - Solves a diagonal Sudoku puzzle and visualizes the solution.We pick a box with a minimal number of possible values and try to solve each of the puzzles obtained by choosing each of these values, recursively. In the process of problem solving, we may get to the point where two or more possibilities are available. As we apply these functions repeatedly, this constraint ensures the resulting board will have a unique value for each box on each diagonal. The diagonal Sudoku problem: When we add diagonal units to both the unit and peer dictionaries, all the functions such as naked_twins, eliminate and only_choice ( solution.py) will take into account this new constraint.When we apply Naked Twins strategy, together with Eliminate and Only Choice, repeatedly, we will likely reach a solution to the Sudoku. As we do so, we recompute the possible value sets across the unit. So if two boxes have naked twins as possibilities, we can remove these possibilities from the rest of the boxes in the same unit. The naked twins problem: Each box must have a different value from the rest of the boxes in the same unit. ![]() Key AI concepts: Constraint propagationīelow is an explanation of how constraint propagation is applied to solve the naked twins problem and the diagonal Sudoku problem (see solution.py for the implementation): See the final section in this README document Sudoku explained for an overview of Sudoku, diagonal Sudoku and relevant terminologies. This project applies two AI concepts, Constraint Propagation and Depth-first Search, to solve diagonal Sudoku puzzles. Solve Sudoku with Artificial Intelligence Synopsis
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |