isudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris

Similar documents
ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

Spring 06 Assignment 2: Constraint Satisfaction Problems

On the Combination of Constraint Programming and Stochastic Search: The Sudoku Case

Techniques for Generating Sudoku Instances

A Novel Multistage Genetic Algorithm Approach for Solving Sudoku Puzzle

Rating and Generating Sudoku Puzzles Based On Constraint Satisfaction Problems

CSC 396 : Introduction to Artificial Intelligence

Spring 06 Assignment 2: Constraint Satisfaction Problems

A Retrievable Genetic Algorithm for Efficient Solving of Sudoku Puzzles Seyed Mehran Kazemi, Bahare Fatemi

Solving Sudoku Using Artificial Intelligence

Cracking the Sudoku: A Deterministic Approach

Automatically Generating Puzzle Problems with Varying Complexity

SudokuSplashZone. Overview 3

The puzzle Sudoku has become the passion

Investigation of Algorithmic Solutions of Sudoku Puzzles

Welcome to the Sudoku and Kakuro Help File.

Kenken For Teachers. Tom Davis January 8, Abstract

An improved strategy for solving Sudoku by sparse optimization methods

Comparing Methods for Solving Kuromasu Puzzles

An efficient algorithm for solving nonograms

Yet Another Organized Move towards Solving Sudoku Puzzle

BMT 2018 Combinatorics Test Solutions March 18, 2018

UN DOS TREZ Sudoku Competition. Puzzle Booklet for Preliminary Round. 19-Feb :45PM 75 minutes

Informatica Universiteit van Amsterdam. Performance optimization of Rush Hour board generation. Jelle van Dijk. June 8, Bachelor Informatica

10/5/2015. Constraint Satisfaction Problems. Example: Cryptarithmetic. Example: Map-coloring. Example: Map-coloring. Constraint Satisfaction Problems

WPF SUDOKU GP 2014 ROUND 2 WPF SUDOKU/PUZZLE GRAND PRIX Puzzle authors: Serbia. Organised by

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

The Mathematics Behind Sudoku Laura Olliverrie Based off research by Bertram Felgenhauer, Ed Russel and Frazer Jarvis. Abstract

Python for education: the exact cover problem

1 Introduction. 2 An Easy Start. KenKen. Charlotte Teachers Institute, 2015

of Nebraska - Lincoln

An Exploration of the Minimum Clue Sudoku Problem

SUDOKU X. Samples Document. by Andrew Stuart. Moderate

Sudoku Solvers. A Different Approach. DD143X Degree Project in Computer Science, First Level CSC KTH. Supervisor: Michael Minock

CMPT 310 Assignment 1

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Unit 12: Artificial Intelligence CS 101, Fall 2018

COMP3211 Project. Artificial Intelligence for Tron game. Group 7. Chiu Ka Wa ( ) Chun Wai Wong ( ) Ku Chun Kit ( )

This chapter gives you everything you

INTRODUCTION TO COMPUTER SCIENCE I PROJECT 6 Sudoku! Revision 2 [2010-May-04] 1

AI Plays Yun Nie (yunn), Wenqi Hou (wenqihou), Yicheng An (yicheng)

A B O U T T H E S E P U Z Z L E S

IN THIS ISSUE

LMI Monthly Test May 2010 Instruction Booklet

CS 229 Final Project: Using Reinforcement Learning to Play Othello

GET OVERLAPPED! Author: Huang Yi. Forum thread:

KenKen Strategies. Solution: To answer this, build the 6 6 table of values of the form ab 2 with a {1, 2, 3, 4, 5, 6}

A comparison of a genetic algorithm and a depth first search algorithm applied to Japanese nonograms

Topic 10 Recursive Backtracking

Fast Placement Optimization of Power Supply Pads

Selected Game Examples

6. Methods of Experimental Control. Chapter 6: Control Problems in Experimental Research

2048: An Autonomous Solver

KenKen Strategies 17+

Python for Education: The Exact Cover Problem

Take Control of Sudoku

Data Structure Analysis

Exploring Strategies to Generate and Solve Sudoku Grids. SUNY Oswego CSC 466 Spring '09 Theodore Trotz

: Principles of Automated Reasoning and Decision Making Midterm

Maze Solving Algorithms for Micro Mouse

