An Efficient Approach to Solving Nonograms

A nonogram puzzle is played on a rectangular grid of pixels with clues given in the form of row and column constraints. The aim of solving a nonogram puzzle, an NP-complete problem, is to paint all the pixels of the grid in black and white while satisfying these constraints. This paper proposes an efficient approach to solving nonogram puzzles. We propose a fast dynamic programming (DP) method for line solving, whose time complexity in the worst case is O(kl) only, where the grid size is l×l and k is the average number of integers in one constraint, always smaller than l. In contrast, the time complexity for the best line-solving method in the past is O(kl2). We also propose some fully probing (FP) methods to solve more pixels before running backtracking. Our FP methods can solve more pixels than the method proposed by Batenburg and Kosters (before backtracking), while having a time complexity that is smaller than theirs by a factor of O(l). Most importantly, these FP methods provide useful guidance in choosing the next promising pixel to guess during backtracking. The proposed methods are incorporated into a fast nonogram solver, named LalaFrogKK. The program outperformed all the programs collected in webpbn.com, and also won both nonogram tournaments that were held at the 2011 Conference on Technologies and Applications of Artificial Intelligence (TAAI 2011, Taiwan). We expect that the proposed FP methods can also be applied to solving other puzzles efficiently.

[1]  I-Chen Wu,et al.  Nonogram Tournaments in TAAI 2011 , 2012, J. Int. Comput. Games Assoc..

[2]  Fahiem Bacchus,et al.  Dynamic Variable Ordering in CSPs , 1995, CP.

[3]  Richard Hamilton,et al.  Painting by Numbers , 2007 .

[4]  I-Chen Wu,et al.  THE 2010 TAAI COMPUTER-GAME TOURNAMENTS , 2011 .

[5]  Marc Gyssens,et al.  A unified theory of structural tractability for constraint satisfaction problems , 2008, J. Comput. Syst. Sci..

[6]  I-Chen Wu,et al.  Solving the Slitherlink Problem , 2012, 2012 Conference on Technologies and Applications of Artificial Intelligence.

[7]  I-Chen Wu,et al.  HAPPYNURI wins the Nurikabe Tournament , 2010 .

[8]  Ling-Hwei Chen,et al.  An efficient algorithm for solving nonograms , 2009, Applied Intelligence.

[9]  N. Ueda,et al.  NP-completeness Results for NONOGRAM via Parsimonious Reductions , 1996 .

[10]  Donald E. Knuth,et al.  Dancing links , 2000, cs/0011047.

[11]  Ronald L. Rivest,et al.  Introduction to Algorithms, 3rd Edition , 2009 .

[12]  Wouter Wiggers A comparison of a genetic algorithm and a depth first search algorithm applied to Japanese nonograms , 2004 .

[13]  Kees Joost Batenburg,et al.  Solving Nonograms by combining relaxations , 2009, Pattern Recognit..

[14]  I-Chen Wu,et al.  An Efficient Approach to Solving the Minimum Sudoku Problem , 2011, J. Int. Comput. Games Assoc..

[15]  Walter A. Kosters,et al.  Constructing Simple Nonograms of Varying Difficulty , 2010 .

[16]  Samuel Y. Edgerton Painting by numbers , 1997, Nature.

[17]  Kees Joost Batenburg A Network Flow Algorithm for Reconstructing Binary Images from Discrete X-rays , 2006, Journal of Mathematical Imaging and Vision.

[18]  Ronald L. Rivest,et al.  Introduction to Algorithms , 1990 .