woob.capabilities.picross
¶
- class CapPicross[source]¶
Bases:
Capability
Capability for getting picross / nonogram puzzles and solving them.
- can_submit_picross_puzzle_solution = False¶
Set to True in your module if it is possible to submit solutions under at least some circumstances (e.g. being logged in).
- iter_picross_puzzles(solved_status)[source]¶
Iter available picross / nonogram puzzles.
- Return type
iter[
Picross
]
- get_picross_puzzle(puzzle_id)[source]¶
Get a picross / nonogram puzzle from its ID.
- Parameters
id (
str
) – ID of the puzzle- Return type
- Raises
- submit_picross_puzzle_solution(puzzle, solution)[source]¶
Submit a picross / nonogram puzzle solution.
- Parameters
puzzle (
Picross
) – The puzzle as gathered by the module.solution (
PicrossSolution
) – The puzzle solution.
- class Picross(id='', url=NotLoaded, backend=None)[source]¶
Bases:
BaseObject
Picross puzzle representation.
For example, take the following basic black and white puzzle:
1 1 3 3 2 3 X X X 2 1 X X X 2 X X 1 X 1 X
It is represented the following way:
lines = [(3,), (2, 1), (2,), (1,), (1,)] columns = [(1,), (3,), (1, 3), (2,)]
Note that empty lines and/or columns are either represented with an empty tuple or as (0,) depending on what is convenient for the module, e.g. the following pattern:
1 1 1 1 1 1 3 X X X 0 3 X X X
Is either represented the following way:
lines = [(3,), (), (3,)] columns = [(1, 1), (1, 1), (1, 1)]
Or the following way:
lines = [(3,), (0,), (3,)] columns = [(1, 1), (1, 1), (1, 1)]
Colored puzzles, on the other hand, associate colors to a puzzle by populating color_lines and color_columns. Since it is possible to distinguish groups by using the color, it does not require gaps between groups, which can just be stuck together.
For example, take the following colored puzzle:
3G 2G 4G 2R 4G 2G 3G G G G 5G G G G G G 5G G G G G G 1G 1R 1G G R G 1R R
It is represented the following way:
lines = [(3,), (5,), (5,), (1, 1, 1), (1,)] columns = [(2,), (4,), (3, 2), (4,), (2,)] line_colors = [(G,), (G,), (G,), (G, R, G), (R,)] column_colors = [(G,), (G,), (G, R), (G,), (G,)]
Where R = 0xFF0000 (i.e. 16711680) and G = 0x00FF00 (i.e. 65280), since color components are integers representing sRGB colors.
- Variables
url – (
str
) urlname – (
str
) The friendly name of the picross puzzle, if availablevariant – (
str
) The rules variant for the picross (default: basic)solved_status – (
str
) Whether the picross has been solved or not (default: unknown)lines – (
list
) List of line tuplescolumns – (
list
) List of column tuplescolor_lines – (
list
) List of colors given to groups on rowscolor_columns – (
list
) List of colors given to groups on columns
- exception PicrossNotFound(msg='Picross not found')[source]¶
Bases:
UserError
Raised when a picross puzzle is not found.
- class PicrossSolution(id='', url=NotLoaded, backend=None)[source]¶
Bases:
BaseObject
Picross puzzle solution representation.
For example, take the following puzzle:
1 1 3 3 2 3 X X X 2 1 X X X 2 X X 1 X 1 X
The puzzle is represented line by line, as the following:
lines = [' xxx', 'xx x', ' xx ', ' x ', ' x ']
Note that if the solution is for a colored picross, it is possible to deduce the colors from the puzzle data and the solution placements, and colors do not need to be included in the solution.
- Variables
url – (
str
) urlkind – (
str
) The solution kind to the picross solution. (default: placements)lines – (
list
) List of lines with x-es and spaces