SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
Sudoku Solving with Computational
           Intelligence




           Dr. Harald Hiss

            June 30, 2010
Summary
Computers can create convincing results – the cinemas are presenting the
latest overwhelming 3D multimedia spectacles. The results and benefits
aren’t restricted to the amusement and movies, modern methods for our
machines bring further considerable improvements to reality. Programs and
algorithms evolve in bioinformatics and public health. Computational intel-
ligence can also be utilized in solving brainteasing tasks. This article is
presenting a computational intelligence approach for solving Sudoku brain-
teasers.
A scanning strategy introduces Sudoku and solves the first example. The
article presents an estimation of the complexity with stochastic methods.
Sudoku-specific advanced strategies refine the scanning technique from
the introduction. A software-architecture for efficiently implementing a rule-
based solver is integrating the strategies and is using annotations that are
updated with notifications. When no rule can be applied, a backtracking
search is started. The parametrized solver offers policies for searching. A
logging mechanism is presented supporting the search saving memory for
the efficient implementation.
The author, Dr. Harald Hiss, has obtained the diploma in software-engineering
in 2004 and he has graduated in databases in 2008 at the university of
Freiburg supported by the interdisciplinary graduate programme logic and
applications. This article is presenting a new Sudoku solver that performs
best. The computer scientist is presenting Sudoku-specific strategies and
a solver architecture for the fast and simple implementation using the latest
technologies.
Contents

1 Solving Sudoku with Computational Intelligence   1

2 Sudoku and a Scanning Strategy                   1

3 Possibilities Estimation                         3

4 Sudoku-specific Strategies and Techniques         4

5 Solver Software-Architecture                     6

6 Integrating AI Search Strategies                 7
2 Sudoku and a Scanning Strategy                                                         1


1 Solving Sudoku with Computational Intelligence
Computers can create convincing results – the cinemas are presenting the latest over-
whelming 3D multimedia spectacles. The results and benefits aren’t restricted to the
amusement and movies, modern methods for our machines bring further consider-
able improvements to reality. Programs and algorithms evolve in bioinformatics and
public health. Computational intelligence can also be utilized in solving brainteasing
tasks. This article is presenting a computational intelligence approach for solving Su-
doku brainteasers. The example is illustrating specific game strategies, estimating the
complexity and again proving both power and expressiveness of computational intelli-
gence.
At the turn of the millenium, the number puzzle became very popular. The enjoyable
quest for filling numbers in fields comes in some variants and difficulty levels. Simple
Sudokus can be solved very fast, the next chapter introduces a scanning strategy that is
sufficient for automatically solving a first example. After the description, an estimation of
the complexity is given with stochastic methods showing a huge amount of possibilities
that a solver has to face. For the development of an automatic solver, some advanced
strategies are presented. The aspects are integrated in a flexible software-architecture
that can be easily adapted to Sudoku variants. Finally, the strategies are integrated
with the architecture. Computational intelligence extracts information for choosing the
appropriate rules to fill the next field and for choosing optimal fields and numbers for
backtracking when no rule applies.
The article presents an approach in computational intelligence for Sudoku. The con-
venient example is illustrating many aspects of computational intelligence. The num-
ber quest is formalized, stochastical methods estimate the possibilities, the specific
advanced strategies integrate with the software architecture and a rule-based logical
system. Methods from artificial intelligence and learning optimize the search choosing
the right fields and numbers – a very promising approach for constructing a success-
ful Sudoku solver with computational intelligence. The author has acquired very much
knowledge in this field. The huge power of computational intelligence can impressively
be shown with the Sudoku example presented in this article.




2 Sudoku and a Scanning Strategy
The challenge of Sudoku is posed in filling fields with fitting numbers so that some
number constraints are satisfied. The fields are arranged in groups. Within a group,
only numbers of a defined domain may be inserted. Numbers may not occur more than
once in a group. Solutions have filled all fields so that each number occurs exactly



                                            1
2 Sudoku and a Scanning Strategy                                                      2


once in each group. The standard Sudoku variant considers a 9 × 9 array of fields and
defines the domain 1, 2, ..., 9 for the numbers. As groups, the number puzzle considers
rows, columns and the 9 blocks formed of the 3 × 3 squares that are tiling the game.
The constraints have to be satisfied for each group. For instance, a row can contain
numbers in 1, 2, ..., 9 and a row of a solution represents a permutation of the domain.
The section shows a simple scanning strategy for solving some Sudokus. Figure 1

Figure 1 An easy Sudoku example.


                          1          2          5     9          4

                                     4     3    6           1    5

                               5           1                3

                    1                           2     5

                    7          2     6                      9    3

                                     3     4          2     7    1

                    3     6                     7     1          9

                               7     1          4           2    8

                          8          5     9                     7


presents the example that is illustrating the strategy. For the numbers of the domain,
the rows and columns are scanned to find the appropriate field in a block. The scan
starts with 1. The second field of the first row, abbreviated with S12 , has a 1. In the
block below, the field S41 stores this number. The first two columns may not contain the
number anymore, the left bottom block has the 1 in S73 or S93 . Then the scan considers
the relevant rows for the bottom block. The seventh row has a 1 in S77 , the 1 can be
filled in S93 . Using scans and filling obvious fields the solution in figure 2 is obtained.
The next section estimates the amount of possible games. Then again the article turns
to solving strategies and presents some advanced techniques.




                                           2
