Kenichi Ishigaki > Games-Nonogram-0.01 > Games::Nonogram::Block

Download:
Games-Nonogram-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Games::Nonogram::Block

SYNOPSIS ^

  use Games::Nonogram::Block;
  my $block = Games::Nonogram::Block->new(
    id        => 'row 1 block 1',
    length    => 2,
    line_size => 20,
  );

DESCRIPTION ^

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.

METHODS ^

new

creates an object.

clear

clears information of the block.

die_if_overflowed

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_overflowed

is used to see if the block is overflowed or not.

cant_have

sets forbidden area for the block (which is (or, should be) occupied by other blocks, or is known to be blank).

might_have

returns if the given cell (id) may belong to the block or not.

must_have

returns if the given cell (id) belongs to the block or not.

try

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.

ACCESSORS ^

id

returns a block id.

length

returns of the length of the block.

left

returns the leftmost id the block can stay.

right

returns the rightmost id the block can stay.

AUTHOR ^

Kenichi Ishigaki, <ishigaki at cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: