230 likes | 1.44k Views
KenKen Solver. Jason Neufeld. KenKen is a popular number placing puzzle game. It is often compared to Sudoku. Unlike Sudoku, subproblems are not always square and have a mathematical operation associated with them. What is KenKen ?. What is KenKen ?. What is KenKen ?. Python 2.x
E N D
KenKen Solver Jason Neufeld
KenKen is a popular number placing puzzle game. • It is often compared to Sudoku. • Unlike Sudoku, subproblems are not always square and have a mathematical operation associated with them. What is KenKen?
Python 2.x • Tkinter for cross-platform GUI • Numpy for multidimensional arrays Solver Implementation
Simple keyboard-based GUI. • Groups and operations can be entered quickly. • Multiple grid sizes are allowed. Interface Design
The solver is separated into two steps: • Pre-processing • Solution Search Solver Algorithm
Without any tree pruning, search sizes can be massive using depth-first search. • Examples: • A 4x4 puzzle, 8 subgroups, 5 possible number combinations (test cases) for each subgroup = 58, or 390,625. • A 9x9 puzzle, 35 subgroups, 5 test cases for each = 535, or ~2.91*1024. Pre-processing
Step 1: Ensure validity of entered board. • Step 2: Determined possible factors of each subgroup: • Equals operation requires only one square, and its only possible value is the total value. • Multiplication, Addition, Subtraction, and Division are all recursively solved for each possible valid combination. • Step 3: Discover conflicts between subgroups. This allows the search process to quickly prune invalid nodes later on. Pre-processing
Subgroups are ordered by their amount of test cases, from least to greatest. • Each subgroup, in order, loops through each of its tests. • Each test spawns a recursion for the next subgroup. • If a conflict is found, that node is pruned. • If a full solution is found, it is returned immediately. • If no solution, a null object is returned. Solution Search
80 puzzles were tested with this size breakdown: Performance Results
All puzzles which completed execution returned valid solutions. • Execution time increased exponentially with grid size. • Average solution time by grid size: Performance Results
Pre-processing made an immense improvement in the amount of nodes in the search tree: Performance Results
Large puzzles caused execution time to lengthen significantly. • 8x8 puzzles caused some delays, but some 9x9 puzzles timed out. • An improved algorithm reduced some delays, but a few tests still timed out. Problems
Add mouse-based GUI for general users. • Continue to work on solving heuristics to improve performance of larger puzzles. Further Improvements