ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Games-Go-SimpleBoard/SimpleBoard.pm
(Generate patch)

Comparing Games-Go-SimpleBoard/SimpleBoard.pm (file contents):
Revision 1.10 by root, Wed Jun 25 20:49:38 2008 UTC vs.
Revision 1.12 by elmex, Wed Jul 23 19:19:31 2008 UTC

99=cut 99=cut
100 100
101sub new { 101sub new {
102 my $class = shift; 102 my $class = shift;
103 my $size = shift; 103 my $size = shift;
104
105 unless ($size > 0) {
106 Carp::croak ("no board size given!");
107 }
104 108
105 bless { 109 bless {
106 max => $size - 1, 110 max => $size - 1,
107 size => $size, 111 size => $size,
108 board => [map [(0) x $size], 1 .. $size], 112 board => [map [(0) x $size], 1 .. $size],
311sub is_valid_move { 315sub is_valid_move {
312 my ($self, $colour, $x, $y, $may_suicide) = @_; 316 my ($self, $colour, $x, $y, $may_suicide) = @_;
313 317
314 my $board = $self->{board}; 318 my $board = $self->{board};
315 319
316 return if $board->[$x][$y] & (MARK_B | MARK_W | MARK_KO); 320 return if $board->[$x][$y] & (MARK_B | MARK_W | MARK_KO)
321 && !($board->[$x][$y] & MARK_GRAYED);
317 322
318 if ($may_suicide) { 323 if ($may_suicide) {
319 return 1; 324 return 1;
320 } else { 325 } else {
321 my ($own, $opp) = $colour == COLOUR_BLACK 326 my ($own, $opp) = $colour == COLOUR_BLACK

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines