Update
This commit is contained in:
parent
494a57eaf9
commit
3d238884b9
17 changed files with 1891 additions and 1816 deletions
|
@ -6,7 +6,7 @@ Nonogram (so named after Non Ishida but known by various other names such as gri
|
|||
|
||||
{ Nonogram has a [free](free_software.md), [suckless](suckless.md) implementation in Simon Tatham's Portable Puzzle Collection under the name "pattern". ~drummyfish }
|
||||
|
||||
**Rules** are simple: we have a two dimensional grid, each square can be either black or white, initially all squares are white. The goal is to fill some squares black and so reveal a hidden picture according to clues given on the sides (usually left and top) of the grid. Each row and each column has a clue consisting of N numbers; each such clue says the lengths of continuous black-colored segments that are contained in that row/column, in that order, with at least one white square between them. For example a clue "2 3" under some column says the column from top to bottom will begin with a number (even zero) of white squares, then exactly two black squares will appear, then at least one white square and then exactly three black squares.
|
||||
**Rules** are simple: we have a two dimensional grid, each square can be either black or white, initially all squares are white (at least in the paper version, in computer implementations the squares may be gray, meaning unknown color). The goal is to fill some squares black and so reveal a hidden picture according to clues given on the sides (usually left and top) of the grid. Each row and each column has a clue consisting of N numbers; each such clue says the lengths of continuous black-colored segments that are contained in that row/column, in that order, with at least one white square between them. For example a clue "2 3" under some column says the column from top to bottom will begin with a number (even zero) of white squares, then exactly two black squares will appear, then at least one white square and then exactly three black squares.
|
||||
|
||||
The fact that **nonograms don't generally have a unique solution** is easy to see from a trivial example of a 2x2 grid with clue numbers 1 in each column and row: two possible solutions will satisfy these clues (a checkerboard pattern and its inversion). It appears (according to someone's 2022 master's thesis that focused solely on this problem) that deciding or even estimating the number of solutions of given nonogram is neither easy nor fast.
|
||||
|
||||
|
@ -32,6 +32,7 @@ While constructing clues from given picture is trivial, solving nonogram is **[N
|
|||
- Reasoning techniques can in many situations be applied to quickly find which squares will be colored, for example:
|
||||
- A single clue number in row/column that's bigger than half of the grid size means that some of the center squares have to be colored because there is an overlap of both extremes. This can be generalized to "an intersection of all possible configurations can be safely colored", i.e. consider all possibilities for a row/column and color the squares that are colored in all of them (and vice versa, if some square is NOT colored in all configurations, it can be marked as surely white).
|
||||
- Some clues only allow a single configuration, i.e. for example "3 4" in a row that's 8 squares wide can be filled right away. Do these first.
|
||||
- If in a row/column you have the very first (or last) square colored, you know it's the part of the first (or last) clue segment and there is only one way for it to fit, so you can fill it in. This can actually be utilized even if the colored square is just close to the edge.
|
||||
- ...
|
||||
- Marking squares that can no longer be colored helps greatly.
|
||||
- Naturally [brute force](brute_force.md) solution always exists, but remember it will be slow -- it may be used to solve smaller grids or help finish a partial solution. When implementing this don't naively try every single possible picture as you won't live long enough to see the solution (the number of possible pictures is 2^(number of squares)); a smarter idea might be to go row by row (or column by column; perhaps sometimes one may be faster than the other) and for each one only check all of its possible configurations while also taking into account the state of previously filled lines.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue