use Games::Nonogram::Block; my $block = Games::Nonogram::Block->new( id => 'row 1 block 1', length => 2, line_size => 20, );
This is used internally to decide where each box (block) be placed in a row or a column. For example, in a row of 5 cells with two clues (1, 2), the first block should not be placed at cell 3, 4 and 5: see all the possible combinations.
1 2 3 4 5 X . X X . X . . X X . X . X X
In this case, the first ::Block object should have properties like
* left: 1 * right: 2
and the second,
* left: 3 * right: 5 * must_have: 4
Actually this ::Block can handle a bit more complicated cases, though I don't explain here.
creates an object.
clears information of the block.
sometimes this block may receive an out-of-range value (while brute-forcing, or when the puzzle is broken, perhaps). In that case, it dies to notify an error, which should be caught somewhere else.
is used to see if the block is overflowed or not.
sets forbidden area for the block (which is (or, should be) occupied by other blocks, or is known to be blank).
returns if the given cell (id) may belong to the block or not.
returns if the given cell (id) belongs to the block or not.
sees if the given area (cells) can belong to the block or not, and sets the result. If it can't belong to the block, all the cells in the area "cant_have" the block, and if the area is exactly the same as the block, both of the adjacent cells must be blank by the rule.
returns a block id.
returns of the length of the block.
returns the leftmost id the block can stay.
returns the rightmost id the block can stay.
Kenichi Ishigaki, <ishigaki at cpan.org>
Copyright 2007 by Kenichi Ishigaki
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.