220 likes | 338 Views
Paint-By-Numbers Puzzle. Chanwit Suebsureekul CS491B Spring 2006. Introduction. The black cells are hiding Find them! Use numbers as clues. The Rule. Each number represents the number of contiguous black cells, called a block There must be “ at least ” one space between blocks
E N D
Paint-By-Numbers Puzzle Chanwit Suebsureekul CS491B Spring 2006
Introduction • The black cells are hiding • Find them! • Use numbers as clues
The Rule • Each number represents the number of contiguous black cells, called a block • There must be “at least” one space between blocks • The blocks are in the same sequenceas the numbers
Motivation • Mario’s Picross • Can we make the computer think
Objective • Puzzle Solver • Game • Puzzle Editor • Edit by numbers • Edit by painting
Technology • J2SE 5.0 • Java Advanced Imaging (JAI) • Javagram
JAI • Advance Image Processing Original 64x64 Resized 20x20 Grayscale Monochrome • Support standard image file formats • BMP, GIF, JPEG, PNG, TIFF, etc.
Javagram • Created by Steven Simpson • Solve a puzzle one line at a time • LineSolver class • FastLineSolver • CompleteLineSolver
FastLineSolver • Use the “Pushing Technique” • Push to the left • Push to the right • Look for the overlap
FastLineSolver Example Push Push
CompleteLineSolver • Try all possibilities • Look for the overlap
FastLineSolverVSCompleteLineSolver • FastLineSolver is much faster • CompleteLineSolver guarantees the best result
Example FastLineSolver CompleteLineSolver
Javagram Deficiency (1) • A conflict
Javagram Deficiency (2) • Multiple solutions
Javagram Deficiency (3) • Not enough clue
Recursive Guessing Main Program Puzzle Javagram Recursive Guessing Solution
Guessing Technique • Pick a random unsolved cell • Make a guess • Continue solving puzzle • If conflict, rollback and change the guessed cell (wrong guess) • If not conflict, find the solution (right guess) • Still have to rollback and try another path
Summary • Paint by Numbers puzzle • JAI • Javagram • FastLineSolver • CompleteLineSolver • Recursive Guessing Technique