Nonogram Solver Cs491b Software Design Prepared by : Irvin P. Bustos Buenrostro June 12, 2009 CALIFORNIA STATE UNIVERSITY LOS ANGELES Los Angeles, California
Background and overall objectives A Nonogram that is game that is known with other several games such as : paint by number, Picross. A Nonogram is a picture logic puzzle game where the main objective is to get a hidden picture at the end by following the rules that are placed on the top and to de side of the grid. The game is very simple to play basically the player must follow the rules to be able to start shading the inside of the grid The main objective of the project is basically a Nonogram solver and a graphical user interface(GUI) where the user can input the rules to get the final answer
Nonogram Solver The reason or the motivation to create a solver was basically was because as a Nonogram player sometimes when I a solve a puzzle there is the need to make sure that the answer I have was the correct one. And what it makes special this project and different than others is that uses constraint programming as the main approach. To be able to get the solver it is important to understand the way that the Nonogram is set up and how is played. Form there once we know how is done we can start developing and create the solver. But as we are going to see that those techniques are not necessary to be implement and look at other directions and see what is easier to implement.
How to Play The main rules of this game is basically to follow the rules/hints that are on the top and on the side of the grid. The Hints tells how many sequences they have to fit in that particular row or column. The Hints are read left to right on the rows and up to down in the columns and the sequences are applied in that order They should be at least of a blank space between each sequence A particular row or column can start with a blank space or not .
Playing Nonogram 5 3 3 3 5 5 3 3 3 5 5 3 3 3 5 X X 2,1 2,1 2,1 3,1 3,1 3,1 5 5 5 1,3 1,3 1,3 1,2 1,2 1,2
Constraint Programming It is know as the “Holy Grail” of programming. As Dr. Abbot suggested this particular logic game can be easily implement and be programmed using constraint programming since there is a logic in it and the constraints within the game need to be satisfied.
JaCoP JaCoP is a Java-based constraint solver. It is a library specialized on constraint programming, several different tools are available in this library. The need was to basically to get familiarized with the API to be able to understand the library and use those tools in such a way that the ideas or approach that I had creating the solver could be implemented.
Solution Approach The approach to make the solver was complicated at the beginning, but researching and looking at the work of other people that created Nonogram solver I realized that regular constraint was a critical part of the project to be able to implement the rules of the Nonogram. At the same time I had to create Automaton according the regular expressions to be able to implemented on JaCoP. It was very handy that JaCoP had a tool where the Automatons could be implement and that make the project easier. But learning the API was a challenge, but once I got familiarized everything came along smoothly.
Nonogram Solver GUI After I created the solver and it was working nice on the command line and I saw that the solver was coming up with the answers for Nonograms there was a need to create a Graphical User Interface where the hints of the Nonogram could be easy input to the program So the GUI was a critical part of the project to be able to have a interface where the user can input the rules and not to deal with the code it self.
Demonstration
Runs
Important implementation issues What it was sophisticated to implement my project was basically because of the usage of a constraint library. I had to got familiar with that library and be able to understand all the tools that were available. Another part of the project that is sophisticated is implementing the regular constraint and creating automatons with those regular constraint. Also satisfying the constraints of that the program should follow they had to be implemented perfectly or the program didn’t work. Sometimes I had to deal and change the code on the API to do what I wanted to do.
Future Additions? Some of the additions that can be added to this project are the following: Game interface Display all solutions (if applicable). 3d Nonogram Solver (Rittai Picross) or Solid Geometric Picross
Final words This class and this project provide me with great opportunities to implement and create something of my interest. It was a reinforcement to the knowledge acquired in the rest of the Computer Science classes, It provide me with the opportunity to research and learn/reinforce the knowledge. I also want to thank Dr. Abbott for not giving up on me and provide me with courage to done this project. Even when I said that it wasn’t possible he encourage me to prove my self wrong. One of my future job towards this project, is extend it and make the game interface. But more important I see a lot of potential creating the 3D Nonogram Solver which sounds challenging.
Reference http://upload.wikimedia.org/wikipedia/commons/6/64/Paint_by_numbers_Animation.gif http://jacop.cs.lth.se/img1.png http://www.wiiwii.tv/wp-content/uploads/2009/02/rittaipicross.jpg http://www.superblog.jp/mt/images/tetrical.jpg