"Paint-By-Number" is one of many names for a type of graphical logic puzzle originating in Japan. Other common names for these puzzles are Nonograms, Griddlers, Hanjie, and Picross. The puzzles consist of a blank grid with numbers along the top and one side. The numbers tell the sizes of the blocks of the foreground color in that row and column. To solve the puzzle, you must reconstruct the image by figuring out how the color blocks must be place in each row and column.
One place to find examples of these puzzles is at my web site, webpbn.com. Many other sites provide puzzles to solve on-line (e.g., griddlers.net) and various books and magazines publish these puzzles regularly. Quite a few people have also written programs that allow puzzles to be solved on a home computer or a PDA, and various other people have written programs to solve puzzles automatically. Steve Simpson's Nonogram site includes a good collection of links to paint-by-number resources.
In surveying these, I noticed a lack of a good, standardized file format for paint-by-number puzzles. Every program seems to invent it's own file format. So I decided to come up with an XML file format that would be rich enough to handle most puzzle-storing applications.
I offer this with some trepedation, as XML formats are typically the subject of endless bickering, and I have very little experience with designing them, but I think this is OK and I presume future versions will be better.
The present format has the following charms to recommend it:
<?xml version="1.0"?>
<!DOCTYPE pbn SYSTEM "http://webpbn.com/pbn-0.1.dtd">
<puzzleset>
<puzzle type="grid" defaultcolor="black">
<title>Sample Puzzle</title>
<author>Jan Wolter</author>
<copyright>© 2004 by Jan Wolter</copyright>
<source>webpbn.com</source>
<id>#1</id>
<description>
A dancing stick figure man.
</description>
<color name="white" char=".">fff</color>
<color name="black" char="X">000</color>
<clues type="columns">
<line><count>2</count><count>1</count></line>
<line><count>2</count><count>1</count><count>3</count></line>
<line><count>7</count></line>
<line><count>1</count><count>3</count></line>
<line><count>2</count><count>1</count></line>
</clues>
<clues type="rows">
<line><count>2</count></line>
<line><count>2</count><count>1</count></line>
<line><count>1</count><count>1</count></line>
<line><count>3</count></line>
<line><count>1</count><count>1</count></line>
<line><count>1</count><count>1</count></line>
<line><count>2</count></line>
<line><count>1</count><count>1</count></line>
<line><count>1</count><count>2</count></line>
<line><count>2</count></line>
</clue>
<solution type="goal">
<image>
|.XX..|
|.XX.X|
|..X.X|
|.XXX.|
|X.X..|
|X.X..|
|..XX.|
|.X.X.|
|.X.XX|
|XX...|
</image>
</solution>
</puzzle>
</puzzleset>
The character entities that may appear in the file are are identical to those that may be used in HTML files.
The following tags appear in the document:
The content of the color tag is a color value, typically an RGB color code. This is usually a 3 or 6-digit hexadecimal number, like "3cc" or "210fbe". A three digit string like "123" is equavalent to the six digit string "112233".
For puzzles with triangles, the value can contain two hexadecimal color codes, separated by a "/" or "\", like "000/fff" or "ffffff\000000".
Two color names are predefined. (Because of this, the color declarations in the sample are redundant and could be omitted.)
Any other color used in the puzzle must be defined by a <color> tag.
Name Value Char black 000 X white fff .
For a puzzle of type "triddler" we expect to see six sets of clues, with types "top", "topright", "bottomright", "bottom", "bottomleft" and "topleft". This labeling assumes that the puzzle is oriented so that there are horizontal lines separating cells, but not vertical cells, and that the horizontal clues are at the left of the puzzle, like this:
/ / 2 /
/ 3 / 1 /
___ ________ 3 /
1 1 1 /\ /\ /\ /
___ /__\/__\/__\
2 3 /\ /\ /\ /
___ /__\/ _\/__\/ \
1 \ /\ /\ / 2
___ \/__\/__\/ \
3 \
\ 1 \ 2 \
\ \ 1 \
The "topleft" and "bottomleft" clues are clues for horizontal rows of
cells above and below the bend on the left side of the puzzle.
The "top" and "topright" clues are for lines in the / direction. The
"bottom" and "bottomright" clues are for lines in the \ direction.
The puzzle above would be represented like:
<clues type="topleft">
<line><count>1</count><count>1</count><count>1</count></line>
<line><count>2</count><count>3</count></line>
</clues>
<clues type="bottomleft">
<line><count>1</count></line>
</clues>
<clues type="top">
<line><count>3</count></line>
<line><count>2</count><count>1</count></line>
</clues>
<clues type="topright">
<line><count>3</count></line>
</clues>
<clues type="bottom">
<line><count>1</count></line>
<line><count>2</count><count>1</count></line>
</clues>
<clues type="bottomright">
<line><count>3</count></line>
<line><count>2</count></line>
</clues>
Solutions may also have an "id=" attribute, which can be used to label particular solutions. They can contain <image> and <note> tags.
The latter two forms are acceptable only in type="saved" puzzles, not in type="goal" or type="solution" puzzles.
Probably to be really XMLy, there should be some fancy substructure to this tag, but I felt it was simpler just to have it contain an image of the puzzle.
For grid type puzzles, the solution is given row-by-row. Each row starts and ends with a | character. There may be line-feeds separating the rows, but there need not be. The solution in the sample above could equally well be given as:
<solution type="goal">
<image>
|.XX..||.XX.X||..X.X||.XXX.||X.X..||X.X..||..XX.||.X.X.||.X.XX||XX...|
</image>
</solution>
For triddlers the solution is also stored row-by-row, but the line
starting and line ending characters are / or \ depending on the slope
of the edge of the puzzle. Basically if the puzzle looks like this:
________ /\ B/\D /\ /A_\/C_\/E_\ /\G /\I /\K / /F_\/H_\/J_\/ \L /\ N/\ P/ \/_M\/_O\/then we save it like this (except, of course, that the letters are replaced by whatever symbol indicates the color for that cell):
/ABCDE\
/FGHIJK/
\LMNOP/