| 1 | package Game::Merrills::Points; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 85 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 85 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 86 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 85 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 85 | POINTS => 24, | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | SIZE => 7, | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 85 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 86 | our (@NAME, %POINT, @ROW, @COL, @ADJACENT, @MILLS, @MILLS_OF); | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 86 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 86 | @NAME = qw/ | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | a7 d7 g7 | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | b6 d6 f6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | c5 d5 e5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | a4 b4 c4 e4 f4 g4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | c3 d3 e3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | b2 d2 f2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | a1 d1 g1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | /; | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 86 | @ADJACENT = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | [1, 9], [0, 2, 4], [1, 14], | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | [4, 10], [1, 3, 5, 7], [4, 13], | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | [7, 11], [4, 6, 8], [7, 12], | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | [0, 10, 21], [3, 9, 11, 18], [6, 10, 15], | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | [8, 13, 17], [5, 12, 14, 20], [2, 13, 23], | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | [11, 16], [15, 17, 19], [12, 16], | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | [10, 19], [16, 18, 20, 22], [13, 19], | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | [9, 22], [19, 21, 23], [14, 22], | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 86 | @MILLS = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | [0, 1, 2], [3, 4, 5], [6, 7, 8], | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | [9, 10, 11], [12, 13, 14], | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | [15, 16, 17], [18, 19, 20], [21, 22, 23], | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | [0, 9, 21], [3, 10, 18], [6, 11, 15], | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | [1, 4, 7], [16, 19, 22], | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [8, 12, 17], [5, 13, 20], [2, 14, 23], | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 86 | for my $n (0 .. $#NAME) { | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2064 | my ($file, $rank) = $NAME[$n] =~ m/^([a-g])([1-7])$/; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2064 | $POINT{$NAME[$n]} = $n; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2064 | $ROW[$n] = SIZE - $rank; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2064 | $COL[$n] = ord($file) - ord('a'); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2064 | $MILLS_OF[$n] = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 86 | for my $mill (@MILLS) { | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1376 | push @{$MILLS_OF[$_]}, $mill for @{$mill}; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2950648 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2950648 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2950648 | ▶ | die 'point must be 0 .. 23, got ' . (defined $n ? "'$n'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
defined $n and $n =~ /^[0-9]+$/ and $n < 24
defined $n and $n =~ /^[0-9]+$/
MC/DC100%3/3
defined $n and $n =~ /^[0-9]+$/ and $n < 24
defined $n
$n =~ /^[0-9]+$/
$n < 24
Truth table100%4/4
A and B and C
A= defined $nB= $n =~ /^[0-9]+$/C= $n < 24
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | unless defined $n && $n =~ m/^[0-9]+$/ && $n < POINTS; | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2950600 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 61972 | ▶ | sub all_points { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_points: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 61972 | return (0 .. POINTS - 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 44641 | ▶ | sub point { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
point: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 44641 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 44641 | ▶ | return undef unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 44640 | return $POINT{lc $name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 348215 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 348215 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 348215 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 348207 | return $NAME[$n]; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 154332 | ▶ | sub row_of { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 154332 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 154332 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 154326 | return $ROW[$n]; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 154176 | ▶ | sub col_of { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 154176 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 154176 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 154170 | return $COL[$n]; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2013 | ▶ | sub adjacent { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adjacent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2013 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2013 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2007 | return @{$ADJACENT[$n]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1055 | ▶ | sub is_adjacent { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_adjacent: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1055 | my ($from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1055 | _check($from); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1055 | _check($to); | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1049 | ▶ | return scalar(grep { $_ == $to } @{$ADJACENT[$from]}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2042 | ▶ | sub mills { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mills: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2042 | return map { [@{$_}] } @MILLS; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 32 | ▶ | sub mills_of { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mills_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 32 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 32 | _check($n); | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 26 | return map { [@{$_}] } @{$MILLS_OF[$n]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 86 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||