80 likes | 219 Views
Sudoku Most-Constrained Value Heuristic. How It Works. Two variable are created C and N C is the amount of numbers 1-9 that can appear in a given cell N is the amount of locations a single number 1-9 can appear in a given square. Example. Example.
E N D
How It Works • Two variable are created C and N • C is the amount of numbers 1-9 that can appear in a given cell • N is the amount of locations a single number 1-9 can appear in a given square
Example • Look at the second square in the first column
Example • Blue marks numbers that can be added to current cell 2,6 1,2,6 2,3,6 3,6 7,6
Example • C = 2 for cells 2, 6, and 7 • C = 3 for cells 4 and 5 • N = 1 for numbers 1 and 7 • N = 2 for number 3 • N = 3 for number 2 • N = 5 for number 6 2,6 1,2,6 2,3,6 3,6 7,6
Example • Heuristic will select 1 for cell 4 and 7 for cell 6 resulting in the square
Why Two Variables • By keeping track of two variables the heuristic is able to make a more informed decision when selecting a cell and a number to place in the given cell, and therefore reducing the amount of searching to find a solution. • With the example it can be shown that cell 4 would not have been selected because its C value was too high but the N value for the number 1 was exactly 1 and therefore the best solution.