Games-Go-Referee
view release on metacpan or search on metacpan
lib/Games/Go/Referee.pm view on Meta::CPAN
if ($self->{_cellfarm}{$x.','.$y} eq $stone) {
$hash{$x.','.$y} = undef;
}
} $self->{_const}{size};
return \%hash
}
# list all the live stones of a particular colour
# (as the set of all blocks adjacent to their opponent's illegal moves)
sub listalive {
my ($self, $colour) = @_;
# turn off alternation and passcount errors temporarily
$self->{_const}{passcount} = 0;
$self->{_const}{alternation} = 0;
# first get the list of illegal moves for the other player
my @illegallist = illegal($self, swapcolour($self, $colour));
my $points = {};
my $stone = ($colour eq 'B') ? 'x' : 'o';
lib/Games/Go/Referee.pm view on Meta::CPAN
my $ydir = $directions[$_][1]+$y;
$points = block($self, $xdir, $ydir, $stone, $points);
}
}
$self->{_const}{passcount} = 1;
$self->{_const}{alternation} = 1;
return $points
}
# list the dead stones of a particular colour
# (as the difference between their alive list
# and their total list)
sub listdead {
my ($self, $colour) = @_;
my $allref = liststones($self, $colour);
my $aliveref = listalive($self, $colour);
my @dead = ();
for (keys %$allref) {
push @dead, $_ unless exists $aliveref->{$_};
}
@dead = map {
/(.*),(.*)/;
insertpoints($self, $1, $2)
} @dead;
return \@dead
}
# list all the dead stones on the board
# (as the union of the Black and White
( run in 1.897 second using v1.01-cache-2.11-cpan-39bf76dae61 )