3 Possibilities Estimation                                                             3


Figure 2 The solution for the previous example.


                     6       1   3    2    7      5    9    8     4

                     9       2   8    4    3      6    7    1     5

                     4       7   5    9    1      8    6    3     2

                     1       3   9    7    8      2    5    4     6

                     7       4   2    6    5      1    8    9     3

                     8       5   6    3    4      9    2    7     1

                     3       6   4    8    2      7    1    5     9

                     5       9   7    1    6      4    3    2     8

                     2       8   1    5    9      3    4    6     7



3 Possibilities Estimation
A first naive estimation of the possibilities for choosing the numbers in the 9 × 9 square
considers filling each field with any number. The 981 combinations compute a total
of 1.966 · 1077 . The first improvement considers the symbols that have been inserted
previously in the same row. For nine rows, 9!9 combinations are obtained, a total of
1.091 · 1050 . Taking into account more information considering relevant blocks the num-
ber can be improved to 1.528 · 1031 . The huge amount suggests to invest some time
in software design considerations and to integrate both efficient game-specific strate-
gies and intelligent computational methods instead of implementing a trial-and-error
program. The following sections are going to present an efficient approach for the de-
velopment of an automatic solver.
The final estimation presented in this section is considering sequentially filling numbers,
from the left to the right and from the top to the bottom. The estimation uses the max-
imal restriction that is available in the context of the focussed field. The maximum of
the present numbers in the same row, column or block reduces the possible choice.
Figure 3 shows the result. The field in line 5, column 4 is regarding the numbers above
and to the left. In the same line, three numbers have been inserted. The column has
four numbers, and the middle block three. The column offers the maximal restriction of



                                           3
4 Sudoku-specific Strategies and Techniques                                               4


Figure 3 Possibilities for choosing a number for a field starting at the top-left corner
continuing from the left to the right and downward.


                     9     8     7     6    5     4     3     2     1

                     6     5     4     6    5     4     3     2     1

                     3     2     1     3    2     1     3     2     1

                     6     6     6     6    5     4     3     2     1

                     5     5     4     5    5     4     3     2     1

                     3     2     1     3    2     1     3     2     1

                     3     3     3     3    3     3     3     2     1

                     2     2     2     2    2     2     2     2     1

                     1     1     1     1    1     1     1     1     1



four different numbers. At most five numbers remain for choosing, the possibilities are
inserted in the field. With this approach, an estimation of 9! · 6!6 · 3!10 · 5 is obtained.
The number of possible valid Sudoku instances can be bound with 1.528 · 1031 . Another
aspect of Sudoku brainteasing is presented in figure 3. The last column and the bottom
row have one possibility left for each field. Often, many fields are still empty although
the game has been solved. Some clean-up work completes a Sudoku game filling num-
bers in fields that are restricted already having 8 numbers in the same group.
The next section is showing some improvements for the simple scanning solver in-
troduced at the beginning and is presenting advanced Sudoku-specific strategies and
techniques.


4 Sudoku-specific Strategies and Techniques
Easy instances can be solved with simple strategies as shown in section 2. For each
number, the possible positions within a block have been scanned excluding correspond-
ing rows and columns in the blocks of the same column and row. Obvious fields remain-
ing as the single gap in a group can be filled. For each field, the numbers of all groups




                                            4
4 Sudoku-specific Strategies and Techniques                                                  5


it belongs to can be removed from the candidates. Again, if one number is left the gap
can be filled. This section is considering advanced strategies for more complex Sudoku
solving.
Side-effects of groups can be used for improving the scanning approach presented in

Figure 4 First lines of the example for the improvement.


                                                                1

                                        1     1     1

                      1     8     9     2     3     4


section 2. Some group restrictions suffice to determine fields in depending groups. Fig-
ure 4 shows an example, the possible positions for a 1 in the middle block have blue
entries. The Information that the middle block has the 1 in the middle row suffices for
filling a 1 in S31 . In this way, the 1 in the first block is restricted to the two bottom fields
when the middle and last block share the 1 in the first two rows as shown in figure 5.
The section presents a strategy that is not necessarily needed to solve the example of

Figure 5 A variant of the improvement.


                                        1     1     1     1     1     1

                                        1     1     1     1     1     1

                      1     1     9     2     3     4     5     6     7


the introduction. The last row of the instance shown in figure 6 contains 9, 6, 7 and 8.
Other fields in this row can be filled with 1, ..., 5. The bottom middle block contains 4, 2
and is restricting its bottom row to 1, 3, 5. Considering columns is proving S94 , S95 ∈ {1,
5} and S96 ∈ {1, 3}. The constraints for S94 and S95 consume 1 and 5, the three fills S96 .
Constraints consuming numbers can be used sometimes similarly to symbols of filled
fields. The information just derived together with the 1 in S77 restricts possible positions
for filling a 1 in the bottom left block to S81 and S82 . Furthermore, the remaining fields
of the bottom middle block may only be filled with 6, ..., 9, possibly resulting in more
consequences.



                                              5
5 Solver Software-Architecture                                                         6


Figure 6 A number consuming example with S94 and S95 consuming the pair (1, 5).


                     7    6      1    3

                     2    8           7          9     3

                                                       7

                     6                           5

                                 9    4                           6

                                           3           8    2

                                           4           1    5

                                 6               2

                     9                                 6    7     8



