43

Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

Embed Size (px)

Citation preview

Page 1: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014
Page 2: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

Sudoku Hands-on TrainingMasters Project Presentation

Yiqi Gao

March 19, 2014

Page 3: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

PROJECT MOTIVATION

• Passion for Sudoku

• Missing pages found on the flight to Mexico

• Thrill of building an expert system with user interface by integrating Clips with Java

Page 4: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

BACKGROUND

• Sudoku – 数独  sūdoku, Digit-single– Originally called Number

Place, is a logic-based, combinatorial number-placement puzzle

Page 5: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

BACKGROUND

• Sudoku– The objective is to fill the playing board

with digits so that each row, column and box contains all of the digits from 1 to 9.

– The same single integer can only appear once in each row, column or box

Page 6: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Objective– Part I: Show solution to a given Sudoku

puzzle step by step with detailed illustration– Part II: Introduce user interaction that could

tell whether user gives the answer by guessing or reasoning and only accept answers got by reasoning

Page 7: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Design Choice– Clips (Inference Engine): a public domain

software tool for building expert systems– Swing (User Interface): Java GUI widget

toolkit– Jess (IE & UI Interaction): a rule engine for

the Java platform, which is a superset of the CLIPS programming language

Page 8: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• User Interface

Checkerboard

Buttons

InfoBar

Page 9: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Quick Start with a built-in Sudoku puzzle

Page 10: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Initialize your own Sudoku puzzle

Page 11: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Try a number to check the correctness

Page 12: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Step to get a currently possible answer

Page 13: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Solve the puzzle immediately

Page 14: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION• Functions

– Clear the playing board

Page 15: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Difficulties & Solutions (Part I)– How to make the sequence of outcomes

more natural (close to the sequence when done by human) ?

– Declare different salience for rules

Page 16: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Difficulties & Solutions (Part I)– How to illustrate the reasoning for each

step on the playing board?– Trace the rules that make a cell have only

one possibility, color the related cells and give the reasoning

Page 17: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Difficulties & Solutions (Part II)– How to interact with user?– Take user input as an assertion of fact,

modify the rules to make the inference engine run again with the new fact and after checking the correctness, retract the fact

Page 18: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Difficulties & Solutions (Part II)– Sudoku is a constraint satisfaction

problem, and usually more than one cell is available at a point, thus choosing different cells makes different paths.

– However, inference engine could only get one path at a point

Page 19: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INTRODUCTION

• Difficulties & Solutions (Part II)– How to check the correctness if the cell is

not the first on the path?– Instead of a depth-first way of thinking,

keep the possibilities of the cells before they get to one, put them in a list, thus all the currently available cells are in the list until the inference engine has no rule to trigger, then compare the cell with the list

Page 20: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

PROJECT STRUCTURE

Page 21: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

PROJECT STRUCTURE

Captured from lecture notes of CAP 5635 Artificial Intelligence

• System Architecture:

Sudoku Rules & Patterns

Sudoku Problem

Sudoku Board

Page 22: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

EXPERT KNOWLEDGE

• Sudoku Rules– Each row, column and box contains all of

the digits from 1 to 9– The same single integer can only appear

once in each row, column and box

Page 23: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

EXPERT KNOWLEDGE

• Solving Patterns– Sole Candidate– Unique Candidate– Box and column /

Row Interaction– Box / Box

Interaction

http://www.kristanix.com/sudokuepic/sudoku-solving-techniques.php

Page 24: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

EXPERT KNOWLEDGE

• Solving Patterns– Naked

Subset – Hidden

subset

http://www.kristanix.com/sudokuepic/sudoku-solving-techniques.php

Page 25: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INFERENCE ENGINE

• Facts– Cell: 9×9 facts recording the information of

each cell and 20+ facts for the puzzle (box 0)

Page 26: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INFERENCE ENGINE

• Facts– Current: 1 fact recording current status and

currently available results

Page 27: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INFERENCE ENGINE

• Rules– Initialize puzzle: extract the (possibilities ?)

value from puzzle(20+ Cell facts) to board(9×9 Cell facts) and retract these facts after initialization so that there are always 9×9 Cell facts afterwards

Page 28: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

INFERENCE ENGINE

• Rules– All elimination rules: each time eliminate

only one number from a cell; if after elimination the cell has only one possibility, then keep that number so that the cell has two possibilities and put this cell and its value in the current results list, meanwhile trace the rules and related cells

Page 29: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

USER INTERFACE

• Sudoku Board– Board/Box/Cell– CardLayout

(JLabel/InputBox) for Cell

Page 30: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

USER INTERFACE

• Buttons & InfoBar– JButton– JLabel

Page 31: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

IE & UI INTERACTION

• Assert new facts for user input with Jess

• Get slot values from facts and show the information on User Interface after reorganization

Page 32: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

EXPECTED RESULTS

• Two Parts (Both Finished)– Part I: Show solution to a given Sudoku

puzzle step by step with detailed illustration

– Part II: Introduce user interaction that could tell whether the user gives the answer by guessing or reasoning and only accept answers got by reasoning

Page 33: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 34: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 35: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 36: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 37: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 38: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 39: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 40: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

RESULTS

Page 41: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

MAIN INNOVATIONS

• Teaching with detailed illustrations– Part I : Colored cells with reasoning

• Training rather than just teaching– Part II : Be able to tell whether the user

gets the answer by guessing or reasoning and only accept answers got by reasoning

Page 42: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014

PROJECT SUMMARY

• Sudoku teaching and training tool

• Clips and Java integration

• Expert system with GUI

• User interaction

Page 43: Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014