| 1 | package Game::Merrills::Rules; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 83 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 83 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 83 | ▶ | use Game::Merrills::Points; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 83 | ▶ | use Game::Merrills::Board; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 83 | ▶ | use Game::Merrills::Move; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 83 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 83 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 83 | HAND_WHITE => 24, | |||||||||||||||||||||||||||||||||||||||||
| 14 | HAND_BLACK => 25, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 83 | }; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 83 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 83 | RM_FROM => Game::Merrills::Move::RM_FROM, | |||||||||||||||||||||||||||||||||||||||||
| 19 | RM_TO => Game::Merrills::Move::RM_TO, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | RM_REMOVE => Game::Merrills::Move::RM_REMOVE, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | RM_CLOSES => Game::Merrills::Move::RM_CLOSES, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | RM_FLEW => Game::Merrills::Move::RM_FLEW, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 83 | }; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 6482465 | ▶ | sub _value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 6482465 | my ($side) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 27 | die 'side must be white or black, got ' . (defined $side ? "'$side'" : 'undef') | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 6482465 | ▶ | unless defined $side && exists $Game::Merrills::Board::VALUE{$side}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $side and exists $Game::Merrills::Board::VALUE{$side}
MC/DC100%2/2
defined $side and exists $Game::Merrills::Board::VALUE{$side}
defined $side
exists $Game::Merrills::Board::VALUE{$side}
Truth table100%3/3
A and B
A= defined $sideB= exists $Game::Merrills::Board::VALUE{$side}
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 6482458 | return $Game::Merrills::Board::VALUE{$side}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2622420 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2622420 | my ($position) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | die 'a position is an arrayref of 26 values' | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 2622420 | ▶ | unless ref $position eq 'ARRAY' && @{$position} == 26; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $position eq "ARRAY" and @{$position;} == 26
MC/DC100%2/2
ref $position eq "ARRAY" and @{$position;} == 26
ref $position eq "ARRAY"
@{$position;} == 26
Truth table100%3/3
A and B
A= ref $position eq "ARRAY"B= @{$position;} == 26
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2622414 | return $position; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 2030093 | ▶ | sub _in_mill { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_mill: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 2030093 | my ($position, $point) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 2030093 | ▶ | my $value = $position->[$point] or return 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2030093 | for my $mill (@{ $Game::Merrills::Points::MILLS_OF[$point] }) { | |||||||||||||||||||||||||||||||||||||||||
| 43 | 3743842 | ▶ | return 1 if $position->[ $mill->[0] ] == $value | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$$position[$mill->[0]] == $value and $$position[$mill->[1]] == $value and $$position[$mill->[2]] == $value
$$position[$mill->[0]] == $value and $$position[$mill->[1]] == $value
MC/DC100%3/3
$$position[$mill->[0]] == $value and $$position[$mill->[1]] == $value and $$position[$mill->[2]] == $value
$$position[$mill->[0]] == $value
$$position[$mill->[1]] == $value
$$position[$mill->[2]] == $value
Truth table100%4/4
A and B and C
A= $$position[$mill->[0]] == $valueB= $$position[$mill->[1]] == $valueC= $$position[$mill->[2]] == $value
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | && $position->[ $mill->[1] ] == $value | ||||||||||||||||||||||||||||||||||||||||||
| 45 | && $position->[ $mill->[2] ] == $value; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1487984 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 14495297 | ▶ | sub _closes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_closes: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 14495297 | my ($position, $value, $from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 14495297 | my $closed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 14495297 | for my $mill (@{ $Game::Merrills::Points::MILLS_OF[$to] }) { | |||||||||||||||||||||||||||||||||||||||||
| 54 | 28990594 | my $whole = 1; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 28990594 | for my $point (@{$mill}) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 43471819 | ▶ | next if $point == $to; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 32740191 | ▶ | next if $position->[$point] == $value && !(defined $from && $point == $from); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$position->[$point] == $value and not defined $from && $point == $from
defined $from && $point == $from
MC/DC100%3/3
$position->[$point] == $value and not defined $from && $point == $from
$position->[$point] == $value
defined $from
$point == $from
Truth table100%4/4
A and not(B && C)
A= $position->[$point] == $valueB= defined $fromC= $point == $from
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 28520627 | $whole = 0; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 28520627 | last; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 28990594 | $closed += $whole; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 14495297 | return $closed; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 378051 | ▶ | sub _removable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_removable: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 378051 | my ($position, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 378051 | my (@loose, @all); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 378051 | for my $point (0 .. 23) { | |||||||||||||||||||||||||||||||||||||||||
| 70 | 9073224 | ▶ | next unless $position->[$point] == -$value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 2030093 | push @all, $point; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 2030093 | ▶ | push @loose, $point unless _in_mill($position, $point); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 378051 | ▶ | return @loose ? @loose : @all; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 3266 | ▶ | sub position { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
position: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 3266 | my ($board) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 3266 | return [ @{ $board->cells }, $board->in_hand('white'), $board->in_hand('black') ]; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 5137 | ▶ | sub board { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
board: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 5137 | my ($position) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 5137 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 85 | return Game::Merrills::Board->new( | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 5136 | cells => [ @{$position}[ 0 .. 23 ] ], | |||||||||||||||||||||||||||||||||||||||||
| 87 | hand => { white => $position->[HAND_WHITE], black => $position->[HAND_BLACK] } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 697 | ▶ | sub closes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
closes: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 697 | my ($position, $side, $from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 697 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 696 | Game::Merrills::Points::_check($to); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 695 | ▶ | Game::Merrills::Points::_check($from) if defined $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 694 | return _closes($position, _value($side), $from, $to); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 24 | ▶ | sub removable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | my ($position, $side) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 24 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 22 | return _removable($position, _value($side)); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2616558 | ▶ | sub _phase { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_phase: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2616558 | my ($position, $value, $flying) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 2616558 | ▶ | return 'placing' if $position->[ $value > 0 ? HAND_WHITE : HAND_BLACK ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 918256 | ▶ | return 'moving' unless $flying; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 899624 | my $men = grep { $_ == $value } @{$position}[ 0 .. 23 ]; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 899624 | ▶ | return $men == 3 ? 'flying' : 'moving'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 42693 | ▶ | sub phase { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
phase: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 42693 | my ($position, $side, $flying) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 42693 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 42693 | ▶ | return _phase($position, _value($side), defined $flying ? $flying : 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 996759 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 996759 | my ($position, $side, $flying) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 996759 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 996757 | my $value = _value($side); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 996755 | ▶ | my $phase = _phase($position, $value, defined $flying ? $flying : 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 996755 | my (@moves, @takes, $asked, @own); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 996755 | ▶ | @own = grep { $position->[$_] == $value } 0 .. 23 if $phase eq 'flying'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 996755 | for my $to (0 .. 23) { | |||||||||||||||||||||||||||||||||||||||||
| 128 | 23922099 | ▶ | next if $position->[$to]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | my @from = $phase eq 'placing' ? (undef) | ||||||||||||||||||||||||||||||||||||||||||
| 130 | : $phase eq 'flying' ? @own | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 14044543 | ▶ | : grep { $position->[$_] == $value } @{ $Game::Merrills::Points::ADJACENT[$to] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 14044543 | for my $from (@from) { | |||||||||||||||||||||||||||||||||||||||||
| 133 | my $flew = $phase eq 'flying' | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 14494604 | ▶ | && !grep { $_ == $from } @{ $Game::Merrills::Points::ADJACENT[$to] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$phase eq 'flying' && !grep({$_ == $from;} @{$Game::Merrills::Points::ADJACENT[$to];})
MC/DC100%2/2
$phase eq 'flying' && !grep({$_ == $from;} @{$Game::Merrills::Points::ADJACENT[$to];})
$phase eq 'flying'
!grep({$_ == $from;} @{$Game::Merrills::Points::ADJACENT[$to];})
Truth table100%3/3
A && not(B)
A= $phase eq 'flying'B= !grep({$_ == $from;} @{$Game::Merrills::Points::ADJACENT[$to];})
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 14494604 | my $closed = _closes($position, $value, $from, $to); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 14494604 | ▶ | unless ($closed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 14025231 | ▶ | push @moves, [ $from, $to, undef, 0, $flew ? 1 : 0 ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 14025231 | next; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 469373 | ▶ | @takes = _removable($position, $value) unless $asked++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 469373 | ▶ | die 'a mill closed and there is no man to take' unless @takes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 469372 | ▶ | push @moves, map { [ $from, $to, $_, $closed, $flew ? 1 : 0 ] } @takes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 996754 | return \@moves; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1577110 | ▶ | sub has_move { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_move: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 1577110 | my ($position, $side, $flying) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 1577110 | _check($position); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 1577110 | my $value = _value($side); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 1577110 | ▶ | my $phase = _phase($position, $value, defined $flying ? $flying : 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 1577110 | ▶ | if ($phase eq 'moving') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 474718 | for my $from (0 .. 23) { | |||||||||||||||||||||||||||||||||||||||||
| 155 | 2293985 | ▶ | next unless $position->[$from] == $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 672901 | for my $to (@{ $Game::Merrills::Points::ADJACENT[$from] }) { | |||||||||||||||||||||||||||||||||||||||||
| 157 | 1209526 | ▶ | return 1 unless $position->[$to]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 149 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 1102392 | ▶ | return scalar(grep { !$_ } @{$position}[ 0 .. 23 ]) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1970212 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1970212 | my ($position, $side, $raw) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 1970212 | my $value = _value($side); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 1970211 | ▶ | if (defined $raw->[RM_FROM]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 686433 | $position->[ $raw->[RM_FROM] ] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1283778 | ▶ | $position->[ $value > 0 ? HAND_WHITE : HAND_BLACK ]--; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 1970211 | $position->[ $raw->[RM_TO] ] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 1970211 | ▶ | $position->[ $raw->[RM_REMOVE] ] = 0 if defined $raw->[RM_REMOVE]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1970211 | return $position; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1894977 | ▶ | sub unapply { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unapply: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1894977 | my ($position, $side, $raw) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 1894977 | my $value = _value($side); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 1894976 | ▶ | $position->[ $raw->[RM_REMOVE] ] = -$value if defined $raw->[RM_REMOVE]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1894976 | $position->[ $raw->[RM_TO] ] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 1894976 | ▶ | if (defined $raw->[RM_FROM]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 649790 | $position->[ $raw->[RM_FROM] ] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 1245186 | ▶ | $position->[ $value > 0 ? HAND_WHITE : HAND_BLACK ]++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 1894976 | return $position; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 83 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | __END__ | ||||||||||||||||||||||||||||||||||||||||||