The strategies introduced here are comfortably integrated in a software-architecture for
a Sudoku solver. The flexible approach makes the integration simple and it is open for
integrating new strategies. Section 3 has shown the importance with the huge amount
of possibilities that make backtracking costly.


5 Solver Software-Architecture
The section presents an object-oriented architecture for a Sudoku solver. A class
hierarchy is structuring the logical groups of the game, annotations provide a flexible
mechanism for rule-based game solving integrating Sudoku-specific strategies.
The solver architecture defines a hierarchy for groups and offers annotations for the
integration of strategies. Fields can be filled with numbers, groups represent fields that
belong to the same logical unit of the game. In particular, a block represents one of the
3 × 3 squares tiling the game. Rows and columns also represent groups. Each field is
associated with the groups it belongs to – a block, a row and a column. Vice versa, the
groups are associated with their fields. Furthermore, the groups are associated to the
groups they intersect.
Empty fields are annotated with possible numbers. Initially, the annotations get the



                                           6
6 Integrating AI Search Strategies                                                       7


numbers that aren’t in the groups of the field. Numbers that don’t occur in a group de-
fine annotations. The annotated group initially stores the empty fields. With constraints
of these annotations, fields can be filled as immediate consequence. In fields with one
possible number, the annotation left can be filled. When the group annotation for a
number leaves one field, the number may fill the gap.
For filling fields, the annotations are updated. Filling a number generates notifications,
the change at a position informs depending fields and groups. In that block, row and
column the number can’t occur again, there are fewer possible numbers. The anno-
tations of the fields in these groups are updated. Depending groups get notifications.
In this way, a generalization of the scanning strategy presented in section 2 is imple-
mented. Depending groups are defined having a non-empty intersection with a group of
the considered field. For example, filling a 1 in the top left field notifies some depending
groups. The first row intersects the top middle and right block – they can fill the only 1 in
the rows two and three. In addition, row one is intersecting the first field of all columns.
The first column intersects all rows and restricts the left middle and bottom blocks to the
columns two and three. Finally, the top left block removes the first three fields from the
group annotations of the first three columns and rows.
The annotations provide a flexible mechanism for integrating the Sudoku-specific strate-
gies presented in section 4. For instance, when the top left block restricts the 1 to the
first column, the blocks below are notified in the same way. Fields consuming con-
straints like exclusive pairs can have the same side-effect. Finding these constraints
always generates notifications within the groups the constraint shares. The field anno-
tations remove the numbers of such a pair, for example.
When no rules apply, the solver uses backtracking for searching a solution. The object-
oriented architecture and the annotations of this section are integrated in the intelligent
search that the next section is presenting.


6 Integrating AI Search Strategies
As section 3 has been showing, the huge amount of possibilities can cause consider-
able costs and so a simple scanning approach and advanced Sudoku-specific strate-
gies have been introduced in the sections 2 and 4. The previous section has integrated
the strategies in a rule-based solver using annotations for fields and groups. When no
rule can be applied, the solver is starting a backtracking search that is presented in this
section. The annotations can be used for optimizing the search.
The solver stores the progress for a Sudoku instance. A history remembers the fields
that are filled and the changes that are computed for the annotations. Logging the steps
is supporting an optimized backtracking search. When no rule or strategy can be ap-




                                            7
6 Integrating AI Search Strategies                                                        8


plied, the solver is introducing a choice-point and is starting a search. Occassionally
choosing a field and a number can be wrong, a guess can cause a clash. Each time
after filling further fields, the solver is checking clashes. Empty fields must have non-
empty annotations that suggest possible numbers for filling. Numbers that don’t occur
in a group may not have empty annotations in that particular group. Such numbers are
then missing in the group that can’t form a solution anymore. Checking clashes can be
limited to changes of annotations.
The backtracking is integrating the annotations. The solver makes a guess and then
continues with rule-based solving. New choice-points can be introduced and clashes
revise a guess. A choice-point is choosing a number for a field or the place for a number
within a group. The annotations decrease the considered possibilities and can be used
to optimize the decisions regarding the basis of a choicepoint. Furthermore, the history
is reducing the required resources storing the changes that can simply be undone. A
choice-point stores the parent state and the history for reaching a descendant. When
breadth-first search is desired, the ways to other choice-points can also be logged. The
choice-point stores the possible choices within its basis and the choices that can al-
ready be disregarded. A field is determined, if only one possibility is left. One more
clash propagates the change to the parent.
The approach offers policies for the parametrized search. The standard depth-first
search method can be replaced with breadth-first search and the approach is open for
further strategies. Choosing the basis for a choice-point is using annotations. For exam-
ple, a test would like to give high priority to choice-points with group annotations storing
two or three fields for a certain number. Another test might prefer field annotations
providing few possible numbers for filling the gap. The solver is open for fine-tuning in
accordance with the software-architecture presented in section 5. Finally, the parameter
can be optimized with statistical methods. Further methods of artificial intelligence can
be utilized for optimizing the solver. Training with Sudoku instances is very promising
for finding the best basis for the choice-point and for at fastest finding the solution.




                                             8

Mais conteúdo relacionado

Mais procurados

KMP Pattern Matching algorithm
KMP Pattern Matching algorithmKMP Pattern Matching algorithm
KMP Pattern Matching algorithmKamal Nayan
 
Conventional Encryption NS2
Conventional Encryption NS2Conventional Encryption NS2
Conventional Encryption NS2koolkampus
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve CryptographyJorgeVillamarin5
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Hasanain Alshadoodee
 
Particle Swarm Optimization.pptx
Particle Swarm Optimization.pptxParticle Swarm Optimization.pptx
Particle Swarm Optimization.pptxNatiTilahun1
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common SubsequenceKrishma Parekh
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 
cryptography Application of linear algebra
cryptography Application of linear algebra cryptography Application of linear algebra
cryptography Application of linear algebra Sami Ullah
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithmgsp1294
 
Discrete Mathematics in Real Life ppt.pdf
Discrete Mathematics in Real Life ppt.pdfDiscrete Mathematics in Real Life ppt.pdf
Discrete Mathematics in Real Life ppt.pdfrushikeshchaudhari43
 
4 informed-search
4 informed-search4 informed-search
4 informed-searchMhd Sb
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Treezhaokatherine
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithmfaisal2204
 
RNN and its applications
RNN and its applicationsRNN and its applications
RNN and its applicationsSungjoon Choi
 
Neural Turing Machines
Neural Turing MachinesNeural Turing Machines
Neural Turing MachinesIlya Kuzovkin
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graphumair khan
 
Permutations and Combinations (All Formulas)
Permutations and Combinations (All Formulas)Permutations and Combinations (All Formulas)
Permutations and Combinations (All Formulas)Anubhav Kumar
 

Mais procurados (20)

KMP Pattern Matching algorithm
KMP Pattern Matching algorithmKMP Pattern Matching algorithm
KMP Pattern Matching algorithm
 
Chinese remainder theorem
Chinese remainder theoremChinese remainder theorem
Chinese remainder theorem
 
Conventional Encryption NS2
Conventional Encryption NS2Conventional Encryption NS2
Conventional Encryption NS2
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking 
 
Particle Swarm Optimization.pptx
Particle Swarm Optimization.pptxParticle Swarm Optimization.pptx
Particle Swarm Optimization.pptx
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
cryptography Application of linear algebra
cryptography Application of linear algebra cryptography Application of linear algebra
cryptography Application of linear algebra
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithm
 
Discrete Mathematics in Real Life ppt.pdf
Discrete Mathematics in Real Life ppt.pdfDiscrete Mathematics in Real Life ppt.pdf
Discrete Mathematics in Real Life ppt.pdf
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
4 informed-search
4 informed-search4 informed-search
4 informed-search
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
 
RNN and its applications
RNN and its applicationsRNN and its applications
RNN and its applications
 
Neural Turing Machines
Neural Turing MachinesNeural Turing Machines
Neural Turing Machines
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graph
 
Permutations and Combinations (All Formulas)
Permutations and Combinations (All Formulas)Permutations and Combinations (All Formulas)
Permutations and Combinations (All Formulas)
 
Chap4
Chap4Chap4
Chap4
 

Destaque

Presentation - Sudoku Assignment
Presentation - Sudoku  AssignmentPresentation - Sudoku  Assignment
Presentation - Sudoku AssignmentCj Uni
 
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Fernando Rodrigues Junior
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
The Sudoku Cipher
The Sudoku Cipher The Sudoku Cipher
The Sudoku Cipher Nefeli Zikou
 
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์Thira Woratanarat
 
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9ทอง บุญยศ
 
Clinical Practice Guideline for Dementia 2008
Clinical Practice Guideline for Dementia 2008Clinical Practice Guideline for Dementia 2008
Clinical Practice Guideline for Dementia 2008Utai Sukviwatsirikul
 
L1 Sudoku
L1 SudokuL1 Sudoku
L1 Sudokubnmoran
 
ซูโดกุ สสวท
ซูโดกุ สสวทซูโดกุ สสวท
ซูโดกุ สสวทNat Krub
 
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557Utai Sukviwatsirikul
 
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพ
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพการทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพ
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพThira Woratanarat
 
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานี
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานีคู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานี
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานีtopsaby99
 
Sudoku powerpoint
Sudoku powerpointSudoku powerpoint
Sudoku powerpointunion40
 

Destaque (20)

Sudoku
SudokuSudoku
Sudoku
 
Sudoku
SudokuSudoku
Sudoku
 
Sudoku
SudokuSudoku
Sudoku
 
Presentation - Sudoku Assignment
Presentation - Sudoku  AssignmentPresentation - Sudoku  Assignment
Presentation - Sudoku Assignment
 
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
Breadth-First Search, Depth-First Search and Backtracking Depth-First Search ...
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
The Sudoku Cipher
The Sudoku Cipher The Sudoku Cipher
The Sudoku Cipher
 
Sudoku
SudokuSudoku
Sudoku
 
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์
บทเรียนการพัฒนาระบบเครือข่ายบริการทางการแพทย์
 
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9
การดูแลสุขภาพระยะยาวเขตบริการสุขภาพที่ 9
 
Sudoku puzzles
Sudoku puzzlesSudoku puzzles
Sudoku puzzles
 
Clinical Practice Guideline for Dementia 2008
Clinical Practice Guideline for Dementia 2008Clinical Practice Guideline for Dementia 2008
Clinical Practice Guideline for Dementia 2008
 
