| 1 | package Game::Checkers::Squares; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 31 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 31 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 32 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 31 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 31 | NE => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | NW => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | SE => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | SW => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 31 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 32 | our (@DIRS, @DIR_NAME, %DIR_INDEX, @STEP, @JUMP_OVER, @JUMP_TO, @ROW, @COL, @DELTA, %FORWARD); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 32 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 32 | @DIRS = (NE, NW, SE, SW); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 32 | @DIR_NAME = qw/NE NW SE SW/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 32 | %DIR_INDEX = (NE => NE, NW => NW, SE => SE, SW => SW); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 32 | @DELTA = ([-1, 1], [-1, -1], [1, 1], [1, -1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | %FORWARD = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | black => [SE, SW], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | white => [NE, NW], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1169 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1169 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1169 | ▶ | die "square must be 1 .. 32, got " . (defined $n ? "'$n'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%6/9
defined $n and $n =~ /^[0-9]+$/ and $n >= 1 and $n <= 32
defined $n and $n =~ /^[0-9]+$/ and $n >= 1
defined $n and $n =~ /^[0-9]+$/
MC/DC50%2/4
defined $n and $n =~ /^[0-9]+$/ and $n >= 1 and $n <= 32
defined $n
$n =~ /^[0-9]+$/
$n >= 1
$n <= 32
Truth table60%3/5
A and B and C and D
A= defined $nB= $n =~ /^[0-9]+$/C= $n >= 1D= $n <= 32
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | unless defined $n && $n =~ m/^[0-9]+$/ && $n >= 1 && $n <= 32; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1167 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1024 | ▶ | sub _coords { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coords: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1024 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1024 | my $row = int(($n - 1) / 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1024 | my $i = ($n - 1) % 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1024 | ▶ | return ($row, $row % 2 == 0 ? ($i * 2) + 1 : $i * 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 13924 | ▶ | sub _square { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_square: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 13924 | my ($row, $col) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 13924 | ▶ | return 0 if $row < 0 || $row > 7 || $col < 0 || $col > 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$row < 0 or $row > 7 or $col < 0 or $col > 7
$row < 0 or $row > 7 or $col < 0
$row < 0 or $row > 7
MC/DC100%4/4
$row < 0 or $row > 7 or $col < 0 or $col > 7
$row < 0
$row > 7
$col < 0
$col > 7
Truth table100%5/5
A or B or C or D
A= $row < 0B= $row > 7C= $col < 0D= $col > 7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12129 | ▶ | return 0 unless ($row + $col) % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 8829 | return ($row * 4) + ($col >> 1) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 32 | for my $n (1 .. 32) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1024 | my ($row, $col) = _coords($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1024 | $ROW[$n] = $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1024 | $COL[$n] = $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1024 | for my $dir (@DIRS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4096 | my ($dr, $dc) = @{$DELTA[$dir]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4096 | my $i = ($n * 4) + $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4096 | my $step = _square($row + $dr, $col + $dc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4096 | $STEP[$i] = $step; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4096 | ▶ | my $landing = $step ? _square($row + ($dr * 2), $col + ($dc * 2)) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4096 | ▶ | $JUMP_OVER[$i] = $landing ? $step : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4096 | $JUMP_TO[$i] = $landing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 34 | ▶ | sub coords { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coords: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 34 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 34 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 32 | return ($ROW[$n], $COL[$n]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6628 | ▶ | sub square { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
square: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6628 | my ($row, $col) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6628 | ▶ | return undef unless defined $row && defined $col; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $row and defined $col
MC/DC0%0/2
defined $row and defined $col
defined $row
defined $col
Truth table33%1/3
A and B
A= defined $rowB= defined $col
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6628 | ▶ | return _square($row, $col) || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_square($row, $col) || undef
MC/DC100%1/1
_square($row, $col) || undef
_square($row, $col)
Truth table100%2/2
A
A= _square($row, $col)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub row_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_of: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $ROW[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub col_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_of: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return $COL[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1101 | ▶ | sub coord_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coord_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1101 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1101 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1101 | return sprintf '%s%d', chr(ord('a') + $COL[$n]), 8 - $ROW[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 68 | ▶ | sub coord_square { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coord_square: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 68 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 68 | ▶ | return undef unless defined $name && $name =~ m/^([a-h])([1-8])$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and $name =~ /^([a-h])([1-8])$/i
MC/DC50%1/2
defined $name and $name =~ /^([a-h])([1-8])$/i
defined $name
$name =~ /^([a-h])([1-8])$/i
Truth table66%2/3
A and B
A= defined $nameB= $name =~ /^([a-h])([1-8])$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 64 | ▶ | return _square(8 - $2, ord(lc $1) - ord('a')) || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_square(8 - $2, ord(lc $1) - 97) || undef
MC/DC100%1/1
_square(8 - $2, ord(lc $1) - 97) || undef
_square(8 - $2, ord(lc $1) - 97)
Truth table100%2/2
A
A= _square(8 - $2, ord(lc $1) - 97)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 19 | ▶ | sub steps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
steps: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 19 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 19 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 19 | my %step; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 19 | for my $dir (@DIRS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 76 | ▶ | $step{$DIR_NAME[$dir]} = $STEP[($n * 4) + $dir] || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$Game::Checkers::Squares::STEP[$n * 4 + $dir] || undef
MC/DC100%1/1
$Game::Checkers::Squares::STEP[$n * 4 + $dir] || undef
$Game::Checkers::Squares::STEP[$n * 4 + $dir]
Truth table100%2/2
A
A= $Game::Checkers::Squares::STEP[$n * 4 + $dir]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 19 | return \%step; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | ▶ | sub jump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jump: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | my ($n, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | $dir = dir_index($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | my $i = ($n * 4) + $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | ▶ | return () unless $JUMP_TO[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | return ($JUMP_OVER[$i], $JUMP_TO[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 10 | ▶ | sub dir_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_index: called CC=6 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 10 | ▶ | return $dir if defined $dir && $dir =~ m/^[0-3]$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $dir and $dir =~ /^[0-3]$/
MC/DC50%1/2
defined $dir and $dir =~ /^[0-3]$/
defined $dir
$dir =~ /^[0-3]$/
Truth table66%2/3
A and B
A= defined $dirB= $dir =~ /^[0-3]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | die "direction must be NE, NW, SE, SW or 0 .. 3, got " . (defined $dir ? "'$dir'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | ▶ | unless defined $dir && exists $DIR_INDEX{uc $dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $dir and exists $Game::Checkers::Squares::DIR_INDEX{uc $dir}
MC/DC0%0/2
defined $dir and exists $Game::Checkers::Squares::DIR_INDEX{uc $dir}
defined $dir
exists $Game::Checkers::Squares::DIR_INDEX{uc $dir}
Truth table33%1/3
A and B
A= defined $dirB= exists $Game::Checkers::Squares::DIR_INDEX{uc $dir}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | return $DIR_INDEX{uc $dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | sub dir_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | return $DIR_NAME[dir_index($dir)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | sub forward_dirs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forward_dirs: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | my ($side) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | die "side must be black or white, got " . (defined $side ? "'$side'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | unless defined $side && $FORWARD{$side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $side and $Game::Checkers::Squares::FORWARD{$side}
MC/DC0%0/2
defined $side and $Game::Checkers::Squares::FORWARD{$side}
defined $side
$Game::Checkers::Squares::FORWARD{$side}
Truth table33%1/3
A and B
A= defined $sideB= $Game::Checkers::Squares::FORWARD{$side}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | return @{$FORWARD{$side}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | ▶ | sub crowning { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
crowning: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | my ($n, $side) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | die "side must be black or white, got " . (defined $side ? "'$side'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | ▶ | unless defined $side && $FORWARD{$side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $side and $Game::Checkers::Squares::FORWARD{$side}
MC/DC50%1/2
defined $side and $Game::Checkers::Squares::FORWARD{$side}
defined $side
$Game::Checkers::Squares::FORWARD{$side}
Truth table66%2/3
A and B
A= defined $sideB= $Game::Checkers::Squares::FORWARD{$side}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 6 | ▶ | return $side eq 'black' ? ($n >= 29 ? 1 : 0) : ($n <= 4 ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||