CS440/ECE448 Fall 2018

Assignment 3: CSP - Nonogram

Due date: Monday October 15th, 11:55pm

Created by Bryce Kille and Renxuan Wang based on Nonogram.

See the the main MP page for programming language requirements, policies about working in groups, submission procedures, etc. Also make sure you are familiar with the course policies on academic integrity, late submissions, etc.

Contents

Introduction and rules

Nonograms, also known as Picross or Griddlers, are picture logic puzzles in which cells in a grid must be filled or left blank according to numbers at the side of the grid to reveal a hidden picture. The numbers are a form of discrete tomography that measures how many unbroken lines of filled-in squares there are in any given row or column. For example, a clue of "4 8 3" would mean there are sets of four, eight, and three filled squares, in that order, with at least one blank square between successive groups. The following figure shows an example of the start state and goal state for one Nonogram instance. In this assignment, each puzzle in the basic part (excluding the extra credit part) only has one unique solution. Try to play the game here!

First, you need to formulate Nonogram as a CSP. In your report, give your definitions of variables, domains, and constraints. Next, with these in mind, implement your solution, includes any variable and value ordering heuristics that make sense for your formulation (which would probably include forward checking). In the report, describe your implementation and give a brief explanation of why you chose to use your particular combination of heuristics and inference techniques.

Your inputs will give you constraints as a numpy object, and you should return a 2D output of an array that satisfies the constraints. For this assignment, you will be autograded by your output. Your job is to implement the solve function in solve.py. The function should take in a set of constraints and output a 2D numpy array that satisfies the constraints. In order to run your code on an instance of a nonogram problem, we have provided a script nonogram.py which will load constraints and test your implementation of the solve function. We will soon also have a tool for viewing the 2D output array as well.

For each of the inputs below, please include a .npy file containing the solution to the input as well. Please also include the runtime for each in your report.

1. Smaller Inputs

In this part, you are required to solve the following puzzles. Your code will also be run on the given puzzles. Note that if your code run more than 15s on any of the puzzles, we will cut it off and you will not get points for that puzzle. We also withhold the right to take away points for solutions that are on the very slow end of the distribution.
  1. 10*5 puzzle
  2. 10*10 puzzle
  3. 10*10 puzzle
  4. 15*15 puzzle
  5. 15*15 puzzle

2. Bigger Inputs

In this part, you are required to solve the following puzzles. Although there is no requirement on the running time in this part, you may want to improve your implementation with a better inference technique or constraint propagation technique. Report your solution, attempted assignments, and running time as in the previous section. The solutions should be reported as part of a single compressed .zip/.tar file, containing the solutions to the puzzles below in the form of a numpy 2D array. For each example below with a filename of [FILENAME].npy, there should be a solution in the submitted .zip/.tar library with the name [FILENAME]_solution.npy.
  1. 14*25 puzzle
  2. 20*20 puzzle
  3. 35*25 puzzle

Extra Credit Suggestions

Extra credit will be awarded for completing the suggestions below. Notice, however, that the score for each MP is capped at 110%.

Provided Code Skeleton

We have provided
tar file and zip file. all the code to get you started on your MP. You will only have to modify solve.py.

Deliverables

Moodle submission instructions will be posted on the the main MP page. You will be uploading three files

  • Your report (pdf).
  • A .zip/.tar file of the discovered solutions to the bigger nonograms and/or colored nonograms. For each set of constraints [FILENAME].npy, you should include a solution named [FILENAME]_solution.npy in the compressed library, where the solution is the saved numpy 2D solution.
  • A copy of solve.py containing all your new code.
  • (Groups only) Statement of individual contribution.

The statement of individual contribution is a brief summary of which group member was responsible for which parts of the solution and submitted material. We reserve the right to contact group members individually to verify this information.

Report Checklist

Your report should briefly describe your implemented solution and fully answer the questions for every part of the assignment. Your description should focus on the most "interesting" aspects of your solution, i.e., any non-obvious implementation choices and parameter settings, and what you have found to be especially important for getting good performance. Feel free to include pseudocode or figures if they are needed to clarify your approach. Your report should be self-contained and it should (ideally) make it possible for us to understand your solution without having to run your source code.

WARNING: You will not get credit for any solutions that you have obtained, but not included in your report!

Your report must be a formatted pdf document. Pictures and example outputs should be incorporated into the document. Exception: items which are very large or unsuitable for inclusion in a pdf document (e.g. videos or animated gifs) may be put on the web and a URL included in your report.

For full credit, in addition to the algorithm descriptions, your report should include the runtimes of each of the given puzzles, as well as an idea on why the runtimes of puzzles of the same size differ.