Heuristics, and what to do if you don t know what to do. Carl Hultquist

Chapter 4 Heuristics & Local Search

The remarkably popular puzzle demonstrates man versus machine, backtraking and recursion, and the mathematics of symmetry.

GENERALIZATION: RANK ORDER FILTERS

Lecture 2. 1 Nondeterministic Communication Complexity

MASTER PROOFS through GAMES

1. Hex Tapa (12 points) 2. Hex Dominos (13 points)

Taking the Mystery Out of Sudoku Difficulty: An Oracular Model

WPF SUDOKU/PUZZLE GRAND PRIX 2014 WPF SUDOKU GP 2014 COMPETITION BOOKLET ROUND 4. Puzzle authors: Russia Andrey Bogdanov, Olga Leontieva.

Games and Adversarial Search II

Informed search algorithms. Chapter 3 (Based on Slides by Stuart Russell, Richard Korf, Subbarao Kambhampati, and UW-AI faculty)

Sudoku Solver Version: 2.5 Due Date: April 5 th 2013

Outline for today s lecture Informed Search Optimal informed search: A* (AIMA 3.5.2) Creating good heuristic functions Hill Climbing

COMP SCI 5401 FS2015 A Genetic Programming Approach for Ms. Pac-Man

Modelling Sudoku Puzzles as Block-world Problems

Comparing BFS, Genetic Algorithms, and the Arc-Constancy 3 Algorithm to solve N Queens and Cross Math

sudoku 16x16 454BB8EA3E376999F4F40AF890078C0E Sudoku 16x16 1 / 6

Colored Nonograms: An Integer Linear Programming Approach

Exercise 4 Exploring Population Change without Selection

CS188 Spring 2010 Section 3: Game Trees

Homework Assignment #1

Intro to Java Programming Project

Comp th February Due: 11:59pm, 25th February 2014

Solving Sudoku with Genetic Operations that Preserve Building Blocks

New Methods in Finding Binary Constant Weight Codes

CS 171, Intro to A.I. Midterm Exam Fall Quarter, 2016

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

CS-171, Intro to A.I. Mid-term Exam Winter Quarter, 2015

Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, :59pm

Modified Method of Generating Randomized Latin Squares

Chapter 5 Backtracking. The Backtracking Technique The n-queens Problem The Sum-of-Subsets Problem Graph Coloring The 0-1 Knapsack Problem

Written examination TIN175/DIT411, Introduction to Artificial Intelligence

Shuffled Complex Evolution

Standard Sudoku point. 1 point. P a g e 1

Lab 7: 3D Tic-Tac-Toe

WPF SUDOKU/PUZZLE GRAND PRIX 2014 WPFSUDOKU GP 2014 COMPETITIONBOOKLET ROUND6. Puzzle authors: Bulgaria Deyan Razsadov.

Game Theory and Randomized Algorithms

5CHAMPIONSHIP. Individual Round Puzzle Examples SUDOKU. th WORLD. from PHILADELPHIA. Lead Sponsor

You ve seen them played in coffee shops, on planes, and

DOWNLOAD OR READ : SUDOKU LARGE PRINT PUZZLE BOOK FOR ADULTS 200 MEDIUM PUZZLES PUZZLE BOOKS PLUS PDF EBOOK EPUB MOBI

Transcription:

isudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris

What is Sudoku? A logic-based puzzle game Heavily based in combinatorics Object: place the digits 1-9 in cells of a 9x9 grid (subdivided into 3x3 regions) such that no row, column, nor region of cells contains the digit more than once Initially given at least 17 clue numbers to work with Row 6 Region 1 Column 6

Example Sudoku Puzzle Given: Solution:

Formal Definition A formal definition of the problem of solving a Sudoku puzzle: Given an n n Sudoku grid, the Sudoku is successfully solved if: x N and i N, with x n and i n: j N (with j n) such that numberat(i, j) = x. ( For any given number x [between 1 and n] and row number i [between 1 and n], there is a column number j [between 1 and n] such that x can be found in row i, column j. ) x N and j N, with x n and j n: i N (with i n) such that numberat(i, j) = x. ( For any given number x and column number j, there is a row number i...) x N and r N, with x n and r n: i N (with i n) and j N (with j n) such that regionof(i,j) = r AND numberat(i,j) = x.

