Reversi/Terminal.pm

filter: Statementstmt 78.9% 304 / 385 Branchbran 66.5% 149 / 224 Conditioncond 55.8% 43 / 77 MC/DCmcdc 39.5% 19 / 48 Subroutinesub 86.9% 40 / 46 Podpod 95.0% 19 / 20 totaltotal 71.7% 574 / 800 CC 146 SCAR 36.8
CC
146
Cov
72%
run
306.0
pick_square
55.3
_typed_turn
15.4
CRAP 39.8
↑ Summary Reversi/Move.pm »
1 package Game::Reversi::Terminal;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Game::Reversi;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Game::Reversi::Board;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Game::Reversi::Bot;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Game::Reversi::Notation;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Game::Reversi::Opening;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '0.03';
16  
17 2 my %GLYPH = (
18 b => { wide => "\x{25CF}", ascii => 'X' },
19 w => { wide => "\x{25CB}", ascii => 'O' },
20 );
21  
22 2 my %TURNED = (
23 b => { wide => "\x{25C9}", ascii => 'x' },
24 w => { wide => "\x{25CE}", ascii => 'o' },
25 );
26 2 my %NAME = (b => 'dark', w => 'light');
27  
28 2 my %LINE = (
29 wide => { h => "\x{2500}", v => "\x{2502}", tl => "\x{250C}", tr => "\x{2510}",
30 bl => "\x{2514}", br => "\x{2518}", t => "\x{252C}", b => "\x{2534}",
31 l => "\x{251C}", r => "\x{2524}", x => "\x{253C}" },
32 ascii => { h => '-', v => '|', tl => '+', tr => '+', bl => '+', br => '+',
33 t => '+', b => '+', l => '+', r => '+', x => '+' },
34 );
35  
36 2 my %INK = (b => "\e[1m", w => "\e[2m", '*' => "\e[33m", grid => "\e[2m",
37 turned => "\e[1;32m", placed => "\e[1;36m", cursor => "\e[1;7m");
38 2 my $OFF = "\e[0m";
39  
40 has in => (
41 is => 'rw',
42 isa => Any,
43 16 ▶ default => sub { \*STDIN }
Subroutine __ANON__: called CC=1 SCAR=0.0
44 2 );
45  
46 has out => (
47 is => 'rw',
48 isa => Any,
49 7 ▶ default => sub { \*STDOUT }
Subroutine __ANON__: called CC=1 SCAR=0.0
50 2 );
51  
52 has level => (
53 is => 'ro',
54 isa => Int,
55 default => 3
56 2 );
57  
58 has variant => (
59 is => 'ro',
60 isa => Str,
61 default => 'historic'
62 2 );
63  
64 has colour => (
65 is => 'ro',
66 isa => Str,
67 default => 'b'
68 2 );
69  
70 has seed => (
71 is => 'ro',
72 default => 'terminal'
73 2 );
74  
75 has [qw/quiet ascii/] => (
76 is => 'rw',
77 isa => Bool,
78 default => 0
79 2 );
80  
81 has game => (
82 is => 'rw',
83 isa => Any
84 2 );
85  
86 2 has last_move => (is => 'rw');
87  
88 2 has raw => (is => 'rw', default => 0);
89  
90 2 has keysource => (is => 'rw');
91  
92 27 ▶has pending => (is => 'rw', default => sub { [] });
Subroutine __ANON__: called CC=1 SCAR=0.0
93  
94 2 has _picking => (is => 'rw', init_arg => 'picking', private => 1);
95  
96 2 our %SEQUENCE = (
97 'A' => 'up', 'B' => 'down', 'C' => 'right', 'D' => 'left',
98 'H' => 'home', 'F' => 'end',
99 '1~' => 'home', '4~' => 'end', '5~' => 'page_up', '6~' => 'page_down',
100 '7~' => 'home', '8~' => 'end',
101 );
102  
103 2 our %CONTROL = (
104 "\r" => 'enter', "\n" => 'enter', "\t" => 'tab',
105 "\x7f" => 'backspace', "\x08" => 'backspace',
106 "\x03" => 'interrupt', "\x04" => 'eof',
107 );
108  
109 has _wants_ansi => (
110 is => 'rw',
111 init_arg => 'ansi',
112 private => 1
113 2 );
114  
115 27 ▶sub BUILD {
Subroutine BUILD: called CC=6 SCAR=17.9
Pod undocumented
116 27 my ($self) = @_;
117  
118 27 ▶ binmode $self->out, ':encoding(UTF-8)' unless $self->ascii;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ascii 14 13 27
119 27 my $previous = select $self->out;
120 27 $| = 1;
121 27 select $previous;
122  
123 27 ▶ die "Game::Reversi::Terminal: colour must be b or w"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->colour eq "b" or $self->colour eq "w" 1 26 27
Condition100%3/3
$self->colour eq "b" or $self->colour eq "w"
l!l&&r!l&&!r
2421
MC/DC100%2/2
$self->colour eq "b" or $self->colour eq "w"
$self->colour eq "b" $self->colour eq "w"
Truth table100%3/3
A or B
A= $self->colour eq "b"B= $self->colour eq "w"
ABresult
1X1
011
000
124 unless $self->colour eq 'b' || $self->colour eq 'w';
125 26 ▶ die "Game::Reversi::Terminal: there is no variant '" . $self->variant . "'"
Branch: 1 branch
BranchTrueFalseTotal
unless "Game::Reversi::Opening"->describes($self->variant) 1 25 26
126 unless Game::Reversi::Opening->describes($self->variant);
127  
128 die 'Game::Reversi::Terminal: there is no level ' . $self->level
129 25 ▶ unless grep { $_ == $self->level } Game::Reversi::Bot->levels;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $self->level;} "Game::Reversi::Bot"->levels 1 24 25
130  
131 24 return $self;
132 }
133  
134 10006 ▶sub ansi {
Subroutine ansi: called CC=6 SCAR=17.9
Pod documented
135 10006 my ($self) = @_;
136 10006 ▶ return 0 if defined $ENV{NO_COLOR} && length $ENV{NO_COLOR};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"NO_COLOR"} and length $ENV{"NO_COLOR"} 2 10004 10006
Condition100%3/3
defined $ENV{"NO_COLOR"} and length $ENV{"NO_COLOR"}
!ll&&!rl&&r
1000312
MC/DC100%2/2
defined $ENV{"NO_COLOR"} and length $ENV{"NO_COLOR"}
defined $ENV{"NO_COLOR"} length $ENV{"NO_COLOR"}
Truth table100%3/3
A and B
A= defined $ENV{"NO_COLOR"}B= length $ENV{"NO_COLOR"}
ABresult
0X0
100
111
137 10004 ▶ return $self->_wants_ansi ? 1 : 0 if defined $self->_wants_ansi;
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->_wants_ansi 353 9651 10004
$self->_wants_ansi ? : 27 326 353
138 9651 ▶ return -t $self->out ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-t $self->out ? : 0 9651 9651
139 }
140  
141 10001 ▶sub _paint {
Subroutine _paint: called CC=3 SCAR=11.1
142 10001 my ($self, $glyph, $key) = @_;
143 10001 ▶ return $glyph unless $self->ansi;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ansi 9976 25 10001
144 25 ▶ return ($INK{$key} || '') . $glyph . $OFF;
Condition50%1/2
$INK{$key} || ''
l!l
250
MC/DC0%0/1
$INK{$key} || ''
$INK{$key}
Truth table50%1/2
A
A= $INK{$key}
Aresult
11
00
145 }
146  
147 733 ▶sub _say {
Subroutine _say: called CC=2 SCAR=6.9
148 733 my ($self, @lines) = @_;
149 733 my $fh = $self->out;
150 733 print {$fh} $_, "\n" for @lines;
151 733 return;
152 }
153  
154 168 ▶sub _ask {
Subroutine _ask: called CC=2 SCAR=6.9
155 168 my ($self, $prompt) = @_;
156 168 my $fh = $self->out;
157 168 print {$fh} $prompt;
158 168 my $in = $self->in;
159 168 my $line = <$in>;
160 168 ▶ return undef unless defined $line;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 1 167 168
161  
162 167 print {$fh} "\n";
163  
164 167 $line =~ s/\A\s+|\s+\z//g;
165 167 return lc $line;
166 }
167  
168 5539 ▶sub glyph {
Subroutine glyph: called CC=2 SCAR=6.9
Pod documented
169 5539 my ($self, $colour) = @_;
170 5539 ▶ return $GLYPH{$colour}{ $self->ascii ? 'ascii' : 'wide' };
Branch: 1 branch
BranchTrueFalseTotal
$self->ascii ? : 1193 4346 5539
171 }
172  
173 190 ▶sub board_text {
Subroutine board_text: called CC=8 SCAR=20.8
Pod documented
174 190 my ($self, $game, $colour, %o) = @_;
175 1227 my %legal = map { $_->square => 1 }
176 190 ▶ @{ defined $colour ? $game->legal($colour) : [] };
Branch: 1 branch
BranchTrueFalseTotal
defined $colour ? : 180 10 190
177 190 ▶ my %flipped = map { $_ => 1 } @{ $o{flips} || [] };
Condition100%2/2
$o{'flips'} || []
l!l
15733
MC/DC100%1/1
$o{'flips'} || []
$o{'flips'}
Truth table100%2/2
A
A= $o{'flips'}
Aresult
11
00
178 190 ▶ my $line = $LINE{ $self->ascii ? 'ascii' : 'wide' };
Branch: 1 branch
BranchTrueFalseTotal
$self->ascii ? : 44 146 190
179 190 ▶ my $kind = $self->ascii ? 'ascii' : 'wide';
Branch: 1 branch
BranchTrueFalseTotal
$self->ascii ? : 44 146 190
180  
181 190 my $files = ' ' . join ' ', 'a' .. 'h';
182 1710 ▶ my $rule = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
183 1710 my ($left, $join, $right) = @_;
184 return ' ' . $self->_paint(
185 1710 $left . join($join, ($line->{h} x 3) x 8) . $right, 'grid');
186 190 };
187  
188 190 my @lines = ($files, $rule->(@{$line}{qw/tl t tr/}));
189 190 for my $row (0 .. 7) {
190 1520 my $rank = 8 - $row;
191 1520 my @cells;
192 1520 for my $col (0 .. 7) {
193 12160 my $square = $row * 8 + $col;
194 12160 my $cell = $game->board->[$square];
195 12160 push @cells, $self->_cell($square, $cell, $kind, \%legal,
196 \%flipped, %o);
197 }
198 1520 my $bar = $self->_paint($line->{v}, 'grid');
199 1520 push @lines, " $rank " . $bar . join($bar, @cells) . $bar . " $rank";
200 1520 ▶ push @lines, $rule->(@{$line}{qw/l x r/}) unless $row == 7;
Branch: 1 branch
BranchTrueFalseTotal
unless $row == 7 1330 190 1520
201 }
202 190 push @lines, $rule->(@{$line}{qw/bl b br/}), $files;
203 190 return @lines;
204 }
205  
206 176 ▶sub since {
Subroutine since: called CC=2 SCAR=6.9
Pod documented
207 176 my ($self) = @_;
208 176 ▶ my $move = $self->last_move or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $move = $self->last_move or return () 157 19 176
209 157 return (last => $move->square, flips => $move->flips);
210 }
211  
212 318 ▶sub remember {
Subroutine remember: called CC=3 SCAR=12.5
Pod documented
213 318 my ($self, $move) = @_;
214 318 ▶ $self->last_move(ref $move && $move->can('square') ? $move : undef);
Branch: 1 branch
BranchTrueFalseTotal
ref $move && $move->can('square') ? : 318 0 318
Condition33%1/3
ref $move and $move->can("square")
!ll&&!rl&&r
00318
MC/DC0%0/2
ref $move and $move->can("square")
ref $move $move->can("square")
Truth table33%1/3
A and B
A= ref $moveB= $move->can("square")
ABresult
0X0
100
111
215 318 return $self;
216 }
217  
218 12160 ▶sub _cell {
Subroutine _cell: called CC=12 SCAR=24.9
219 12160 my ($self, $square, $cell, $kind, $legal, $flipped, %o) = @_;
220  
221 12160 ▶ my $cursor = defined $o{cursor} && $o{cursor} == $square;
Condition100%3/3
defined $o{'cursor'} && $o{'cursor'} == $square
!ll&&!rl&&r
117124417
MC/DC100%2/2
defined $o{'cursor'} && $o{'cursor'} == $square
defined $o{'cursor'} $o{'cursor'} == $square
Truth table100%3/3
A && B
A= defined $o{'cursor'}B= $o{'cursor'} == $square
ABresult
0X0
100
111
222 12160 ▶ my $placed = defined $o{last} && $o{last} == $square;
Condition100%3/3
defined $o{'last'} && $o{'last'} == $square
!ll&&!rl&&r
21129891157
MC/DC100%2/2
defined $o{'last'} && $o{'last'} == $square
defined $o{'last'} $o{'last'} == $square
Truth table100%3/3
A && B
A= defined $o{'last'}B= $o{'last'} == $square
ABresult
0X0
100
111
223  
224 12160 ▶ if ($cursor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cursor) 7 12153 12160
225 my $face = defined $cell ? $self->glyph($cell)
226 7 ▶ : $o{to_play} ? $GLYPH{ $o{to_play} }{$kind} : '*';
Branch: 2 branches
BranchTrueFalseTotal
defined $cell ? : 0 7 7
$o{'to_play'} ? : 7 0 7
227 7 return $self->_paint('>' . $face . '<', 'cursor');
228 }
229  
230 12153 ▶ return $self->_paint('[' . $self->glyph($cell) . ']', 'placed')
Branch: 1 branch
BranchTrueFalseTotal
if $placed and defined $cell 157 11996 12153
Condition66%2/3
$placed and defined $cell
!ll&&!rl&&r
119960157
MC/DC50%1/2
$placed and defined $cell
$placed defined $cell
Truth table66%2/3
A and B
A= $placedB= defined $cell
ABresult
0X0
100
111
231 if $placed && defined $cell;
232  
233 return ' ' . $self->_paint($TURNED{$cell}{$kind}, 'turned') . ' '
234 11996 ▶ if defined $cell && $flipped->{$square};
Branch: 1 branch
BranchTrueFalseTotal
if defined $cell and $flipped->{$square} 384 11612 11996
Condition100%3/3
defined $cell and $flipped->{$square}
!ll&&!rl&&r
66164996384
MC/DC100%2/2
defined $cell and $flipped->{$square}
defined $cell $flipped->{$square}
Truth table100%3/3
A and B
A= defined $cellB= $flipped->{$square}
ABresult
0X0
100
111
235  
236 return ' ' . (defined $cell ? $self->_paint($self->glyph($cell), $cell)
237 11612 ▶ : $legal->{$square} ? $self->_paint('*', '*')
Branch: 2 branches
BranchTrueFalseTotal
defined $cell ? : 4996 6616 11612
$legal->{$square} ? : 1220 5396 6616
238 : ' ') . ' ';
239 }
240  
241 8 ▶sub start {
Subroutine start: called CC=8 SCAR=20.8
Pod documented
242 8 my ($self) = @_;
243  
244 8 my $game = Game::Reversi->new(
245 variant => $self->variant, seed => $self->seed);
246 8 $self->game($game);
247 8 my $bot = Game::Reversi::Bot->new(
248 level => $self->level, seed => $self->seed . ':bot');
249 8 my $me = $self->colour;
250  
251 8 $self->_intro;
252 8 my $seen = scalar @{ $game->events };
253  
254 8 ▶ while ($game->status eq 'active') {
Branch: 1 branch
BranchTrueFalseTotal
if ($game->status eq "active") 319 5 324
255 319 my $turn = $game->turn;
256  
257 319 ▶ if ($turn eq $me) {
Branch: 1 branch
BranchTrueFalseTotal
if ($turn eq $me) { } 163 156 319
258 163 my $quit = $self->_human_turn($game, $me);
259 163 ▶ if ($quit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quit) 3 160 163
260 3 $game->resign($me);
261 3 last;
262 }
263 }
264 else {
265 156 my $move = $bot->choose($game, $turn);
266 156 ▶ last unless $move;
Branch: 1 branch
BranchTrueFalseTotal
unless $move 0 156 156
267 156 my $done = $game->play($turn, $move->square);
268 156 $self->remember($done);
269 156 ▶ $self->_say('', $NAME{$turn} . ' plays ' . $move->name
Branch: 2 branches
BranchTrueFalseTotal
if $move->phase eq "play" 148 8 156
$move->turned == 1 ? : 54 94 148
270 . ', turning ' . $move->turned
271 . ($move->turned == 1 ? ' disc' : ' discs'))
272 if $move->phase eq 'play';
273 156 ▶ $self->_say('', $NAME{$turn} . ' places on ' . $move->name)
Branch: 1 branch
BranchTrueFalseTotal
if $move->phase eq "place" 8 148 156
274 if $move->phase eq 'place';
275 }
276  
277 316 $seen = $self->_announce_passes($game, $seen);
278 }
279  
280 8 $self->_finish($game);
281 8 return $game->result;
282 }
283  
284 8 ▶sub _intro {
Subroutine _intro: called CC=3 SCAR=11.0
285 8 my ($self) = @_;
286 8 my $me = $self->colour;
287 $self->_say(
288 8 ▶ 'Reversi. You are ' . $self->glyph($me) . ', ' . $NAME{$me} . '.',
Branch: 2 branches
BranchTrueFalseTotal
unless $self->quiet 6 2 8
$self->variant eq 'historic' ? : 4 2 6
289 $self->variant eq 'historic'
290 ? 'The historic opening: the first four discs are placed by the '
291 . 'players, on the centre four, and turn nothing.'
292 : 'The Othello opening: four discs are already on the board.',
293 'Enter a square such as d3. "help" for help, "quit" to give up.',
294 ) unless $self->quiet;
295 8 return;
296 }
297  
298 162 ▶sub keys_available {
Subroutine keys_available: called CC=4 SCAR=18.7
Pod documented
299 162 my ($self) = @_;
300 162 ▶ return 1 if $self->keysource;
Branch: 1 branch
BranchTrueFalseTotal
if $self->keysource 0 162 162
301 162 ▶ return 0 unless eval { -t $self->in };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { -t $self->in } } 162 0 162
302 0 ▶ return eval { require Term::ReadKey; 1 } ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Term::ReadKey; 1 } } ? : 0 0 0
303 }
304  
305 165 ▶sub picking {
Subroutine picking: called CC=6 SCAR=17.9
Pod documented
306 165 my ($self, @set) = @_;
307 165 ▶ $self->_picking($set[0] ? 1 : 0) if @set;
Branch: 2 branches
BranchTrueFalseTotal
if @set 1 164 165
$set[0] ? : 0 1 1
308 165 ▶ return 0 if $self->quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $self->quiet 2 163 165
309 163 ▶ return $self->_picking ? 1 : 0 if defined $self->_picking;
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->_picking 3 160 163
$self->_picking ? : 1 2 3
310 160 return $self->keys_available;
311 }
312  
313 5 ▶sub enter_raw {
Subroutine enter_raw: called CC=5 SCAR=20.4
Pod documented
314 5 my ($self) = @_;
315 5 ▶ return $self if $self->raw;
Branch: 1 branch
BranchTrueFalseTotal
if $self->raw 0 5 5
316 5 ▶ if ($self->keysource) { $self->raw(1); return $self }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->keysource) 4 1 5
317 1 ▶ return undef unless $self->keys_available;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->keys_available 1 0 1
318 0 ▶ return undef unless eval { Term::ReadKey::ReadMode(3, $self->in); 1 };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { Term::ReadKey::ReadMode(3, $self->in); 1 } } 0 0 0
319 0 $self->raw(1);
320 0 return $self;
321 }
322  
323 0 ▶sub leave_raw {
Subroutine leave_raw: not called CC=3 SCAR=24.8
Pod documented
324 0 my ($self) = @_;
325 0 ▶ return $self unless $self->raw;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->raw 0 0 0
326 0 ▶ eval { Term::ReadKey::ReadMode(0, $self->in) } unless $self->keysource;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->keysource 0 0 0
327 0 $self->raw(0);
328 0 return $self;
329 }
330  
331 48 ▶sub read_char {
Subroutine read_char: called CC=6 SCAR=27.1
Pod documented
332 48 my ($self, $wait) = @_;
333 48 my $pending = $self->pending;
334 48 ▶ return shift @$pending if @$pending;
Branch: 1 branch
BranchTrueFalseTotal
if @$pending 2 46 48
335 46 ▶ return $self->keysource->($wait) if $self->keysource;
Branch: 1 branch
BranchTrueFalseTotal
if $self->keysource 46 0 46
336 0 ▶ my $char = Term::ReadKey::ReadKey($wait ? 0 : -1, $self->in);
Branch: 1 branch
BranchTrueFalseTotal
$wait ? : 0 0 0
337 0 ▶ return $char if defined $char || $wait;
Branch: 1 branch
BranchTrueFalseTotal
if defined $char or $wait 0 0 0
Condition0%0/3
defined $char or $wait
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $char or $wait
defined $char $wait
Truth table0%0/3
A or B
A= defined $charB= $wait
ABresult
1X1
011
000
338 0 select undef, undef, undef, 0.05;
339 0 return Term::ReadKey::ReadKey(-1, $self->in);
340 }
341  
342 26 ▶sub read_key {
Subroutine read_key: called CC=4 SCAR=13.9
Pod documented
343 26 my ($self) = @_;
344 26 my $char = $self->read_char(1);
345 26 ▶ return undef unless defined $char;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char 1 25 26
346 25 ▶ return $CONTROL{$char} if $CONTROL{$char};
Branch: 1 branch
BranchTrueFalseTotal
if $Game::Reversi::Terminal::CONTROL{$char} 6 19 25
347 19 ▶ return $self->read_sequence if $char eq "\e";
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "\e" 11 8 19
348 8 return $char;
349 }
350  
351 11 ▶sub read_sequence {
Subroutine read_sequence: called CC=8 SCAR=21.0
Pod documented
352 11 my ($self) = @_;
353 11 my $opener = $self->read_char(0);
354 11 ▶ return 'escape' unless defined $opener;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opener 0 11 11
355 11 ▶ unless ($opener eq '[' || $opener eq 'O') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opener eq "[" or $opener eq "O") 2 9 11
Condition100%3/3
$opener eq "[" or $opener eq "O"
l!l&&r!l&&!r
812
MC/DC100%2/2
$opener eq "[" or $opener eq "O"
$opener eq "[" $opener eq "O"
Truth table100%3/3
A or B
A= $opener eq "["B= $opener eq "O"
ABresult
1X1
011
000
356 2 unshift @{ $self->pending }, $opener;
357 2 return 'escape';
358 }
359 9 my $tail = '';
360 9 ▶ while (length $tail < 8) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $tail < 8) 11 0 11
361 11 my $char = $self->read_char(0);
362 11 ▶ last unless defined $char;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char 0 11 11
363 11 $tail .= $char;
364 11 ▶ last if $char =~ /[A-Za-z~]/;
Branch: 1 branch
BranchTrueFalseTotal
if $char =~ /[A-Za-z~]/ 9 2 11
365 }
366 9 ▶ return $SEQUENCE{$tail} || 'escape';
Condition50%1/2
$Game::Reversi::Terminal::SEQUENCE{$tail} || 'escape'
l!l
90
MC/DC0%0/1
$Game::Reversi::Terminal::SEQUENCE{$tail} || 'escape'
$Game::Reversi::Terminal::SEQUENCE{$tail}
Truth table50%1/2
A
A= $Game::Reversi::Terminal::SEQUENCE{$tail}
Aresult
11
00
367 }
368  
369 7 ▶sub interactive {
Subroutine interactive: called CC=3 SCAR=11.4
Pod documented
370 7 my ($self) = @_;
371 7 ▶ my $out = $self->out or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $out = $self->out or return 0 7 0 7
372 7 ▶ return (eval { -t $out }) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { -t $out } } ? : 0 7 7
373 }
374  
375 7 ▶sub clear {
Subroutine clear: called CC=2 SCAR=10.9
Pod documented
376 7 my ($self) = @_;
377 7 ▶ return $self unless $self->interactive;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->interactive 7 0 7
378 0 my $fh = $self->out;
379 0 print {$fh} "\e[2J\e[3J\e[H";
380 0 return $self;
381 }
382  
383 8 ▶sub square_line {
Subroutine square_line: called CC=6 SCAR=19.6
Pod documented
384 8 my ($self, $game, $me, $square) = @_;
385  
386 8 my $name = Game::Reversi::Board->name_of($square);
387 8 my $trial = $game->clone;
388 8 my $move = $trial->play($me, $square);
389  
390 8 ▶ return "$name: " . $move->message
Branch: 1 branch
BranchTrueFalseTotal
if ref $move and $move->isa("Game::Reversi::Error") 0 8 8
Condition33%1/3
ref $move and $move->isa("Game::Reversi::Error")
!ll&&!rl&&r
080
MC/DC0%0/2
ref $move and $move->isa("Game::Reversi::Error")
ref $move $move->isa("Game::Reversi::Error")
Truth table33%1/3
A and B
A= ref $moveB= $move->isa("Game::Reversi::Error")
ABresult
0X0
100
111
391 if ref $move && $move->isa('Game::Reversi::Error');
392  
393 8 ▶ return "$name: placed, turning nothing yet" if $move->phase eq 'place';
Branch: 1 branch
BranchTrueFalseTotal
if $move->phase eq "place" 0 8 8
394  
395 8 my $count = $trial->counts;
396 return sprintf '%s: turns %d %s, and you would be %d to %d',
397 $name, $move->turned, ($move->turned == 1 ? 'disc' : 'discs'),
398 8 ▶ $count->{$me}, $count->{ $me eq 'b' ? 'w' : 'b' };
Branch: 2 branches
BranchTrueFalseTotal
$move->turned == 1 ? : 8 0 8
$me eq 'b' ? : 8 0 8
399 }
400  
401 0 ▶sub pick_help {
Subroutine pick_help: not called CC=1 SCAR=6.9
Pod documented
402 return (
403 0 'arrows walk the squares marked *, which are the only ones that play.',
404 'the line under the board says what the move would turn.',
405 'enter plays it, t goes back to typing, q gives up.',
406 );
407 }
408  
409 4 ▶sub pick_square {
Subroutine pick_square: called CC=24 SCAR=40.1
Pod documented
410 4 my ($self, $game, $me) = @_;
411  
412 4 my @legal = sort { $a <=> $b } map { $_->square } @{ $game->legal($me) };
413 4 ▶ return $self->_typed_turn($game, $me) unless @legal;
Branch: 1 branch
BranchTrueFalseTotal
unless @legal 0 4 4
414  
415 4 my $at = 0;
416 4 ▶ if (my $last = $self->last_move) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $last = $self->last_move) 0 4 4
417 0 my ($near) = sort { abs($a - $last->square) <=> abs($b - $last->square) }
418 0 .. $#legal;
419 0 ▶ $at = $near if defined $near;
Branch: 1 branch
BranchTrueFalseTotal
if defined $near 0 0 0
420 }
421  
422 4 my @notice;
423  
424 4 while (1) {
425 7 my $count = $game->counts;
426 7 $self->clear;
427 7 $self->_say('', $self->board_text($game, $me, $self->since,
428 cursor => $legal[$at], to_play => $me));
429 $self->_say(' discs: ' . $self->glyph(q{b}) . ' ' . $count->{b}
430 7 . ' ' . $self->glyph(q{w}) . ' ' . $count->{w});
431 7 $self->_say(' ' . $self->square_line($game, $me, $legal[$at]));
432 7 $self->_say(' ' . $_) for @notice;
433 7 @notice = ();
434 7 $self->_say(' ' . $self->_paint(
435 'arrows to choose, enter to play, ? for the keys', 'grid'));
436  
437 7 my $key = $self->read_key;
438 7 ▶ return 1 if !defined $key || $key eq 'eof' || $key eq 'interrupt';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $key or $key eq "eof" or $key eq "interrupt" 0 7 7
Condition33%2/6
not defined $key or $key eq "eof" or $key eq "interrupt"
l!l&&r!l&&!r
007
not defined $key or $key eq "eof"
l!l&&r!l&&!r
007
MC/DC0%0/3
not defined $key or $key eq "eof" or $key eq "interrupt"
not defined $key $key eq "eof" $key eq "interrupt"
Truth table25%1/4
not(A) or B or C
A= not defined $keyB= $key eq "eof"C= $key eq "interrupt"
ABCresult
1XX1
01X1
0011
0000
439  
440 7 ▶ if ($key eq 'left' || $key eq 'up') { $at = ($at - 1) % @legal; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "left" or $key eq "up") 0 7 7
Condition33%1/3
$key eq "left" or $key eq "up"
l!l&&r!l&&!r
007
MC/DC0%0/2
$key eq "left" or $key eq "up"
$key eq "left" $key eq "up"
Truth table33%1/3
A or B
A= $key eq "left"B= $key eq "up"
ABresult
1X1
011
000
441 7 ▶ if ($key eq 'right' || $key eq 'down' || $key eq 'tab') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "right" or $key eq "down" or $key eq "tab") 2 5 7
Condition66%4/6
$key eq "right" or $key eq "down" or $key eq "tab"
l!l&&r!l&&!r
205
$key eq "right" or $key eq "down"
l!l&&r!l&&!r
205
MC/DC33%1/3
$key eq "right" or $key eq "down" or $key eq "tab"
$key eq "right" $key eq "down" $key eq "tab"
Truth table50%2/4
A or B or C
A= $key eq "right"B= $key eq "down"C= $key eq "tab"
ABCresult
1XX1
01X1
0011
0000
442 2 $at = ($at + 1) % @legal;
443 2 next;
444 }
445 5 ▶ if ($key eq 'home') { $at = 0; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "home") 0 5 5
446 5 ▶ if ($key eq 'end') { $at = $#legal; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "end") 0 5 5
447  
448 5 ▶ if ($key eq 'enter' || $key eq ' ') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "enter" or $key eq " ") 1 4 5
Condition66%2/3
$key eq "enter" or $key eq " "
l!l&&r!l&&!r
104
MC/DC50%1/2
$key eq "enter" or $key eq " "
$key eq "enter" $key eq " "
Truth table66%2/3
A or B
A= $key eq "enter"B= $key eq " "
ABresult
1X1
011
000
449 1 my $played = $game->play($me, $legal[$at]);
450 1 ▶ if (ref $played && $played->isa('Game::Reversi::Error')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $played and $played->isa("Game::Reversi::Error")) 0 1 1
Condition33%1/3
ref $played and $played->isa("Game::Reversi::Error")
!ll&&!rl&&r
010
MC/DC0%0/2
ref $played and $played->isa("Game::Reversi::Error")
ref $played $played->isa("Game::Reversi::Error")
Truth table33%1/3
A and B
A= ref $playedB= $played->isa("Game::Reversi::Error")
ABresult
0X0
100
111
451 0 @notice = ($played->message . '.');
452 0 next;
453 }
454 1 $self->remember($played);
455 1 ▶ $self->_say(' you play ' . $played->name
Branch: 2 branches
BranchTrueFalseTotal
$played->phase eq 'play' ? : 1 0 1
$played->turned == 1 ? : 1 0 1
456 . ($played->phase eq 'play'
457 ? ', turning ' . $played->turned
458 . ($played->turned == 1 ? ' disc' : ' discs')
459 : ''));
460 1 return 0;
461 }
462  
463 4 ▶ if ($key eq 'q') { return 1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "q") 3 1 4
464 1 ▶ if ($key eq 't') { $self->picking(0); return $self->_typed_turn($game, $me) }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "t") 0 1 1
465 1 ▶ if ($key eq '?') { @notice = $self->pick_help; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "?") 0 1 1
466  
467 1 @notice = ('that key does nothing here. ? for the ones that do');
468 }
469 }
470  
471 163 ▶sub _human_turn {
Subroutine _human_turn: called CC=3 SCAR=11.0
472 163 my ($self, $game, $me) = @_;
473  
474 163 ▶ if ($self->picking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->picking) 1 162 163
475 1 ▶ return $self->pick_square($game, $me) if $self->enter_raw;
Branch: 1 branch
BranchTrueFalseTotal
if $self->enter_raw 0 1 1
476 1 $self->picking(0);
477 }
478  
479 163 return $self->_typed_turn($game, $me);
480 }
481  
482 163 ▶sub _typed_turn {
Subroutine _typed_turn: called CC=15 SCAR=27.4
483 163 my ($self, $game, $me) = @_;
484  
485 163 while (1) {
486 168 my $count = $game->counts;
487 168 $self->_say("", $self->board_text($game, $me, $self->since));
488 $self->_say(
489 ' discs: ' . $self->glyph(q{b}) . ' ' . $count->{b} . ' '
490 . $self->glyph(q{w}) . ' ' . $count->{w},
491 168 ▶ ' ' . ($game->phase eq 'opening'
Branch: 1 branch
BranchTrueFalseTotal
$game->phase eq 'opening' ? : 15 153 168
492 ? 'Place a disc on one of the centre four.'
493 : 'Your move. The squares marked * are the ones that outflank something.'),
494 );
495  
496 168 my $answer = $self->_ask(' > ');
497  
498 168 ▶ return 1 unless defined $answer;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $answer 1 167 168
499 167 ▶ return 1 if $answer eq 'quit' || $answer eq 'resign';
Branch: 1 branch
BranchTrueFalseTotal
if $answer eq "quit" or $answer eq "resign" 2 165 167
Condition66%2/3
$answer eq "quit" or $answer eq "resign"
l!l&&r!l&&!r
20165
MC/DC50%1/2
$answer eq "quit" or $answer eq "resign"
$answer eq "quit" $answer eq "resign"
Truth table66%2/3
A or B
A= $answer eq "quit"B= $answer eq "resign"
ABresult
1X1
011
000
500  
501 165 ▶ if ($answer eq 'help') {
Branch: 1 branch
BranchTrueFalseTotal
if ($answer eq "help") 1 164 165
502 1 $self->_help($game, $me);
503 1 next;
504 }
505 164 ▶ if ($answer eq 'board' || $answer eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($answer eq "board" or $answer eq "") 0 164 164
Condition33%1/3
$answer eq "board" or $answer eq ""
l!l&&r!l&&!r
00164
MC/DC0%0/2
$answer eq "board" or $answer eq ""
$answer eq "board" $answer eq ""
Truth table33%1/3
A or B
A= $answer eq "board"B= $answer eq ""
ABresult
1X1
011
000
506 0 next;
507 }
508  
509 164 my $square = Game::Reversi::Notation->text_to_square($answer);
510 164 ▶ if (!defined $square) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $square) 3 161 164
511 3 $self->_say(' "' . $answer . '" is not a square. Try d3, or "help".');
512 3 next;
513 }
514  
515 161 my $played = $game->play($me, $square);
516 161 ▶ $self->remember($played) unless ref $played && $played->isa("Game::Reversi::Error");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $played and $played->isa("Game::Reversi::Error") 160 1 161
Condition66%2/3
ref $played and $played->isa("Game::Reversi::Error")
!ll&&!rl&&r
01601
MC/DC50%1/2
ref $played and $played->isa("Game::Reversi::Error")
ref $played $played->isa("Game::Reversi::Error")
Truth table66%2/3
A and B
A= ref $playedB= $played->isa("Game::Reversi::Error")
ABresult
0X0
100
111
517 161 ▶ if (ref $played && $played->isa('Game::Reversi::Error')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $played and $played->isa("Game::Reversi::Error")) 1 160 161
Condition66%2/3
ref $played and $played->isa("Game::Reversi::Error")
!ll&&!rl&&r
01601
MC/DC50%1/2
ref $played and $played->isa("Game::Reversi::Error")
ref $played $played->isa("Game::Reversi::Error")
Truth table66%2/3
A and B
A= ref $playedB= $played->isa("Game::Reversi::Error")
ABresult
0X0
100
111
518 1 $self->_say(' ' . $played->message . '.');
519 1 next;
520 }
521  
522 160 ▶ $self->_say(' you play ' . $played->name
Branch: 2 branches
BranchTrueFalseTotal
$played->phase eq 'play' ? : 152 8 160
$played->turned == 1 ? : 65 87 152
523 . ($played->phase eq 'play'
524 ? ', turning ' . $played->turned
525 . ($played->turned == 1 ? ' disc' : ' discs')
526 : ''));
527 160 return 0;
528 }
529 }
530  
531 1 ▶sub _help {
Subroutine _help: called CC=1 SCAR=0.0
532 1 my ($self, $game, $me) = @_;
533 1 $self->_say(
534 '',
535 ' Enter a square as a file and a rank, such as d3 or f5.',
536 ' A move must outflank at least one of the other side\'s discs;',
537 ' every disc it outflanks is turned, and you do not get to choose.',
538 ' The squares marked * are the ones you can play.',
539 ' A turn with no legal move is forfeited for you automatically.',
540 ' The game ends when neither side can move, which can happen with',
541 ' the board not full. "quit" gives up.',
542 '',
543 );
544 1 return;
545 }
546  
547 316 ▶sub _announce_passes {
Subroutine _announce_passes: called CC=3 SCAR=11.0
548 316 my ($self, $game, $seen) = @_;
549 316 my $events = $game->events;
550 316 for my $i ($seen .. $#$events) {
551 325 my $event = $events->[$i];
552 325 ▶ next unless $event->{kind} eq 'pass';
Branch: 1 branch
BranchTrueFalseTotal
unless $event->{"kind"} eq "pass" 321 4 325
553 4 my $colour = $event->{payload}{colour};
554 4 $self->_say(' ' . $NAME{$colour} . ' has no legal move, so that turn is '
555 . 'forfeited and the other side plays again.');
556 }
557 316 return scalar @$events;
558 }
559  
560 9 ▶sub _finish {
Subroutine _finish: called CC=7 SCAR=19.6
561 9 my ($self, $game) = @_;
562 9 my $result = $game->result;
563 9 ▶ return unless $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 9 9
564  
565 9 $self->_say('', $self->board_text($game, undef), '');
566  
567 9 my $count = $result->counts;
568 $self->_say(' discs on the board: ' . $self->glyph(q{b}) . ' ' . $count->{b}
569 9 . ' ' . $self->glyph(q{w}) . ' ' . $count->{w});
570  
571 9 my $score = $result->score;
572 9 ▶ if ($score) {
Branch: 1 branch
BranchTrueFalseTotal
if ($score) 6 3 9
573 6 my $empty = Game::Reversi::Board->empties($game->board);
574 $self->_say(' final score: ' . $self->glyph(q{b}) . ' ' . $score->{b}
575 . ' ' . $self->glyph(q{w}) . ' ' . $score->{w}
576 6 ▶ . ($empty ? " (the $empty empty squares go to the winner)" : ''));
Branch: 1 branch
BranchTrueFalseTotal
$empty ? : 1 5 6
577 }
578  
579 9 my $me = $self->colour;
580 9 ▶ $self->_say('', !defined $result->winner ? ' A tie.'
Branch: 2 branches
BranchTrueFalseTotal
!defined($result->winner) ? : 0 9 9
$result->winner eq $me ? : 0 9 9
581 : $result->winner eq $me ? ' You win.'
582 : ' You lose.');
583 9 ▶ $self->_say(' (' . $result->result . ')') unless $result->natural;
Branch: 1 branch
BranchTrueFalseTotal
unless $result->natural 3 6 9
584 9 return;
585 }
586  
587 0 ▶sub _usage {
Subroutine _usage: not called CC=1 SCAR=6.9
588 0 return <<'USAGE';
589 reversi - play Reversi in a terminal
590  
591 reversi [--level 1..5] [--variant historic|othello]
592 [--colour b|w] [--seed STRING] [--ascii]
593  
594 --level how hard the opponent is, 1 to 5. Default 3.
595 --variant historic, the real Reversi opening where the players place the
596 first four discs themselves, or othello, where those four are
597 already down. Default historic.
598 --colour b to play dark and move first, w to play light. Default b.
599 --seed makes a game reproducible, and decides how the bot opens.
600 --ascii X and O on a plain grid, for a terminal without box characters.
601 --nopick type the squares out instead of pointing at them.
602  
603 On a terminal the arrow keys walk the squares marked *, which are the only
604 ones that play, and the line under the board says what the move would turn
605 and what the score would become. Enter plays it, t goes back to typing and
606 ? lists the keys. Needs Term::ReadKey; without it the squares are typed.
607  
608 The square the last move went on is bracketed and the discs it turned are
609 drawn ringed, so both are visible with --ascii and with colour off.
610  
611 Exit status is 0 if you won or tied, 1 if you lost, 2 for a bad option.
612 USAGE
613 }
614  
615 0 ▶sub run {
Subroutine run: not called CC=17 SCAR=57.2
Pod documented
616 0 my ($class, @argv) = @_;
617 0 my %opt = (level => 3, variant => 'historic', colour => 'b', seed => 'reversi');
618  
619 0 my $ok = eval {
620 0 ▶ local $SIG{__WARN__} = sub { print STDERR "reversi: $_[0]" };
Subroutine __ANON__: not called CC=1 SCAR=6.9
621 0 Getopt::Long::GetOptionsFromArray(\@argv, \%opt,
622 'level=i', 'variant=s', 'colour=s', 'seed=s', 'ascii', 'pick!', 'help|h');
623 };
624 0 ▶ if (!$ok) { print STDERR _usage(); return 2 }
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
625 0 ▶ if ($opt{help}) { print _usage(); return 0 }
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"help"}) 0 0 0
626 0 ▶ if (@argv) { print STDERR "reversi: not an option: $argv[0]\n", _usage(); return 2 }
Branch: 1 branch
BranchTrueFalseTotal
if (@argv) 0 0 0
627  
628 0 ▶ $opt{colour} = 'b' if lc $opt{colour} eq 'dark' || lc $opt{colour} eq 'black';
Branch: 1 branch
BranchTrueFalseTotal
if lc $opt{"colour"} eq "dark" or lc $opt{"colour"} eq "black" 0 0 0
Condition0%0/3
lc $opt{"colour"} eq "dark" or lc $opt{"colour"} eq "black"
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $opt{"colour"} eq "dark" or lc $opt{"colour"} eq "black"
lc $opt{"colour"} eq "dark" lc $opt{"colour"} eq "black"
Truth table0%0/3
A or B
A= lc $opt{"colour"} eq "dark"B= lc $opt{"colour"} eq "black"
ABresult
1X1
011
000
629 0 ▶ $opt{colour} = 'w' if lc $opt{colour} eq 'light' || lc $opt{colour} eq 'white';
Branch: 1 branch
BranchTrueFalseTotal
if lc $opt{"colour"} eq "light" or lc $opt{"colour"} eq "white" 0 0 0
Condition0%0/3
lc $opt{"colour"} eq "light" or lc $opt{"colour"} eq "white"
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $opt{"colour"} eq "light" or lc $opt{"colour"} eq "white"
lc $opt{"colour"} eq "light" lc $opt{"colour"} eq "white"
Truth table0%0/3
A or B
A= lc $opt{"colour"} eq "light"B= lc $opt{"colour"} eq "white"
ABresult
1X1
011
000
630  
631 0 my $terminal = eval {
632 $class->new(
633 level => $opt{level}, variant => $opt{variant},
634 colour => $opt{colour}, seed => $opt{seed},
635 ascii => $opt{ascii},
636 0 ▶ (defined $opt{pick} ? (picking => $opt{pick} ? 1 : 0) : ()));
Branch: 2 branches
BranchTrueFalseTotal
defined $opt{'pick'} ? : 0 0 0
$opt{'pick'} ? : 0 0 0
637 };
638 0 ▶ if (!$terminal) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($terminal) 0 0 0
639 0 ▶ my $why = $@ || "could not start\n";
Condition0%0/2
$@ || "could not start\n"
l!l
00
MC/DC0%0/1
$@ || "could not start\n"
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
640 0 $why =~ s/ at \S+ line \d+\.?\n?\z//;
641 0 $why =~ s/\AGame::Reversi(?:::\w+)*: //;
642 0 chomp $why;
643 0 print STDERR "reversi: $why\n";
644 0 return 2;
645 }
646  
647 0 local @SIG{qw(INT TERM HUP)};
648 0 for my $sig (qw(INT TERM HUP)) {
649 0 ▶ $SIG{$sig} = sub { $terminal->leave_raw; $SIG{$sig} = 'DEFAULT'; kill $sig, $$ };
Subroutine __ANON__: not called CC=1 SCAR=6.9
650 }
651  
652 0 my $result = eval { $terminal->start };
653 0 my $died = $@;
654 0 $terminal->leave_raw;
655 0 ▶ die $died if $died;
Branch: 1 branch
BranchTrueFalseTotal
if $died 0 0 0
656 0 ▶ return 0 unless $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 0 0
657 0 ▶ return 0 if !defined $result->winner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result->winner 0 0 0
658 0 ▶ return 0 if $result->winner eq $opt{colour};
Branch: 1 branch
BranchTrueFalseTotal
if $result->winner eq $opt{"colour"} 0 0 0
659 0 return 1;
660 }
661  
662  
663 2 1;
664  
665 __END__
↑ Summary Reversi/Move.pm »