| 1 | package Game::Senet::Notation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 62 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 62 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 62 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 62 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 62 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 62 | ▶ | use Game::Senet::Sticks (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 64 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 62 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 62 | POS_OK => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | POS_NULL => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | POS_GROUPS => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | POS_WIDTH => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | POS_LETTER => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | POS_SIDE => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | POS_PIECES => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | POS_EXCESS => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | POS_FIELD => 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | POS_LONG => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 62 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 64 | our (@EXPORT_OK, %EXPORT_TAGS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 64 | my (@FIELDS, %FIELD_OK, %SIDE_OF, %LETTER_OF, %RESULT_OK, $MOVE_MAX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 64 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 64 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | house_ok parse_move format_move format_display format_forfeit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | validate_position parse_record format_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | POS_OK POS_NULL POS_GROUPS POS_WIDTH POS_LETTER POS_SIDE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | POS_PIECES POS_EXCESS POS_FIELD POS_LONG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 64 | %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 64 | @FIELDS = qw(pieces blockade protect backward reach26 throw_on_26); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 64 | %FIELD_OK = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | pieces => qr/\A[1-7]\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | blockade => qr/\A[023]\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | protect => qr/\A(?:none|run|ends)\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | backward => qr/\A[01]\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | reach26 => qr/\A(?:exact|any)\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | throw_on_26 => qr/\A[01]\z/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 64 | %SIDE_OF = (l => 'light', d => 'dark'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 64 | %LETTER_OF = (light => 'l', dark => 'd'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 64 | %RESULT_OK = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'light home', 'dark home', 'light resign', 'dark resign', 'draw ply_cap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 64 | $MOVE_MAX = length '30-off'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2826004 | ▶ | sub house_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
house_ok: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2826004 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2826004 | ▶ | return 0 unless defined $text && $text =~ /\A[1-9][0-9]?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $text and $text =~ /\A[1-9][0-9]?\z/
MC/DC50%1/2
defined $text and $text =~ /\A[1-9][0-9]?\z/
defined $text
$text =~ /\A[1-9][0-9]?\z/
Truth table66%2/3
A and B
A= defined $textB= $text =~ /\A[1-9][0-9]?\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2826001 | ▶ | return $text <= 30 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2350734 | ▶ | my $place = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2350734 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2350734 | ▶ | return ('off', undef) if lc $text eq 'off'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2316201 | ▶ | return (undef, 'shape') unless $text =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2316196 | ▶ | return (undef, 'house') unless house_ok($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2316192 | return ($text + 0, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1182273 | ▶ | sub parse_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_move: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1182273 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1182273 | ▶ | return (undef, 'empty') unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $text and length $text
MC/DC100%2/2
defined $text and length $text
defined $text
length $text
Truth table100%3/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1182271 | ▶ | return (undef, 'long') if length $text > $MOVE_MAX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1175373 | my @parts = split /-/, $text, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1175373 | ▶ | return (undef, 'shape') unless @parts == 2 && length $parts[0] && length $parts[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@parts == 2 and length $parts[0] and length $parts[1]
@parts == 2 and length $parts[0]
MC/DC66%2/3
@parts == 2 and length $parts[0] and length $parts[1]
@parts == 2
length $parts[0]
length $parts[1]
Truth table75%3/4
A and B and C
A= @parts == 2B= length $parts[0]C= length $parts[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1175369 | my ($from, $bad_from) = $place->($parts[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1175369 | ▶ | return (undef, $bad_from) if $bad_from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1175365 | my ($to, $bad_to) = $place->($parts[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1175365 | ▶ | return (undef, $bad_to) if $bad_to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1175360 | ▶ | return (undef, 'from_off') if $from eq 'off'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1175359 | ▶ | return (undef, 'same') if $from eq $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1175358 | return ({ from => $from, to => $to }, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 8407152 | ▶ | my $read = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 8407152 | my ($move, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 8407152 | ▶ | return $move->$name if Scalar::Util::blessed($move) && $move->can($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($move) and $move->can($name)
MC/DC50%1/2
builtin::blessed($move) and $move->can($name)
builtin::blessed($move)
$move->can($name)
Truth table66%2/3
A and B
A= builtin::blessed($move)B= $move->can($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1701616 | ▶ | return ref $move eq 'HASH' ? $move->{$name} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2823698 | ▶ | sub format_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_move: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2823698 | my ($move) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2823698 | ▶ | my $to = $read->($move, 'off') ? 'off' : $read->($move, 'to'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2823698 | return $read->($move, 'from') . '-' . lc $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2357 | ▶ | sub format_display { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_display: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2357 | my ($move, $again) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2357 | ▶ | return $read->($move, 'roll') . ': ' . format_move($move) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | . ($read->($move, 'back') ? '<' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | . ($read->($move, 'swap') ? 'x' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | . ($again ? '+' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | sub format_forfeit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_forfeit: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | my ($roll, $again) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | ▶ | return $roll . ': -' . ($again ? '+' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 752 | ▶ | sub validate_position { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_position: called CC=30 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 752 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 752 | ▶ | return POS_NULL unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $text and length $text
MC/DC50%1/2
defined $text and length $text
defined $text
length $text
Truth table66%2/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 751 | ▶ | return POS_LONG if length $text >= 48; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 750 | my @c = split //, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 750 | my ($group, $width, $i) = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 750 | my %count = (l => 0, d => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 750 | ▶ | for (; $i < @c && $c[$i] ne ' '; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i < @c and $c[$i] ne " "
MC/DC100%2/2
$i < @c and $c[$i] ne " "
$i < @c
$c[$i] ne " "
Truth table100%3/3
A and B
A= $i < @cB= $c[$i] ne " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 23281 | my $ch = $c[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 23281 | ▶ | if ($ch eq '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1456 | ▶ | return POS_WIDTH if $width != 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1450 | ▶ | return POS_GROUPS if $group == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1449 | $group++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1449 | $width = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1449 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 21825 | ▶ | return POS_LETTER unless $ch eq 'l' || $ch eq 'd' || $ch eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$ch eq "l" or $ch eq "d" or $ch eq "."
$ch eq "l" or $ch eq "d"
MC/DC100%3/3
$ch eq "l" or $ch eq "d" or $ch eq "."
$ch eq "l"
$ch eq "d"
$ch eq "."
Truth table100%4/4
A or B or C
A= $ch eq "l"B= $ch eq "d"C= $ch eq "."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 21794 | ▶ | return POS_WIDTH if $width >= 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 21793 | ▶ | $count{$ch}++ if $ch ne '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 21793 | $width++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 711 | ▶ | return POS_GROUPS if $group != 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 707 | ▶ | return POS_WIDTH if $width != 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 706 | ▶ | return POS_FIELD unless $i < @c && $c[$i] eq ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$i < @c and $c[$i] eq " "
MC/DC50%1/2
$i < @c and $c[$i] eq " "
$i < @c
$c[$i] eq " "
Truth table66%2/3
A and B
A= $i < @cB= $c[$i] eq " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 705 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 705 | ▶ | return POS_FIELD if $i >= @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 705 | ▶ | return POS_SIDE unless $c[$i] eq 'l' || $c[$i] eq 'd'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c[$i] eq "l" or $c[$i] eq "d"
MC/DC100%2/2
$c[$i] eq "l" or $c[$i] eq "d"
$c[$i] eq "l"
$c[$i] eq "d"
Truth table100%3/3
A or B
A= $c[$i] eq "l"B= $c[$i] eq "d"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 702 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 702 | ▶ | return POS_FIELD if $i >= @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 701 | ▶ | return POS_SIDE unless $c[$i] eq ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 700 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 700 | ▶ | return POS_FIELD if $i >= @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 699 | ▶ | return POS_PIECES unless $c[$i] =~ /\A[1-7]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 696 | my $pieces = $c[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 696 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 696 | ▶ | return POS_PIECES if $i < @c && $c[$i] ne ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i < @c and $c[$i] ne " "
MC/DC100%2/2
$i < @c and $c[$i] ne " "
$i < @c
$c[$i] ne " "
Truth table100%3/3
A and B
A= $i < @cB= $c[$i] ne " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 695 | ▶ | return POS_FIELD if $i < @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 694 | ▶ | return POS_EXCESS if $count{l} > $pieces || $count{d} > $pieces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$count{"l"} > $pieces or $count{"d"} > $pieces
MC/DC100%2/2
$count{"l"} > $pieces or $count{"d"} > $pieces
$count{"l"} > $pieces
$count{"d"} > $pieces
Truth table100%3/3
A or B
A= $count{"l"} > $piecesB= $count{"d"} > $pieces
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 691 | return POS_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 7141 | ▶ | my $variant_text = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7141 | my ($variant) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7141 | return join ' ', $variant->{name}, map { "$_=$variant->{$_}" } @FIELDS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5690 | ▶ | my $variant_of = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 5690 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 5690 | my ($name, @pairs) = split / /, $text, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 5690 | ▶ | return undef unless defined $name && $name =~ /\A[a-z][a-z0-9_]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and $name =~ /\A[a-z][a-z0-9_]*\z/
MC/DC0%0/2
defined $name and $name =~ /\A[a-z][a-z0-9_]*\z/
defined $name
$name =~ /\A[a-z][a-z0-9_]*\z/
Truth table33%1/3
A and B
A= defined $nameB= $name =~ /\A[a-z][a-z0-9_]*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 5690 | my (%variant, @names) = (name => $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5690 | for my $pair (@pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 34134 | ▶ | my ($field, $value) = $pair =~ /\A([a-z_0-9]+)=([a-z0-9]+)\z/ or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 34134 | push @names, $field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 34134 | ▶ | return undef unless $FIELD_OK{$field} && $value =~ $FIELD_OK{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$FIELD_OK{$field} and $value =~ /$FIELD_OK{$field}/
MC/DC50%1/2
$FIELD_OK{$field} and $value =~ /$FIELD_OK{$field}/
$FIELD_OK{$field}
$value =~ /$FIELD_OK{$field}/
Truth table66%2/3
A and B
A= $FIELD_OK{$field}B= $value =~ /$FIELD_OK{$field}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 34133 | ▶ | $variant{$field} = $value =~ /\A\d+\z/ ? $value + 0 : $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5689 | ▶ | return undef unless "@names" eq "@FIELDS"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5687 | return \%variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7141 | ▶ | sub format_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_record: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7141 | my ($record) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | my @lines = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | '[variant ' . $variant_text->($record->{variant}) . ']', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7141 | '[first ' . $record->{first} . ']', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 7141 | ▶ | push @lines, '[position ' . $record->{position} . ']' if defined $record->{position}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 7141 | ▶ | push @lines, '[seed ' . $record->{seed} . ']' if defined $record->{seed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 7141 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 7141 | ▶ | for my $ply (@{ $record->{plies} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$record->{'plies'} || []
MC/DC0%0/1
$record->{'plies'} || []
$record->{'plies'}
Truth table50%1/2
A
A= $record->{'plies'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 712448 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | push @lines, $n . '. ' . $LETTER_OF{ $ply->{side} } . ' ' . $ply->{roll} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | . (defined $ply->{sticks} ? ' ' . $ply->{sticks} : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 712448 | ▶ | . ': ' . (defined $ply->{move} ? $ply->{move} : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | push @lines, '[result ' . $record->{result}{winner} . ' ' . $record->{result}{how} . ']' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 7141 | ▶ | if $record->{result}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7141 | return join("\n", @lines) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5731 | ▶ | sub parse_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_record: called CC=36 SCAR=36.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5731 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5731 | ▶ | my $fail = sub { return (undef, { line => $_[0], error => $_[1] }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 5731 | ▶ | return $fail->(0, 'empty') unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $text and length $text
MC/DC0%0/2
defined $text and length $text
defined $text
length $text
Truth table33%1/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5731 | ▶ | return $fail->(0, 'no_newline') unless $text =~ /\n\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 5730 | my @lines = split /\n/, $text, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5730 | pop @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5730 | my %record = (plies => []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5730 | my ($at, $done) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 22789 | ▶ | my $header = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 22789 | my ($name, $pattern) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 22789 | ▶ | return undef unless $at < @lines && $lines[$at] =~ /\A\[\Q$name\E ($pattern)\]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$at < @lines and $lines[$at] =~ /\A\[\Q$name\E ($pattern)\]\z/
MC/DC100%2/2
$at < @lines and $lines[$at] =~ /\A\[\Q$name\E ($pattern)\]\z/
$at < @lines
$lines[$at] =~ /\A\[\Q$name\E ($pattern)\]\z/
Truth table100%3/3
A and B
A= $at < @linesB= $lines[$at] =~ /\A\[\Q$name\E ($pattern)\]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 17050 | $at++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 17050 | return $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5730 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 5730 | my $variant = $header->('variant', '[a-z0-9_= ]+'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5730 | ▶ | return $fail->($at + 1, 'variant') unless defined $variant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 5690 | $record{variant} = $variant_of->($variant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5690 | ▶ | return $fail->($at, 'variant') unless $record{variant}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5687 | $record{first} = $header->('first', 'light|dark'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5687 | ▶ | return $fail->($at + 1, 'first') unless defined $record{first}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 5686 | my $position = $header->('position', '[ld./ 1-7]+'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5686 | ▶ | if (defined $position) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | return $fail->($at, 'position') if validate_position($position); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my ($side, $pieces) = $position =~ / ([ld]) (\d)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | return $fail->($at, 'position') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | unless $pieces == $record{variant}{pieces} && $side eq substr($record{first}, 0, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pieces == $record{"variant"}{"pieces"} and $side eq substr($record{"first"}, 0, 1)
MC/DC0%0/2
$pieces == $record{"variant"}{"pieces"} and $side eq substr($record{"first"}, 0, 1)
$pieces == $record{"variant"}{"pieces"}
$side eq substr($record{"first"}, 0, 1)
Truth table33%1/3
A and B
A= $pieces == $record{"variant"}{"pieces"}B= $side eq substr($record{"first"}, 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | $record{position} = $position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 5686 | my $seed = $header->('seed', '(?:[0-9a-f]{2})+'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5686 | ▶ | $record{seed} = $seed if defined $seed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 5686 | ▶ | my $bytes = defined $seed ? pack('H*', $seed) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5686 | my $expect = $record{first}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5686 | my $bind = $record{variant}{throw_on_26}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5686 | ▶ | for (; $at < @lines; $at++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 543417 | my $line = $lines[$at]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 543417 | my $number = $at + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 543417 | ▶ | return $fail->($number, 'after_result') if $done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 543416 | ▶ | if ($line =~ /\A\[result ([a-z_]+ [a-z_]+)\]\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 517 | ▶ | return $fail->($number, 'result') unless $RESULT_OK{$1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 517 | my ($winner, $how) = split / /, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 517 | $record{result} = { winner => $winner, how => $how }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 517 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 517 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 542899 | ▶ | my ($n, $letter, $roll, $sticks, $move) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | $line =~ /\A([1-9][0-9]*)\. ([ld]) ([1-5])(?: ([01]{4}))?: (\S+)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | or return $fail->($number, 'ply'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 542899 | my $throw = scalar @{ $record{plies} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 542899 | ▶ | return $fail->($number, 'number') unless $n == $throw + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 542899 | my $side = $SIDE_OF{$letter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 542899 | ▶ | return $fail->($number, 'side') unless $side eq $expect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 542895 | ▶ | if (defined $sticks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 542876 | my $light = ($sticks =~ tr/1//); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 542876 | ▶ | return $fail->($number, 'sticks') unless Game::Senet::Sticks::roll_of($light) == $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 542894 | ▶ | if (defined $bytes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 542871 | my $thrown = Game::Senet::Sticks::throw_for($bytes, $throw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 542871 | ▶ | return $fail->($number, 'roll') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | unless Game::Senet::Sticks::roll_of(Game::Senet::Sticks::light_of($thrown)) == $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 542868 | ▶ | return $fail->($number, 'sticks') if defined $sticks && $sticks ne join('', @$thrown); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sticks and $sticks ne join("", @$thrown)
MC/DC0%0/2
defined $sticks and $sticks ne join("", @$thrown)
defined $sticks
$sticks ne join("", @$thrown)
Truth table33%1/3
A and B
A= defined $sticksB= $sticks ne join("", @$thrown)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 542891 | my %ply = (side => $side, roll => $roll + 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 542891 | ▶ | $ply{sticks} = $sticks if defined $sticks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 542891 | ▶ | my $other = $side eq 'light' ? 'dark' : 'light'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 542891 | my $again = Game::Senet::Sticks::extra_throw($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 542891 | ▶ | if ($move eq '-') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3811 | $ply{move} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 539080 | my ($parsed) = parse_move($move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 539080 | ▶ | return $fail->($number, 'move') unless $parsed && $move eq format_move($parsed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parsed and $move eq format_move($parsed)
MC/DC50%1/2
$parsed and $move eq format_move($parsed)
$parsed
$move eq format_move($parsed)
Truth table66%2/3
A and B
A= $parsedB= $move eq format_move($parsed)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 539079 | $ply{move} = $move; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 539079 | ▶ | $again ||= $bind && $parsed->{to} ne 'off' && $parsed->{from} < 26 && $parsed->{to} == 26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%12/12
$again ||= $bind && $parsed->{"to"} ne "off" && $parsed->{"from"} < 26 && $parsed->{"to"} == 26
$bind && $parsed->{'to'} ne 'off' && $parsed->{'from'} < 26 && $parsed->{'to'} == 26
$bind and $parsed->{"to"} ne "off" and $parsed->{"from"} < 26
$bind and $parsed->{"to"} ne "off"
MC/DC0%0/5
$again ||= $bind && $parsed->{"to"} ne "off" && $parsed->{"from"} < 26 && $parsed->{"to"} == 26
$again
$bind
$parsed->{"to"} ne "off"
$parsed->{"from"} < 26
$parsed->{'to'} == 26
Truth table0%0/6
A ||= B and C and D && E
A= $againB= $bindC= $parsed->{"to"} ne "off"D= $parsed->{"from"} < 26E= $parsed->{'to'} == 26
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 542890 | ▶ | $expect = $again ? $side : $other; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 542890 | push @{ $record{plies} }, \%ply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5676 | return (\%record, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 64 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||