3 Algorithms for Solving a Sudoku Backtracking Dancing links Crook s Algorithm Generic Algorithm

Steps for the Backtracking Algorithm Iterate over the cells in the puzzle, and for each cell: 1. Place a number (in the case of a 9 9 grid) between 1 and 9 in that empty cell. 2. Check that the placed number does not violate any of the three constraints (duplicate number in its row, column, or region). 3. If any constraint is violated, backtrack and place the next greater number in the cell. 4. Repeat until all cells have been filled.

Results of Backtracking Algorithm Tested on 100 randomly-generated (online data source) Sudoku puzzles of varying difficulty Tested on 10 puzzles for each difficulty: easy, normal, and hard difficulty (for a total of 30 puzzles) Recorded runtime and # of iterations required for each solution, as well as the avg/min/max runtime across all solutions.

Backtracking Results for 100 Puzzles (runtimes) Total time taken Average time per puzzle Fastest solve (minimum time) Slowest solve (maximum time) 248.48 ms 2.48 ms 0.63 ms 14.31 ms

Backtracking Results for Easy, Normal, Hard Puzzles

Steps for Dancing Links Algorithm 1. Setup initial matrix with constraints, column headers, and node pointers directed to neighbors and their column headers 2. For a row satisfying a constraint, remove the column and the rows intersecting that column (ie covering a node/column) 3. If no solution is found, backtrack in the exact reverse order nodes were covered (ie uncover a node/column) 4. Continue covering until the solution to the constraints is found

Dancing Links Results for 100 Puzzles (runtimes) Total time taken Average time per puzzle Fastest solve (minimum time) Slowest solve (maximum time) 19.62 ms 0.1962 ms 0.1834 0.7952

Dancing Links Results for Easy, Normal, Hard Puzzles

Algorithm #3 - Crook s Algorithm Crook s Algorithm is a method to solve any sudoku puzzle using pen and paper. Determines what is possible in each cell by looking through all the possibilities, then crosses out as it test each value. Uses a preemptive sets of possible integers of the possibilities, and groups possible sets together for a solution.

Crook s continued

Steps for Crook s Algorithm 1. Mark up the cells ie. list of numbers that the cell may contain. 2. Look at each column, row and 3x3 box and break down into preemptive sets. Break down the sets and use Occupancy Theorm whenever possible. 3. Determine if puzzle is: Finished, not possible or next step. 4. Choose an empty cell and mark a number and color. Repeat step 2 until no more preemptive sets remain. 5. Go through the markup until you solve or determine as not possible.

Crook s Results for Easy, Medium, Hard Puzzles

Crook s Results for 100 Puzzles (Run time) Total time taken Average time per puzzle Fastest solve (minimum time) Slowest solve (maximum time) 231.64 ms 2.31 ms 0.74 ms 12.42 ms

Conclusions Based on our results, we conclude that Dancing Links will be the most efficient based on time constraints. This result matches with our initial estimate at the beginning of the project. The order of efficiency based on time(most efficient first): Backtracking Crook s Algorithm Dancing Links

Questions 1. Based on Crook s Algorithm, what is the difference between a preemptive set and a markup? A: Markup is the list of possible values for each cell. Preemptive set are numbers that are potential occupants of the cell and can be occupied by no other value. 2. What differentiates brute-force with backtracking from a complete brute-force algorithm for finding Sudoku solutions? A: Backtracking will check if the number can legally be placed in the cell. 3. How can one tell the difference between an easy and hard Sudoku Puzzle? A: The amount of conceptual moves needed to complete the puzzle 4. Does backtracking for solving Sudoku puzzles perform a breadth-first or depth-first search down the decision tree? A: Depth-first

Questions contn 5. What is one reason that causes the crook s algorithm to slow down during harder puzzles? A: The increase in blank spaces is one reason, because it has more cells to create the markup and preemptive sets on each one.

Genetic Algorithm A genetic algorithm is a metaheuristic algorithm inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms. 1. Create a population (vector) of random solutions 2. Pick a few solutions and sort them 3. Replace the worst solution with a new solution 4. Check if you have a new global best fitness, if so, store the solution. 5. If too many iterations go by without improvement, the entire population might be stuck in a local minimum. If so, kill the population and start over at 1. 6. Go to 2.