| 1 | package Game::Go; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 47 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 47 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 47 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 47 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 47 | ▶ | use Game::Go::Rules; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 47 | ▶ | use Game::Go::Engine; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use Game::Go::Board; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 47 | ▶ | use Game::Go::Move; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 47 | ▶ | use Game::Go::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 47 | ▶ | use Game::Go::Marking; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 47 | ▶ | use Game::Go::Scoring; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 47 | ▶ | use Game::Go::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 47 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 47 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 47 | EMPTY => Game::Go::Rules::EMPTY, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | BLACK => Game::Go::Rules::BLACK, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | WHITE => Game::Go::Rules::WHITE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | BORDER => Game::Go::Rules::BORDER, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 47 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 47 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 47 | OK => Game::Go::Rules::OK, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ILL_OFF => Game::Go::Rules::ILL_OFF, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ILL_TAKEN => Game::Go::Rules::ILL_TAKEN, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ILL_KO => Game::Go::Rules::ILL_KO, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ILL_SUICIDE => Game::Go::Rules::ILL_SUICIDE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ILL_REPEAT => Game::Go::Rules::ILL_REPEAT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ILL_COLOUR => Game::Go::Rules::ILL_COLOUR, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 47 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 47 | ▶ | use constant MAX_DISPUTES => 3; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 47 | has size => (is => 'ro', isa => Int, default => 19); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 47 | has komi => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 47 | has handicap => (is => 'ro', isa => Int, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 47 | has ko => (is => 'ro', isa => Str, default => 'positional'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 47 | has setup => (is => 'ro', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 47 | has first => (is => 'ro', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 47 | has status => (is => 'rw', isa => Str, default => 'active'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 47 | has phase => (is => 'rw', isa => Str, default => 'play'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 47 | has turn => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 47 | has [qw/winner result/] => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 47 | has scored_by => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 47 | has outcome => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 47 | has marking => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 47 | has disputes => (is => 'rw', default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 47 | has log => (is => 'rw', isa => ArrayRef, default => []); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 47 | has _engine => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 47 | has _passes => (is => 'rw', private => 1, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 47 | has _held_seed => (is => 'ro', init_arg => 'seed', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 646 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=16 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 646 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 646 | my $size = $self->size; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | Carp::croak("Game::Go: size must be 9, 13 or 19, not '$size'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 646 | ▶ | unless grep { $_ == $size } Game::Go::Rules::sizes(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 637 | ▶ | $self->komi( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $self->handicap | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ? Game::Go::Rules::HANDICAP_KOMI | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | : Game::Go::Rules::DEFAULT_KOMI | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ) unless defined $self->komi; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 637 | my $komi = $self->komi; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 637 | ▶ | Carp::croak("Game::Go: komi must be a multiple of 0.5, not '$komi'") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | unless $komi =~ /\A-?[0-9]+(?:\.[05])?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 636 | my $handicap = $self->handicap; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 636 | my $most = Game::Go::Rules::max_handicap($size); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 636 | ▶ | Carp::croak("Game::Go: handicap must be 0 to $most on a ${size}x$size board, not '$handicap'") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$handicap < 0 or $handicap > $most
MC/DC100%2/2
$handicap < 0 or $handicap > $most
$handicap < 0
$handicap > $most
Truth table100%3/3
A or B
A= $handicap < 0B= $handicap > $most
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | if $handicap < 0 || $handicap > $most; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 626 | my $ko = $self->ko; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 626 | ▶ | Carp::croak("Game::Go: ko must be 'positional' or 'simple', not '$ko'") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ko eq "positional" or $ko eq "simple"
MC/DC100%2/2
$ko eq "positional" or $ko eq "simple"
$ko eq "positional"
$ko eq "simple"
Truth table100%3/3
A or B
A= $ko eq "positional"B= $ko eq "simple"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | unless $ko eq 'positional' || $ko eq 'simple'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 625 | $self->_engine(Game::Go::Engine->new(size => $size)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 625 | ▶ | $self->_engine->superko(0) if $ko eq 'simple'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 625 | my $first = $self->first; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 625 | my $told; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 625 | ▶ | if ($first) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 9 | $told = Game::Go::Rules::from_letter($first); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 9 | ▶ | Carp::croak("Game::Go: first must be 'b' or 'w', not '$first'") unless $told; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 625 | $self->turn(BLACK); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 625 | ▶ | $self->_log('sys', 'start', { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | komi => $komi + 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | handicap => $handicap, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ko => $ko, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | first => Game::Go::Rules::letter($self->turn), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ($told ? (turn => $first) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 625 | ▶ | $self->_place_setup($self->setup) if $self->setup; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 625 | ▶ | $self->_place_handicap($handicap) if $handicap > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 625 | ▶ | $self->turn($told) if $told; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 625 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | ▶ | sub _place_setup { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_place_setup: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | my ($self, $setup) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | my %placed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | for my $letter (sort keys %$setup) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | my $colour = Game::Go::Rules::from_letter($letter); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 12 | ▶ | Carp::croak("Game::Go: setup names '$letter', which is not a colour") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | unless $colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 12 | for my $cr (@{ $setup->{$letter} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 18 | my $pt = $self->point(@$cr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 18 | ▶ | Carp::croak('Game::Go: a setup stone is off the board') if $pt < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 18 | $self->_engine->put($pt, $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 18 | push @{ $placed{$letter} }, $pt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 6 | $self->_log('sys', 'setup', \%placed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | $self->_engine->push_position; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 40 | ▶ | sub _place_handicap { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_place_handicap: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 40 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 40 | my $points = Game::Go::Rules::handicap_points($self->size, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 40 | for my $cr (@$points) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 198 | my $pt = $self->point(@$cr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 198 | $self->_engine->put($pt, BLACK); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 198 | $self->_log(Game::Go::Rules::letter(BLACK), 'handicap', { pt => $pt }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 40 | $self->_engine->push_position; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 40 | $self->turn(WHITE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 80 | ▶ | sub seats { (BLACK, WHITE) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seats: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1047 | ▶ | sub board { Game::Go::Board->new($_[0]->_engine) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
board: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 42109 | ▶ | sub point { $_[0]->_engine->point_of($_[1], $_[2]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
point: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 687 | ▶ | sub col_row { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_row: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 687 | my ($self, $pt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 687 | my $engine = $self->_engine; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 687 | return ($engine->col_of($pt), $engine->row_of($pt)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 304 | ▶ | sub events { [ map { { %$_ } } @{ $_[0]->log } ] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
events: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 78 | ▶ | sub raw_score { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw_score: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 78 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 78 | my $m = $self->marking; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 78 | my $p = $self->prisoners; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | return $self->_engine->score( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | dead => ($m ? $m->dead_points : []), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | seki => ($m ? $m->seki_points : []), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | prisoners_b => $p->{ +BLACK }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 78 | ▶ | prisoners_w => $p->{ +WHITE }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | komi_tenths => int($self->komi * 10 + ($self->komi < 0 ? -0.5 : 0.5)), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | ▶ | sub raw_area { $_[0]->_engine->area_score } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw_area: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | sub territory_map { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
territory_map: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | my $m = $self->marking; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | return $self->_engine->territory_map( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | dead => ($m ? $m->dead_points : []), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | seki => ($m ? $m->seki_points : []), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 25 | ▶ | sub _handicap_points { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handicap_points: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 101 | return [ map { $self->point(@$_) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 25 | @{ Game::Go::Rules::handicap_points($self->size, $self->handicap) } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 473 | ▶ | sub star_points { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
star_points: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 473 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 473 | return [ map { $self->point(@$_) } @{ Game::Go::Rules::star_points($self->size) } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 26 | ▶ | sub ko_point { $_[0]->_engine->ko_point } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ko_point: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub ko_colour { $_[0]->_engine->ko_colour } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ko_colour: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1183 | ▶ | sub search_from { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1183 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1183 | return $self->_engine->search(%o); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 49 | ▶ | sub dead_guess_from { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dead_guess_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 49 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 49 | return $self->_engine->dead_guess(%o); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 123 | ▶ | sub is_alive { $_[0]->_engine->is_alive($_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_alive: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 121 | ▶ | sub chain_id { $_[0]->_chain_id($_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chain_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 31 | ▶ | sub marked_seki { $_[0]->marking ? $_[0]->marking->seki_points : [] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
marked_seki: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub marked_dead { $_[0]->marking ? $_[0]->marking->dead_points : [] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
marked_dead: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 584 | ▶ | sub prisoners { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prisoners: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 584 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 584 | my %taken = (BLACK, 0, WHITE, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 584 | for my $e (@{ $self->log }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 17980 | ▶ | next unless $e->{kind} eq 'play'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 10121 | ▶ | my $by = Game::Go::Rules::from_letter($e->{actor}) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 10121 | ▶ | $taken{$by} += scalar @{ $e->{payload}{caps} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$e->{'payload'}{'caps'} || []
MC/DC0%0/1
$e->{'payload'}{'caps'} || []
$e->{'payload'}{'caps'}
Truth table50%1/2
A
A= $e->{'payload'}{'caps'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 584 | return \%taken; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1569 | ▶ | sub waiting_on { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
waiting_on: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1569 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1569 | ▶ | return () unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1551 | ▶ | return ($self->marking->turn) if $self->phase eq 'marking'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1497 | return ($self->turn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | ▶ | sub seed { $_[0]->status eq 'finished' ? $_[0]->_held_seed : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seed: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 7094 | ▶ | sub _log { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7094 | my ($self, $actor, $kind, $payload) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 7094 | ▶ | push @{ $self->log }, { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$payload || {}
MC/DC100%1/1
$payload || {}
$payload
Truth table100%2/2
A
A= $payload
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | actor => $actor, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | payload => $payload || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 7094 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 5880 | ▶ | sub _guard { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_guard: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 5880 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5880 | ▶ | return Game::Go::Error->throw('bad_colour') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | unless Game::Go::Rules::is_colour($colour); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5880 | ▶ | return Game::Go::Error->throw('game_over') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5879 | ▶ | return Game::Go::Error->throw('still_marking') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | unless $self->phase eq 'play'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5873 | ▶ | return Game::Go::Error->throw('not_your_turn') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | unless $colour == $self->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5870 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1331 | ▶ | sub legal { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legal: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1331 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1331 | ▶ | return [] unless Game::Go::Rules::is_colour($colour); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1330 | ▶ | return [] unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1316 | ▶ | return $self->_legal_marking($colour) if $self->phase eq 'marking'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1295 | ▶ | return [] unless $colour == $self->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1282 | my $engine = $self->_engine; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | my @moves = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 51955 | Game::Go::Move->new(kind => 'play', colour => $colour, point => $_) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1282 | } @{ $engine->legal_moves($colour) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1282 | push @moves, Game::Go::Move->new(kind => 'pass', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1282 | return \@moves; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5183 | ▶ | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5183 | my ($self, $colour, $pt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5183 | my $stop = $self->_guard($colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5183 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5176 | my $r = $self->_engine->play($pt, $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5176 | ▶ | return Game::Go::Error->from_code($r->{code}) unless $r->{ok}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 5156 | $self->_passes(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | $self->_log(Game::Go::Rules::letter($colour), 'play', { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | pt => $pt, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | caps => $r->{caps}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 5156 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 5156 | $self->turn(Game::Go::Rules::other($colour)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | return Game::Go::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | kind => 'play', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | colour => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | point => $pt, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | caps => $r->{caps}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 5156 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 697 | ▶ | sub pass { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pass: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 697 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 697 | my $stop = $self->_guard($colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 697 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 694 | $self->_engine->pass($colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 694 | $self->_log(Game::Go::Rules::letter($colour), 'pass'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 694 | $self->_passes($self->_passes + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 694 | $self->turn(Game::Go::Rules::other($colour)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 694 | ▶ | $self->_stop if $self->_passes >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 694 | return Game::Go::Move->new(kind => 'pass', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 82 | ▶ | sub _stop { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stop: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 82 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 82 | $self->_log('sys', 'stop'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 82 | ▶ | if ($self->disputes >= MAX_DISPUTES) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | $self->_log('sys', 'area'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | return $self->_score('area'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 80 | $self->phase('marking'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 80 | $self->marking(Game::Go::Marking->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | proposer => $self->turn, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | answerer => Game::Go::Rules::other($self->turn), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 80 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 21 | ▶ | sub _legal_marking { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_legal_marking: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 21 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 21 | my $m = $self->marking; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 21 | ▶ | return [] unless $m && $colour == $m->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$m and $colour == $m->turn
MC/DC50%1/2
$m and $colour == $m->turn
$m
$colour == $m->turn
Truth table66%2/3
A and B
A= $mB= $colour == $m->turn
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 13 | my @moves; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 13 | ▶ | if (!$m->proposed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 6 | my $engine = $self->_engine; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 6 | my $alive = $self->_alive_set; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 6 | my %chain; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 6 | for my $row (0 .. $self->size - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 54 | for my $col (0 .. $self->size - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 486 | my $pt = $engine->point_of($col, $row); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 486 | my $at = $engine->at($pt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 486 | ▶ | if ($at == EMPTY) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 311 | ▶ | push @moves, Game::Go::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | kind => ($m->is_seki($pt) ? 'unseki' : 'seki'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | colour => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | point => $pt, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 311 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 175 | ▶ | next if $alive->{$pt}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 162 | my $id = $self->_chain_id($pt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 162 | ▶ | next if !defined $id || $chain{$id}++; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $id or $chain{$id}++
MC/DC50%1/2
not defined $id or $chain{$id}++
not defined $id
$chain{$id}++
Truth table66%2/3
not(A) or B
A= not defined $idB= $chain{$id}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 14 | ▶ | push @moves, Game::Go::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | kind => ($m->is_dead($id) ? 'unmark' : 'mark'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | colour => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | point => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 6 | push @moves, Game::Go::Move->new(kind => 'done', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | return \@moves; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | push @moves, Game::Go::Move->new(kind => 'accept', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 7 | ▶ | push @moves, Game::Go::Move->new(kind => 'dispute', colour => $colour) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | if $self->disputes < MAX_DISPUTES; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 7 | return \@moves; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 333 | ▶ | sub _chain_id { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chain_id: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 333 | my ($self, $pt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 333 | my $stones = $self->_engine->chain_at($pt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 333 | ▶ | return undef unless @$stones; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 332 | my ($low) = sort { $a <=> $b } @$stones; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 332 | return $low; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 185 | ▶ | sub _marking_guard { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_marking_guard: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 185 | my ($self, $colour, $role) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 185 | ▶ | return Game::Go::Error->throw('bad_colour') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | unless Game::Go::Rules::is_colour($colour); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 185 | ▶ | return Game::Go::Error->throw('game_over') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 185 | ▶ | return Game::Go::Error->throw('not_marking') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | unless $self->phase eq 'marking'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 185 | my $m = $self->marking; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 185 | ▶ | my $whose = $role eq 'proposer' ? $m->proposer : $m->answerer; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 185 | ▶ | return Game::Go::Error->throw('not_your_turn') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$colour == $whose and $colour == $m->turn
MC/DC100%2/2
$colour == $whose and $colour == $m->turn
$colour == $whose
$colour == $m->turn
Truth table100%3/3
A and B
A= $colour == $whoseB= $colour == $m->turn
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | unless $colour == $whose && $colour == $m->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 179 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 55 | ▶ | sub _alive_set { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_alive_set: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 55 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 55 | my $engine = $self->_engine; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 55 | my %alive; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 55 | for my $colour ($self->seats) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 110 | $alive{$_} = 1 for @{ $engine->alive($colour) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 55 | return \%alive; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 52 | ▶ | sub mark { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 52 | my ($self, $colour, $pt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 52 | my $stop = $self->_marking_guard($colour, 'proposer'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 52 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 50 | my $id = $self->_chain_id($pt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 50 | ▶ | return Game::Go::Error->throw('not_a_chain') unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | return Game::Go::Error->throw('alive_chain') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 49 | ▶ | if $self->_alive_set->{$pt}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 48 | my $on = $self->marking->toggle_dead($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 48 | ▶ | $self->_log(Game::Go::Rules::letter($colour), ($on ? 'mark' : 'unmark'), { chain => $id }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 48 | ▶ | return Game::Go::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | kind => ($on ? 'mark' : 'unmark'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | colour => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | point => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 13 | ▶ | sub mark_seki { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_seki: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 13 | my ($self, $colour, $pt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 13 | my $stop = $self->_marking_guard($colour, 'proposer'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 13 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 13 | ▶ | return Game::Go::Error->throw('off_board') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | unless $self->_engine->at($pt) == EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 12 | my $on = $self->marking->toggle_seki($pt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 12 | ▶ | $self->_log(Game::Go::Rules::letter($colour), ($on ? 'seki' : 'unseki'), { region => $pt }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 12 | ▶ | return Game::Go::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | kind => ($on ? 'seki' : 'unseki'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | colour => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | point => $pt, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 60 | ▶ | sub done { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 60 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 60 | my $stop = $self->_marking_guard($colour, 'proposer'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 60 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 59 | $self->marking->proposed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 59 | $self->_log(Game::Go::Rules::letter($colour), 'done'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 59 | return Game::Go::Move->new(kind => 'done', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 42 | ▶ | sub accept { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 42 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 42 | my $stop = $self->_marking_guard($colour, 'answerer'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 42 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 40 | $self->_log(Game::Go::Rules::letter($colour), 'accept'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 40 | return $self->_score('territory'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 18 | ▶ | sub dispute { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispute: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 18 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 18 | my $stop = $self->_marking_guard($colour, 'answerer'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 18 | ▶ | return $stop if $stop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 17 | my $proposer = $self->marking->proposer; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 17 | $self->disputes($self->disputes + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 17 | $self->_log(Game::Go::Rules::letter($colour), 'dispute'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 17 | $self->phase('play'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 17 | $self->marking(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 17 | $self->_passes(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 17 | $self->turn($proposer); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 17 | $self->_log('sys', 'resumed', { first => Game::Go::Rules::letter($proposer) }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 17 | return Game::Go::Move->new(kind => 'dispute', colour => $colour); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 42 | ▶ | sub _score { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_score: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 42 | my ($self, $how) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 42 | $self->scored_by($how); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 42 | ▶ | my $scored = $how eq 'area' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | ? Game::Go::Scoring::score_by_area($self) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | : Game::Go::Scoring::score($self, scored_by => 'territory'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 42 | $self->phase('play'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 42 | $self->marking(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 42 | $self->outcome($scored); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 42 | return $self->_finish($scored->winner, 'score'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 36 | ▶ | sub resign { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resign: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 36 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 36 | ▶ | return Game::Go::Error->throw('bad_colour') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | unless Game::Go::Rules::is_colour($colour); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 36 | ▶ | return Game::Go::Error->throw('game_over') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 35 | $self->_log(Game::Go::Rules::letter($colour), 'resign'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 35 | return $self->_finish(Game::Go::Rules::other($colour), 'resign'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 9 | ▶ | sub timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 9 | my ($self, $colour) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 9 | ▶ | return Game::Go::Error->throw('bad_colour') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | unless Game::Go::Rules::is_colour($colour); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 9 | ▶ | return Game::Go::Error->throw('game_over') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 9 | $self->_log('sys', 'timeout', { p => Game::Go::Rules::letter($colour) }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 9 | return $self->_finish(Game::Go::Rules::other($colour), 'timeout'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 4 | ▶ | sub abandon { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abandon: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | ▶ | return Game::Go::Error->throw('game_over') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | unless $self->status eq 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 4 | $self->_log('sys', 'abandon'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 4 | return $self->_finish(undef, 'abandoned'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 90 | ▶ | sub _finish { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 90 | my ($self, $winner, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 90 | $self->status('finished'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 90 | $self->winner($winner); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 90 | $self->result($result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 90 | $self->turn(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 90 | ▶ | $self->_log('sys', 'game_end', { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | winner => (defined $winner ? Game::Go::Rules::letter($winner) : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | result => $result, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | scored_by => $self->scored_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 90 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 47 | our %SITE_OWNED; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 47 | ▶ | BEGIN { %SITE_OWNED = map { $_ => 1 } qw(timeout abandon) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 649 | ▶ | sub replay { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replay: called CC=31 SCAR=34.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 649 | my ($self, $events, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 649 | ▶ | Carp::croak('Game::Go: replay wants an arrayref of events') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | unless ref $events eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 648 | ▶ | return $self->_rebuild($events, %o) unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 332 | my $seen = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 332 | my $seen_handicap = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 332 | for my $e (@$events) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3316 | my $actor = $e->{actor}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3316 | my $kind = $e->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 3316 | ▶ | my $load = $e->{payload} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$e->{'payload'} || {}
MC/DC0%0/1
$e->{'payload'} || {}
$e->{'payload'}
Truth table50%1/2
A
A= $e->{'payload'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 3316 | $seen++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 3316 | ▶ | if ($actor eq 'sys') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 384 | ▶ | if ($kind eq 'timeout') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 4 | ▶ | my $who = Game::Go::Rules::from_letter($load->{p} || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$load->{'p'} || ''
MC/DC0%0/1
$load->{'p'} || ''
$load->{'p'}
Truth table50%1/2
A
A= $load->{'p'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 4 | ▶ | Carp::croak("Game::Go: replay: timeout names no colour") unless $who; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 4 | $self->timeout($who); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 380 | ▶ | if ($kind eq 'abandon') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | $self->abandon; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 379 | my $mine = $self->_last_sys($kind); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 379 | ▶ | Carp::croak("Game::Go: replay: the log claims a 'sys $kind' the engine did not produce") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | unless $mine; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 378 | $self->_agree($kind, $load, $mine->{payload}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 375 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2932 | my $colour = Game::Go::Rules::from_letter($actor); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 2932 | ▶ | Carp::croak("Game::Go: replay: '$actor' is not a player") unless $colour; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2931 | ▶ | if ($kind eq 'handicap') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 25 | my $mine = $self->_handicap_points; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 25 | my $want = $mine->[ $seen_handicap++ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 25 | ▶ | Carp::croak('Game::Go: replay: the log has more handicap stones than this board places') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | unless defined $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | Carp::croak("Game::Go: replay: handicap stone $seen_handicap is on the wrong point") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 25 | ▶ | unless defined $load->{pt} && $load->{pt} == $want; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $load->{"pt"} and $load->{"pt"} == $want
MC/DC50%1/2
defined $load->{"pt"} and $load->{"pt"} == $want
defined $load->{"pt"}
$load->{"pt"} == $want
Truth table66%2/3
A and B
A= defined $load->{"pt"}B= $load->{"pt"} == $want
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 23 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2906 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 2906 | ▶ | if ($kind eq 'play') { $out = $self->play($colour, $load->{pt}) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 231 | elsif ($kind eq 'pass') { $out = $self->pass($colour) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 6 | elsif ($kind eq 'resign') { $out = $self->resign($colour); next } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ▶ | elsif ($kind eq 'mark' || $kind eq 'unmark') { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$kind eq "mark" or $kind eq "unmark"
MC/DC50%1/2
$kind eq "mark" or $kind eq "unmark"
$kind eq "mark"
$kind eq "unmark"
Truth table66%2/3
A or B
A= $kind eq "mark"B= $kind eq "unmark"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 30 | $out = $self->mark($colour, $load->{chain}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 30 | ▶ | Carp::croak("Game::Go: replay: the log's '$kind' came out as a '" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $out eq "Game::Go::Move" and $out->kind ne $kind
MC/DC0%0/2
ref $out eq "Game::Go::Move" and $out->kind ne $kind
ref $out eq "Game::Go::Move"
$out->kind ne $kind
Truth table33%1/3
A and B
A= ref $out eq "Game::Go::Move"B= $out->kind ne $kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | . $out->kind . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | if ref $out eq 'Game::Go::Move' && $out->kind ne $kind; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ▶ | elsif ($kind eq 'seki' || $kind eq 'unseki') { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$kind eq "seki" or $kind eq "unseki"
MC/DC50%1/2
$kind eq "seki" or $kind eq "unseki"
$kind eq "seki"
$kind eq "unseki"
Truth table66%2/3
A or B
A= $kind eq "seki"B= $kind eq "unseki"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | $out = $self->mark_seki($colour, $load->{region}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | Carp::croak("Game::Go: replay: the log's '$kind' came out as a '" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $out eq "Game::Go::Move" and $out->kind ne $kind
MC/DC0%0/2
ref $out eq "Game::Go::Move" and $out->kind ne $kind
ref $out eq "Game::Go::Move"
$out->kind ne $kind
Truth table33%1/3
A and B
A= ref $out eq "Game::Go::Move"B= $out->kind ne $kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | . $out->kind . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | if ref $out eq 'Game::Go::Move' && $out->kind ne $kind; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 14 | elsif ($kind eq 'done') { $out = $self->done($colour) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 6 | elsif ($kind eq 'accept') { $out = $self->accept($colour); next } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 5 | elsif ($kind eq 'dispute') { $out = $self->dispute($colour) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | else { Carp::croak("Game::Go: replay: no such player event '$kind'") } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2893 | ▶ | Carp::croak("Game::Go: replay: the log's '$kind' was refused: " . $out->message) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | if ref $out eq 'Game::Go::Error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 321 | return $seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 379 | ▶ | sub _last_sys { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_last_sys: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 379 | my ($self, $kind) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 379 | for my $e (reverse @{ $self->log }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 418 | ▶ | return $e if $e->{actor} eq 'sys' && $e->{kind} eq $kind; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$e->{"actor"} eq "sys" and $e->{"kind"} eq $kind
MC/DC100%2/2
$e->{"actor"} eq "sys" and $e->{"kind"} eq $kind
$e->{"actor"} eq "sys"
$e->{"kind"} eq $kind
Truth table100%3/3
A and B
A= $e->{"actor"} eq "sys"B= $e->{"kind"} eq $kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 378 | ▶ | sub _agree { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_agree: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 378 | my ($self, $kind, $theirs, $mine) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 378 | for my $key (sort keys %$mine) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | Carp::croak("Game::Go: replay: 'sys $kind' disagrees about $key") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 1719 | ▶ | unless _same($mine->{$key}, $theirs->{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 375 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1731 | ▶ | sub _same { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_same: called CC=13 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 1731 | my ($a, $b) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1731 | ▶ | return 1 if !defined $a && !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $a or defined $b
MC/DC50%1/2
defined $a or defined $b
defined $a
defined $b
Truth table66%2/3
A or B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1719 | ▶ | return 0 if !defined $a || !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $a and defined $b
MC/DC0%0/2
defined $a and defined $b
defined $a
defined $b
Truth table33%1/3
A and B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 1719 | ▶ | if (ref $a eq 'ARRAY' || ref $b eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $a eq "ARRAY" or ref $b eq "ARRAY"
MC/DC50%1/2
ref $a eq "ARRAY" or ref $b eq "ARRAY"
ref $a eq "ARRAY"
ref $b eq "ARRAY"
Truth table66%2/3
A or B
A= ref $a eq "ARRAY"B= ref $b eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 8 | ▶ | return 0 unless ref $a eq 'ARRAY' && ref $b eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $a eq "ARRAY" and ref $b eq "ARRAY"
MC/DC0%0/2
ref $a eq "ARRAY" and ref $b eq "ARRAY"
ref $a eq "ARRAY"
ref $b eq "ARRAY"
Truth table33%1/3
A and B
A= ref $a eq "ARRAY"B= ref $b eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 8 | ▶ | return 0 unless @$a == @$b; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 8 | ▶ | _same($a->[$_], $b->[$_]) or return 0 for 0 .. $#$a; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 1711 | ▶ | return $a eq $b ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 316 | ▶ | sub _rebuild { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rebuild: called CC=23 SCAR=33.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 316 | my ($class, $events, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 316 | my $start = $events->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | Carp::croak("Game::Go: replay: the log does not begin with a 'sys start'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | unless ref $start eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | && ($start->{actor} // '') eq 'sys' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 316 | ▶ | && ($start->{kind} // '') eq 'start'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%6/10
ref $start eq "HASH" and ($start->{"actor"} // "") eq "sys" and ($start->{"kind"} // "") eq "start"
ref $start eq "HASH" and ($start->{"actor"} // "") eq "sys"
$start->{"actor"} // ""
$start->{"kind"} // ""
MC/DC0%0/3
ref $start eq "HASH" and ($start->{"actor"} // "") eq "sys" and ($start->{"kind"} // "") eq "start"
ref $start eq "HASH"
$start->{"actor"}
$start->{"kind"}
Truth table25%1/4
A and B and C
A= ref $start eq "HASH"B= $start->{"actor"}C= $start->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 315 | ▶ | my $p = $start->{payload} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$start->{'payload'} || {}
MC/DC0%0/1
$start->{'payload'} || {}
$start->{'payload'}
Truth table50%1/2
A
A= $start->{'payload'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 315 | ▶ | my %args = map { defined $p->{$_} ? ($_ => $p->{$_}) : () } qw(size komi handicap ko); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 315 | ▶ | $args{first} = $p->{turn} if defined $p->{turn}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 315 | ▶ | $args{seed} = $o{seed} if defined $o{seed}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 315 | ▶ | my $size = $args{size} // 19; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"size"} // 19
MC/DC0%0/1
$args{"size"} // 19
$args{"size"}
Truth table50%1/2
A
A= $args{"size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | Carp::croak("Game::Go: replay: the log's 'sys start' names size '$size'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 315 | ▶ | unless $size =~ /\A[0-9]+\z/ && grep { $_ == $size } Game::Go::Rules::sizes(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$size =~ /\A[0-9]+\z/ and grep {$_ == $size;} Game::Go::Rules::sizes()
MC/DC50%1/2
$size =~ /\A[0-9]+\z/ and grep {$_ == $size;} Game::Go::Rules::sizes()
$size =~ /\A[0-9]+\z/
grep {$_ == $size;} Game::Go::Rules::sizes()
Truth table66%2/3
A and B
A= $size =~ /\A[0-9]+\z/B= grep {$_ == $size;} Game::Go::Rules::sizes()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 314 | my $next = $events->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 314 | ▶ | if (ref $next eq 'HASH' && ($next->{actor} // '') eq 'sys' && ($next->{kind} // '') eq 'setup') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%8/10
ref $next eq "HASH" and ($next->{"actor"} // "") eq "sys" and ($next->{"kind"} // "") eq "setup"
ref $next eq "HASH" and ($next->{"actor"} // "") eq "sys"
$next->{"actor"} // ""
$next->{"kind"} // ""
MC/DC33%1/3
ref $next eq "HASH" and ($next->{"actor"} // "") eq "sys" and ($next->{"kind"} // "") eq "setup"
ref $next eq "HASH"
$next->{"actor"}
$next->{"kind"}
Truth table50%2/4
A and B and C
A= ref $next eq "HASH"B= $next->{"actor"}C= $next->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 4 | my $probe = Game::Go::Engine->new(size => $size); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 4 | my %setup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 4 | ▶ | my $placed = $next->{payload} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$next->{'payload'} || {}
MC/DC0%0/1
$next->{'payload'} || {}
$next->{'payload'}
Truth table50%1/2
A
A= $next->{'payload'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 4 | for my $letter (keys %$placed) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 8 | my $points = $placed->{$letter}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | Carp::croak("Game::Go: replay: the log's 'sys setup' has a bad list for '$letter'") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 8 | ▶ | unless ref $points eq 'ARRAY' && !grep { !defined $_ || !/\A[0-9]+\z/ } @$points; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $points eq "ARRAY" and not grep({not defined $_ && /\A[0-9]+\z/;} @$points)
defined $_ && /\A[0-9]+\z/
MC/DC0%0/2
ref $points eq "ARRAY" and not grep({not defined $_ && /\A[0-9]+\z/;} @$points)
ref $points eq "ARRAY"
not grep({not defined $_ && /\A[0-9]+\z/;} @$points)
MC/DC0%0/2
defined $_ && /\A[0-9]+\z/
defined $_
/\A[0-9]+\z/
Truth table33%1/3
A and not(B)
A= ref $points eq "ARRAY"B= not grep({not defined $_ && /\A[0-9]+\z/;} @$points)
Truth table33%1/3
A && B
A= defined $_B= /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 8 | $setup{$letter} = [ map { [ $probe->col_of($_), $probe->row_of($_) ] } @$points ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 4 | $args{setup} = \%setup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 314 | my $game = $class->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 313 | $game->replay($events); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 311 | return $game; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 245 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 245 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 245 | return ref($self)->replay($self->events, seed => $self->_held_seed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 47 | ▶ | use constant TEXT_HEAD => 'game-go 1'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 718 | ▶ | sub to_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_text: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 718 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 718 | my @lines = (TEXT_HEAD); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 718 | my $seed = $self->_held_seed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 718 | ▶ | if (defined $seed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 715 | ▶ | Carp::croak('Game::Go: to_text cannot write a seed that is not a byte string') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | if $seed =~ /[^\x00-\xff]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 715 | push @lines, 'seed ' . unpack('H*', $seed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 718 | for my $e (@{ $self->log }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 28962 | ▶ | my $p = $e->{payload} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$e->{'payload'} || {}
MC/DC0%0/1
$e->{'payload'} || {}
$e->{'payload'}
Truth table50%1/2
A
A= $e->{'payload'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | push @lines, join ' ', $e->{actor}, $e->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 28962 | map { "$_=" . _value_text($p->{$_}) } sort keys %$p; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 718 | return join("\n", @lines) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 45689 | ▶ | sub _value_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value_text: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 45689 | my ($v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 45689 | ▶ | return '~' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 45681 | ▶ | return '[' . join(',', @$v) . ']' if ref $v eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 24693 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 81 | ▶ | sub from_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_text: called CC=17 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 81 | my ($class, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 81 | ▶ | Carp::croak('Game::Go: from_text wants the string to_text wrote') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $text and not ref $text
MC/DC100%2/2
defined $text and not ref $text
defined $text
not ref $text
Truth table100%3/3
A and not(B)
A= defined $textB= not ref $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | unless defined $text && !ref $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 79 | my @lines = split /\n/, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 79 | ▶ | Carp::croak("Game::Go: from_text: this is not a saved game, it does not begin '" . TEXT_HEAD . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@lines and $lines[0] eq "game-go 1"
MC/DC100%2/2
@lines and $lines[0] eq "game-go 1"
@lines
$lines[0] eq "game-go 1"
Truth table100%3/3
A and B
A= @linesB= $lines[0] eq "game-go 1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | unless @lines && $lines[0] eq TEXT_HEAD; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 77 | shift @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 77 | my %o; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 77 | ▶ | if (@lines && $lines[0] =~ /\Aseed/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@lines and $lines[0] =~ /\Aseed/
MC/DC100%2/2
@lines and $lines[0] =~ /\Aseed/
@lines
$lines[0] =~ /\Aseed/
Truth table100%3/3
A and B
A= @linesB= $lines[0] =~ /\Aseed/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 74 | my ($hex) = $lines[0] =~ /\Aseed ((?:[0-9a-f]{2})*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 74 | ▶ | Carp::croak('Game::Go: from_text: the seed line is not an even run of hex digits') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | unless defined $hex; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 73 | $o{seed} = pack 'H*', $hex; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 73 | shift @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 76 | my @events; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 76 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 76 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 1712 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 1712 | my ($actor, $kind, @pairs) = split / /, $line, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 1712 | ▶ | Carp::croak("Game::Go: from_text: event $n is not an actor and a kind") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $kind and $actor =~ /\A(?:sys|b|w)\z/ and $kind =~ /\A[a-z_]+\z/
defined $kind and $actor =~ /\A(?:sys|b|w)\z/
MC/DC33%1/3
defined $kind and $actor =~ /\A(?:sys|b|w)\z/ and $kind =~ /\A[a-z_]+\z/
defined $kind
$actor =~ /\A(?:sys|b|w)\z/
$kind =~ /\A[a-z_]+\z/
Truth table50%2/4
A and B and C
A= defined $kindB= $actor =~ /\A(?:sys|b|w)\z/C= $kind =~ /\A[a-z_]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | unless defined $kind && $actor =~ /\A(?:sys|b|w)\z/ && $kind =~ /\A[a-z_]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1711 | my %payload; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1711 | for my $pair (@pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 3104 | my ($key, $raw) = $pair =~ /\A([a-z_]+)=(.*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 3104 | ▶ | Carp::croak("Game::Go: from_text: event $n has '$pair', which is not a key=value") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | Carp::croak("Game::Go: from_text: event $n names '$key' twice") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 3103 | ▶ | if exists $payload{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 3102 | my ($ok, $value) = _value_from($raw); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 3102 | ▶ | Carp::croak("Game::Go: from_text: event $n has '$raw' for '$key', which is not a value") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 3101 | $payload{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1708 | push @events, { actor => $actor, kind => $kind, payload => \%payload }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 72 | ▶ | Carp::croak('Game::Go: from_text: there are no events after the header') unless @events; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 71 | return $class->replay(\@events, %o); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 3102 | ▶ | sub _value_from { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value_from: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 3102 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 3102 | my $word = qr/-?[A-Za-z0-9_.]+/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 3102 | ▶ | return (1, undef) if $raw eq '~'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 3094 | ▶ | if (my ($list) = $raw =~ /\A\[(.*)\]\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 1326 | my @items = split /,/, $list, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 1326 | ▶ | @items = () if $list eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 1326 | ▶ | return (0) if grep { !/\A$word\z/ } @items; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 1326 | return (1, \@items); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 1768 | ▶ | return (0) unless $raw =~ /\A$word\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 1767 | return (1, $raw); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 100 | ▶ | sub sizes { Game::Go::Rules::sizes() } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sizes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | sub other { Game::Go::Rules::other($_[-1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | sub refusal { Game::Go::Rules::refusal($_[-1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refusal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | sub refusals { Game::Go::Rules::refusals() } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refusals: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 3 | ▶ | sub abi_version { Game::Go::Engine::_abi_version() } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abi_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 47 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||