Sudoku valencia 2
Sudoku valencia  2Sudoku valencia  2
Sudoku valencia 2
 
L1 Sudoku
L1 SudokuL1 Sudoku
L1 Sudoku
 
ซูโดกุ สสวท
ซูโดกุ สสวทซูโดกุ สสวท
ซูโดกุ สสวท
 
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557
แนวทางเวชปฏิบัติภาวะสมองเสื่อม 2557
 
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพ
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพการทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพ
การทบทวนสถานการณ์และกลไกจัดการความแตกฉานด้านสุขภาพ
 
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานี
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานีคู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานี
คู่มือ การสื่อสารกับผู้ป่วยชาวต่างชาติ โรงพยาบาลนพรัตนราชธานี
 
Sudoku powerpoint
Sudoku powerpointSudoku powerpoint
Sudoku powerpoint
 
Cpg copd
Cpg copdCpg copd
Cpg copd
 

Semelhante a Sudoku Solving with Computational Intelligence

Solve Sudoku using Constraint Propagation- Search and Genetic Algorithm
Solve Sudoku using  Constraint Propagation- Search and Genetic AlgorithmSolve Sudoku using  Constraint Propagation- Search and Genetic Algorithm
Solve Sudoku using Constraint Propagation- Search and Genetic AlgorithmAi Sha
 
The sexagesimal foundation of mathematics
The sexagesimal foundation of mathematicsThe sexagesimal foundation of mathematics
The sexagesimal foundation of mathematicsMichielKarskens
 
GRADE 4 SESSION 4.pptx
GRADE 4 SESSION 4.pptxGRADE 4 SESSION 4.pptx
GRADE 4 SESSION 4.pptxLuisSalenga1
 
Andrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws
 
Exponents and radicals in Algebra
Exponents and radicals in AlgebraExponents and radicals in Algebra
Exponents and radicals in Algebraindianeducation
 
iGridd puzzles, Demo book
iGridd puzzles, Demo bookiGridd puzzles, Demo book
iGridd puzzles, Demo bookRastislav Rehak
 
Solving Multiple Square Jigsaw Puzzles with Missing Pieces
Solving Multiple Square Jigsaw Puzzles with Missing PiecesSolving Multiple Square Jigsaw Puzzles with Missing Pieces
Solving Multiple Square Jigsaw Puzzles with Missing PiecesGravitate Project
 
Presentation- How To Sudoku
Presentation- How To SudokuPresentation- How To Sudoku
Presentation- How To SudokuCj Uni
 
Module 1 answer key
Module 1 answer keyModule 1 answer key
Module 1 answer keyNRWEG3
 
Overview of sparse and low-rank matrix / tensor techniques
Overview of sparse and low-rank matrix / tensor techniques Overview of sparse and low-rank matrix / tensor techniques
Overview of sparse and low-rank matrix / tensor techniques Alexander Litvinenko
 
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...AyanRocks
 
FINAL DEFENCE
FINAL DEFENCEFINAL DEFENCE
FINAL DEFENCERahul KC
 
Precalculus 6th edition blitzer test bank
Precalculus 6th edition blitzer test bankPrecalculus 6th edition blitzer test bank
Precalculus 6th edition blitzer test bankSullivan001
 

Semelhante a Sudoku Solving with Computational Intelligence (20)

Solve Sudoku using Constraint Propagation- Search and Genetic Algorithm
Solve Sudoku using  Constraint Propagation- Search and Genetic AlgorithmSolve Sudoku using  Constraint Propagation- Search and Genetic Algorithm
Solve Sudoku using Constraint Propagation- Search and Genetic Algorithm
 
The sexagesimal foundation of mathematics
The sexagesimal foundation of mathematicsThe sexagesimal foundation of mathematics
The sexagesimal foundation of mathematics
 
Grade 10 tutorials
Grade 10 tutorialsGrade 10 tutorials
Grade 10 tutorials
 
Sudoku solve rmain
Sudoku solve rmainSudoku solve rmain
Sudoku solve rmain
 
GRADE 4 SESSION 4.pptx
GRADE 4 SESSION 4.pptxGRADE 4 SESSION 4.pptx
GRADE 4 SESSION 4.pptx
 
Andrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws - Final Project Report
Andrew Daws - Final Project Report
 
Z And T Tests
Z And T TestsZ And T Tests
Z And T Tests
 
Lattice multiplication
Lattice multiplicationLattice multiplication
Lattice multiplication
 
Exponents and radicals in Algebra
Exponents and radicals in AlgebraExponents and radicals in Algebra
Exponents and radicals in Algebra
 
iGridd puzzles, Demo book
iGridd puzzles, Demo bookiGridd puzzles, Demo book
iGridd puzzles, Demo book
 
[ACM-ICPC] Sort
[ACM-ICPC] Sort[ACM-ICPC] Sort
[ACM-ICPC] Sort
 
Solving Multiple Square Jigsaw Puzzles with Missing Pieces
Solving Multiple Square Jigsaw Puzzles with Missing PiecesSolving Multiple Square Jigsaw Puzzles with Missing Pieces
Solving Multiple Square Jigsaw Puzzles with Missing Pieces
 
Presentation- How To Sudoku
Presentation- How To SudokuPresentation- How To Sudoku
Presentation- How To Sudoku
 
L 12 give and take
L 12 give and takeL 12 give and take
L 12 give and take
 
Module 1 answer key
Module 1 answer keyModule 1 answer key
Module 1 answer key
 
Sudokureport
SudokureportSudokureport
Sudokureport
 
Overview of sparse and low-rank matrix / tensor techniques
Overview of sparse and low-rank matrix / tensor techniques Overview of sparse and low-rank matrix / tensor techniques
Overview of sparse and low-rank matrix / tensor techniques
 
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...
Dan Stefanica - A Primer for the Mathematics of Financial Engineering-FE Pres...
 
FINAL DEFENCE
FINAL DEFENCEFINAL DEFENCE
FINAL DEFENCE
 
Precalculus 6th edition blitzer test bank
Precalculus 6th edition blitzer test bankPrecalculus 6th edition blitzer test bank
Precalculus 6th edition blitzer test bank
 

Último

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

Sudoku Solving with Computational Intelligence

  • 1. Sudoku Solving with Computational Intelligence Dr. Harald Hiss June 30, 2010
  • 2. Summary Computers can create convincing results – the cinemas are presenting the latest overwhelming 3D multimedia spectacles. The results and benefits aren’t restricted to the amusement and movies, modern methods for our machines bring further considerable improvements to reality. Programs and algorithms evolve in bioinformatics and public health. Computational intel- ligence can also be utilized in solving brainteasing tasks. This article is presenting a computational intelligence approach for solving Sudoku brain- teasers. A scanning strategy introduces Sudoku and solves the first example. The article presents an estimation of the complexity with stochastic methods. Sudoku-specific advanced strategies refine the scanning technique from the introduction. A software-architecture for efficiently implementing a rule- based solver is integrating the strategies and is using annotations that are updated with notifications. When no rule can be applied, a backtracking search is started. The parametrized solver offers policies for searching. A logging mechanism is presented supporting the search saving memory for the efficient implementation. The author, Dr. Harald Hiss, has obtained the diploma in software-engineering in 2004 and he has graduated in databases in 2008 at the university of Freiburg supported by the interdisciplinary graduate programme logic and applications. This article is presenting a new Sudoku solver that performs best. The computer scientist is presenting Sudoku-specific strategies and a solver architecture for the fast and simple implementation using the latest technologies.
  • 3. Contents 1 Solving Sudoku with Computational Intelligence 1 2 Sudoku and a Scanning Strategy 1 3 Possibilities Estimation 3 4 Sudoku-specific Strategies and Techniques 4 5 Solver Software-Architecture 6 6 Integrating AI Search Strategies 7
  • 4. 2 Sudoku and a Scanning Strategy 1 1 Solving Sudoku with Computational Intelligence Computers can create convincing results – the cinemas are presenting the latest over- whelming 3D multimedia spectacles. The results and benefits aren’t restricted to the amusement and movies, modern methods for our machines bring further consider- able improvements to reality. Programs and algorithms evolve in bioinformatics and public health. Computational intelligence can also be utilized in solving brainteasing tasks. This article is presenting a computational intelligence approach for solving Su- doku brainteasers. The example is illustrating specific game strategies, estimating the complexity and again proving both power and expressiveness of computational intelli- gence. At the turn of the millenium, the number puzzle became very popular. The enjoyable quest for filling numbers in fields comes in some variants and difficulty levels. Simple Sudokus can be solved very fast, the next chapter introduces a scanning strategy that is sufficient for automatically solving a first example. After the description, an estimation of the complexity is given with stochastic methods showing a huge amount of possibilities that a solver has to face. For the development of an automatic solver, some advanced strategies are presented. The aspects are integrated in a flexible software-architecture that can be easily adapted to Sudoku variants. Finally, the strategies are integrated with the architecture. Computational intelligence extracts information for choosing the appropriate rules to fill the next field and for choosing optimal fields and numbers for backtracking when no rule applies. The article presents an approach in computational intelligence for Sudoku. The con- venient example is illustrating many aspects of computational intelligence. The num- ber quest is formalized, stochastical methods estimate the possibilities, the specific advanced strategies integrate with the software architecture and a rule-based logical system. Methods from artificial intelligence and learning optimize the search choosing the right fields and numbers – a very promising approach for constructing a success- ful Sudoku solver with computational intelligence. The author has acquired very much knowledge in this field. The huge power of computational intelligence can impressively be shown with the Sudoku example presented in this article. 2 Sudoku and a Scanning Strategy The challenge of Sudoku is posed in filling fields with fitting numbers so that some number constraints are satisfied. The fields are arranged in groups. Within a group, only numbers of a defined domain may be inserted. Numbers may not occur more than once in a group. Solutions have filled all fields so that each number occurs exactly 1
  • 5. 2 Sudoku and a Scanning Strategy 2 once in each group. The standard Sudoku variant considers a 9 × 9 array of fields and defines the domain 1, 2, ..., 9 for the numbers. As groups, the number puzzle considers rows, columns and the 9 blocks formed of the 3 × 3 squares that are tiling the game. The constraints have to be satisfied for each group. For instance, a row can contain numbers in 1, 2, ..., 9 and a row of a solution represents a permutation of the domain. The section shows a simple scanning strategy for solving some Sudokus. Figure 1 Figure 1 An easy Sudoku example. 1 2 5 9 4 4 3 6 1 5 5 1 3 1 2 5 7 2 6 9 3 3 4 2 7 1 3 6 7 1 9 7 1 4 2 8 8 5 9 7 presents the example that is illustrating the strategy. For the numbers of the domain, the rows and columns are scanned to find the appropriate field in a block. The scan starts with 1. The second field of the first row, abbreviated with S12 , has a 1. In the block below, the field S41 stores this number. The first two columns may not contain the number anymore, the left bottom block has the 1 in S73 or S93 . Then the scan considers the relevant rows for the bottom block. The seventh row has a 1 in S77 , the 1 can be filled in S93 . Using scans and filling obvious fields the solution in figure 2 is obtained. The next section estimates the amount of possible games. Then again the article turns to solving strategies and presents some advanced techniques. 2
  • 6. 3 Possibilities Estimation 3 Figure 2 The solution for the previous example. 6 1 3 2 7 5 9 8 4 9 2 8 4 3 6 7 1 5 4 7 5 9 1 8 6 3 2 1 3 9 7 8 2 5 4 6 7 4 2 6 5 1 8 9 3 8 5 6 3 4 9 2 7 1 3 6 4 8 2 7 1 5 9 5 9 7 1 6 4 3 2 8 2 8 1 5 9 3 4 6 7 3 Possibilities Estimation A first naive estimation of the possibilities for choosing the numbers in the 9 × 9 square considers filling each field with any number. The 981 combinations compute a total of 1.966 · 1077 . The first improvement considers the symbols that have been inserted previously in the same row. For nine rows, 9!9 combinations are obtained, a total of 1.091 · 1050 . Taking into account more information considering relevant blocks the num- ber can be improved to 1.528 · 1031 . The huge amount suggests to invest some time in software design considerations and to integrate both efficient game-specific strate- gies and intelligent computational methods instead of implementing a trial-and-error program. The following sections are going to present an efficient approach for the de- velopment of an automatic solver. The final estimation presented in this section is considering sequentially filling numbers, from the left to the right and from the top to the bottom. The estimation uses the max- imal restriction that is available in the context of the focussed field. The maximum of the present numbers in the same row, column or block reduces the possible choice. Figure 3 shows the result. The field in line 5, column 4 is regarding the numbers above and to the left. In the same line, three numbers have been inserted. The column has four numbers, and the middle block three. The column offers the maximal restriction of 3
  • 7. 4 Sudoku-specific Strategies and Techniques 4 Figure 3 Possibilities for choosing a number for a field starting at the top-left corner continuing from the left to the right and downward. 9 8 7 6 5 4 3 2 1 6 5 4 6 5 4 3 2 1 3 2 1 3 2 1 3 2 1 6 6 6 6 5 4 3 2 1 5 5 4 5 5 4 3 2 1 3 2 1 3 2 1 3 2 1 3 3 3 3 3 3 3 2 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 four different numbers. At most five numbers remain for choosing, the possibilities are inserted in the field. With this approach, an estimation of 9! · 6!6 · 3!10 · 5 is obtained. The number of possible valid Sudoku instances can be bound with 1.528 · 1031 . Another aspect of Sudoku brainteasing is presented in figure 3. The last column and the bottom row have one possibility left for each field. Often, many fields are still empty although the game has been solved. Some clean-up work completes a Sudoku game filling num- bers in fields that are restricted already having 8 numbers in the same group. The next section is showing some improvements for the simple scanning solver in- troduced at the beginning and is presenting advanced Sudoku-specific strategies and techniques. 4 Sudoku-specific Strategies and Techniques Easy instances can be solved with simple strategies as shown in section 2. For each number, the possible positions within a block have been scanned excluding correspond- ing rows and columns in the blocks of the same column and row. Obvious fields remain- ing as the single gap in a group can be filled. For each field, the numbers of all groups 4
  • 8. 4 Sudoku-specific Strategies and Techniques 5 it belongs to can be removed from the candidates. Again, if one number is left the gap can be filled. This section is considering advanced strategies for more complex Sudoku solving. Side-effects of groups can be used for improving the scanning approach presented in Figure 4 First lines of the example for the improvement. 1 1 1 1 1 8 9 2 3 4 section 2. Some group restrictions suffice to determine fields in depending groups. Fig- ure 4 shows an example, the possible positions for a 1 in the middle block have blue entries. The Information that the middle block has the 1 in the middle row suffices for filling a 1 in S31 . In this way, the 1 in the first block is restricted to the two bottom fields when the middle and last block share the 1 in the first two rows as shown in figure 5. The section presents a strategy that is not necessarily needed to solve the example of Figure 5 A variant of the improvement. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 2 3 4 5 6 7 the introduction. The last row of the instance shown in figure 6 contains 9, 6, 7 and 8. Other fields in this row can be filled with 1, ..., 5. The bottom middle block contains 4, 2 and is restricting its bottom row to 1, 3, 5. Considering columns is proving S94 , S95 ∈ {1, 5} and S96 ∈ {1, 3}. The constraints for S94 and S95 consume 1 and 5, the three fills S96 . Constraints consuming numbers can be used sometimes similarly to symbols of filled fields. The information just derived together with the 1 in S77 restricts possible positions for filling a 1 in the bottom left block to S81 and S82 . Furthermore, the remaining fields of the bottom middle block may only be filled with 6, ..., 9, possibly resulting in more consequences. 5
  • 9. 5 Solver Software-Architecture 6 Figure 6 A number consuming example with S94 and S95 consuming the pair (1, 5). 7 6 1 3 2 8 7 9 3 7 6 5 9 4 6 3 8 2 4 1 5 6 2 9 6 7 8 The strategies introduced here are comfortably integrated in a software-architecture for a Sudoku solver. The flexible approach makes the integration simple and it is open for integrating new strategies. Section 3 has shown the importance with the huge amount of possibilities that make backtracking costly. 5 Solver Software-Architecture The section presents an object-oriented architecture for a Sudoku solver. A class hierarchy is structuring the logical groups of the game, annotations provide a flexible mechanism for rule-based game solving integrating Sudoku-specific strategies. The solver architecture defines a hierarchy for groups and offers annotations for the integration of strategies. Fields can be filled with numbers, groups represent fields that belong to the same logical unit of the game. In particular, a block represents one of the 3 × 3 squares tiling the game. Rows and columns also represent groups. Each field is associated with the groups it belongs to – a block, a row and a column. Vice versa, the groups are associated with their fields. Furthermore, the groups are associated to the groups they intersect. Empty fields are annotated with possible numbers. Initially, the annotations get the 6
  • 10. 6 Integrating AI Search Strategies 7 numbers that aren’t in the groups of the field. Numbers that don’t occur in a group de- fine annotations. The annotated group initially stores the empty fields. With constraints of these annotations, fields can be filled as immediate consequence. In fields with one possible number, the annotation left can be filled. When the group annotation for a number leaves one field, the number may fill the gap. For filling fields, the annotations are updated. Filling a number generates notifications, the change at a position informs depending fields and groups. In that block, row and column the number can’t occur again, there are fewer possible numbers. The anno- tations of the fields in these groups are updated. Depending groups get notifications. In this way, a generalization of the scanning strategy presented in section 2 is imple- mented. Depending groups are defined having a non-empty intersection with a group of the considered field. For example, filling a 1 in the top left field notifies some depending groups. The first row intersects the top middle and right block – they can fill the only 1 in the rows two and three. In addition, row one is intersecting the first field of all columns. The first column intersects all rows and restricts the left middle and bottom blocks to the columns two and three. Finally, the top left block removes the first three fields from the group annotations of the first three columns and rows. The annotations provide a flexible mechanism for integrating the Sudoku-specific strate- gies presented in section 4. For instance, when the top left block restricts the 1 to the first column, the blocks below are notified in the same way. Fields consuming con- straints like exclusive pairs can have the same side-effect. Finding these constraints always generates notifications within the groups the constraint shares. The field anno- tations remove the numbers of such a pair, for example. When no rules apply, the solver uses backtracking for searching a solution. The object- oriented architecture and the annotations of this section are integrated in the intelligent search that the next section is presenting. 6 Integrating AI Search Strategies As section 3 has been showing, the huge amount of possibilities can cause consider- able costs and so a simple scanning approach and advanced Sudoku-specific strate- gies have been introduced in the sections 2 and 4. The previous section has integrated the strategies in a rule-based solver using annotations for fields and groups. When no rule can be applied, the solver is starting a backtracking search that is presented in this section. The annotations can be used for optimizing the search. The solver stores the progress for a Sudoku instance. A history remembers the fields that are filled and the changes that are computed for the annotations. Logging the steps is supporting an optimized backtracking search. When no rule or strategy can be ap- 7
  • 11. 6 Integrating AI Search Strategies 8 plied, the solver is introducing a choice-point and is starting a search. Occassionally choosing a field and a number can be wrong, a guess can cause a clash. Each time after filling further fields, the solver is checking clashes. Empty fields must have non- empty annotations that suggest possible numbers for filling. Numbers that don’t occur in a group may not have empty annotations in that particular group. Such numbers are then missing in the group that can’t form a solution anymore. Checking clashes can be limited to changes of annotations. The backtracking is integrating the annotations. The solver makes a guess and then continues with rule-based solving. New choice-points can be introduced and clashes revise a guess. A choice-point is choosing a number for a field or the place for a number within a group. The annotations decrease the considered possibilities and can be used to optimize the decisions regarding the basis of a choicepoint. Furthermore, the history is reducing the required resources storing the changes that can simply be undone. A choice-point stores the parent state and the history for reaching a descendant. When breadth-first search is desired, the ways to other choice-points can also be logged. The choice-point stores the possible choices within its basis and the choices that can al- ready be disregarded. A field is determined, if only one possibility is left. One more clash propagates the change to the parent. The approach offers policies for the parametrized search. The standard depth-first search method can be replaced with breadth-first search and the approach is open for further strategies. Choosing the basis for a choice-point is using annotations. For exam- ple, a test would like to give high priority to choice-points with group annotations storing two or three fields for a certain number. Another test might prefer field annotations providing few possible numbers for filling the gap. The solver is open for fine-tuning in accordance with the software-architecture presented in section 5. Finally, the parameter can be optimized with statistical methods. Further methods of artificial intelligence can be utilized for optimizing the solver. Training with Sudoku instances is very promising for finding the best basis for the choice-point and for at fastest finding the solution. 8