blib/lib/Game/Mahjong/Fans.pm

filter: Statementstmt 99.4% 506 / 509 Branchbran 92.9% 212 / 228 Conditioncond 92.7% 257 / 277 MC/DCmcdc 84.8% 123 / 145 Subroutinesub 98.1% 107 / 109 Podpod 100% 6 / 6 totaltotal 95.0% 1211 / 1274 CC 231 SCAR 16.7
CC
231
Cov
96%
view
19.0
_f_nine_gates
13.0
_f_three_suited_terminal_chows
11.0
CRAP 5.3
« blib/lib/Game/Mahjong/Meld.pm ↑ Summary blib/lib/Game/Mahjong/Wall.pm »
1 package Game::Mahjong::Fans;
2  
3 34 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 34 ▶use Game::Mahjong::Tiles;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 34 ▶use Game::Mahjong::Fan;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 34 our $VERSION = '0.02';
11  
12 34 our @GRADES = (88, 64, 48, 32, 24, 16, 12, 8, 6, 4, 2, 1);
13 34 our %PER_GRADE = (88 => 7, 64 => 6, 48 => 2, 32 => 3, 24 => 9, 16 => 6, 12 => 5, 8 => 10, 6 => 6, 4 => 4, 2 => 10, 1 => 13);
14 34 ▶use constant COUNT => 81;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2451 ▶sub view {
Subroutine view: called CC=19 SCAR=29.4
Pod documented
17 2451 my ($split, $ctx) = @_;
18 2451 ▶ $ctx ||= {};
Condition50%1/2
$ctx ||= {}
l!l
24510
MC/DC0%0/1
$ctx ||= {}
$ctx
Truth table50%1/2
A
A= $ctx
Aresult
11
00
19 2451 my @sets;
20 2451 for my $i (0 .. $#{ $split->{sets} }) {
21 8614 my $s = $split->{sets}[$i];
22 8614 my $t0 = $s->{tiles}[0];
23 push @sets, {
24 %$s,
25 i => $i,
26 suit => Game::Mahjong::Tiles::suit_of($t0),
27 base => Game::Mahjong::Tiles::rank_of($t0),
28 tile => $t0,
29 honour => Game::Mahjong::Tiles::is_honour($t0),
30 8614 ▶ exposed => ($s->{melded} && !$s->{concealed}) ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$s->{'melded'} && !$s->{'concealed'} ? : 2169 6445 8614
Condition100%3/3
$s->{"melded"} and not $s->{"concealed"}
!ll&&!rl&&r
6393522169
MC/DC100%2/2
$s->{"melded"} and not $s->{"concealed"}
$s->{"melded"} not $s->{"concealed"}
Truth table100%3/3
A and not(B)
A= $s->{"melded"}B= not $s->{"concealed"}
ABresult
0X0
100
111
31 };
32 }
33 2451 my @chows = grep { $_->{kind} eq 'chow' } @sets;
34 2451 ▶ my @pungs = grep { $_->{kind} eq 'pung' || $_->{kind} eq 'kong' } @sets;
Condition100%3/3
$_->{'kind'} eq 'pung' || $_->{'kind'} eq 'kong'
l!l&&r!l&&!r
22501136251
MC/DC100%2/2
$_->{'kind'} eq 'pung' || $_->{'kind'} eq 'kong'
$_->{'kind'} eq 'pung' $_->{'kind'} eq 'kong'
Truth table100%3/3
A || B
A= $_->{'kind'} eq 'pung'B= $_->{'kind'} eq 'kong'
ABresult
1X1
011
000
35 2451 my @kongs = grep { $_->{kind} eq 'kong' } @sets;
36 2451 my @knits = grep { $_->{kind} eq 'knit' } @sets;
37  
38 2451 my @tiles;
39 2451 for my $s (@sets) {
40 8614 push @tiles, @{ $s->{tiles} };
41 }
42 2451 ▶ push @tiles, ($split->{pair}) x 2 if $split->{pair} && $split->{form} ne 'seven_pairs' && $split->{form} ne 'thirteen_orphans';
Branch: 1 branch
BranchTrueFalseTotal
if $split->{"pair"} and $split->{"form"} ne "seven_pairs" and $split->{"form"} ne "thirteen_orphans" 2057 394 2451
Condition100%6/6
$split->{"pair"} and $split->{"form"} ne "seven_pairs" and $split->{"form"} ne "thirteen_orphans"
!ll&&!rl&&r
38862057
$split->{"pair"} and $split->{"form"} ne "seven_pairs"
!ll&&!rl&&r
369192063
MC/DC100%3/3
$split->{"pair"} and $split->{"form"} ne "seven_pairs" and $split->{"form"} ne "thirteen_orphans"
$split->{"pair"} $split->{"form"} ne "seven_pairs" $split->{"form"} ne "thirteen_orphans"
Truth table100%4/4
A and B and C
A= $split->{"pair"}B= $split->{"form"} ne "seven_pairs"C= $split->{"form"} ne "thirteen_orphans"
ABCresult
0XX0
10X0
1100
1111
43 2451 ▶ if ($split->{form} eq 'seven_pairs') {
Branch: 3 branches
BranchTrueFalseTotal
if ($split->{'form'} eq 'seven_pairs') { } 30 2421 2451
elsif ($split->{'form'} eq 'thirteen_orphans') { } 6 2415 2421
elsif ($split->{'form'} eq 'honours_knitted') { } 30 2385 2415
44 30 push @tiles, map { ($_) x 2 } @{ $split->{singles} };
45 }
46 elsif ($split->{form} eq 'thirteen_orphans') {
47 6 push @tiles, @{ $split->{singles} }, $split->{pair};
48 }
49 elsif ($split->{form} eq 'honours_knitted') {
50 30 push @tiles, @{ $split->{singles} };
51 }
52 2451 my %count;
53 2451 $count{$_}++ for @tiles;
54 2451 my %suits;
55 2451 my $honours = 0;
56 2451 for my $t (@tiles) {
57 30993 ▶ if (my $s = Game::Mahjong::Tiles::suit_of($t)) { $suits{$s}++ }
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = Game::Mahjong::Tiles::suit_of($t)) { } 28558 2435 30993
58 2435 else { $honours++ }
59 }
60  
61 2451 my @elements = (@sets);
62 2451 ▶ if ($split->{form} eq 'seven_pairs') {
Branch: 2 branches
BranchTrueFalseTotal
if ($split->{'form'} eq 'seven_pairs') { } 30 2421 2451
elsif ($split->{'pair'}) { } 2063 358 2421
63 30 @elements = map { { kind => 'pair', tiles => [ ($_) x 2 ], tile => $_, suit => Game::Mahjong::Tiles::suit_of($_), base => Game::Mahjong::Tiles::rank_of($_), honour => Game::Mahjong::Tiles::is_honour($_) } } @{ $split->{singles} };
64 }
65 elsif ($split->{pair}) {
66 2063 my $p = $split->{pair};
67 2063 push @elements, { kind => 'pair', tiles => [ $p, $p ], tile => $p, suit => Game::Mahjong::Tiles::suit_of($p), base => Game::Mahjong::Tiles::rank_of($p), honour => Game::Mahjong::Tiles::is_honour($p) };
68 }
69  
70 return {
71 split => $split,
72 ctx => $ctx,
73 form => $split->{form},
74 sets => \@sets,
75 chows => \@chows,
76 pungs => \@pungs,
77 kongs => \@kongs,
78 knits => \@knits,
79 pair => $split->{pair},
80 elements => \@elements,
81 tiles => \@tiles,
82 count => \%count,
83 suits => [ sort keys %suits ],
84 nsuits => scalar keys %suits,
85 honours => $honours,
86 8614 exposed => scalar(grep { $_->{exposed} } @sets),
87 2363 ▶ concealed_pungs => [ grep { $_->{concealed} } @pungs ],
Branch: 1 branch
BranchTrueFalseTotal
$ctx->{'waits'} ? : 2194 257 2451
88 wait => $split->{placement}{wait},
89 place_in => $split->{placement}{in},
90 2451 nwaits => ($ctx->{waits} ? scalar @{ $ctx->{waits} } : 1),
91 };
92 }
93  
94 27004 ▶sub _every { my ($v, $pred) = @_; return 0 unless @{ $v->{tiles} }; for (@{ $v->{tiles} }) { return 0 unless $pred->($_) } return 1 }
Subroutine _every: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
unless @{$v->{"tiles"};} 0 27004 27004
unless &$pred($_) 25860 33644 59504
95 13401 ▶sub _one { return ({ sets => [ map { $_->{i} } @_ ] }) }
Subroutine _one: called CC=1 SCAR=0.0
96 19608 ▶sub _standard { return $_[0]->{form} eq 'standard' ? 1 : 0 }
Subroutine _standard: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'form'} eq 'standard' ? : 19064 544 19608
97 12255 ▶sub _pairs_of { my ($list) = @_; my @p; for my $i (0 .. $#$list) { for my $j ($i + 1 .. $#$list) { push @p, [ $list->[$i], $list->[$j] ] } } return @p }
Subroutine _pairs_of: called CC=3 SCAR=11.0
98 22059 ▶sub _triples_of { my ($list) = @_; my @t; for my $i (0 .. $#$list) { for my $j ($i + 1 .. $#$list) { for my $k ($j + 1 .. $#$list) { push @t, [ $list->[$i], $list->[$j], $list->[$k] ] } } } return @t }
Subroutine _triples_of: called CC=4 SCAR=13.9
99 9804 ▶sub _wind_of { my ($v, $which) = @_; my $i = $v->{ctx}{$which}; return defined $i ? 28 + $i : -1 }
Subroutine _wind_of: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
defined $i ? : 9804 0 9804
100 33146 ▶sub _same_suit { my @s = @_; my $suit = $s[0]{suit}; return 0 unless defined $suit; for (@s) { return 0 unless defined $_->{suit} && $_->{suit} eq $suit } return 1 }
Subroutine _same_suit: called CC=5 SCAR=16.3
Branch: 2 branches
BranchTrueFalseTotal
unless defined $suit 0 33146 33146
unless defined $_->{"suit"} and $_->{"suit"} eq $suit 25611 45811 71422
Condition66%2/3
defined $_->{"suit"} and $_->{"suit"} eq $suit
!ll&&!rl&&r
02561145811
MC/DC50%1/2
defined $_->{"suit"} and $_->{"suit"} eq $suit
defined $_->{"suit"} $_->{"suit"} eq $suit
Truth table66%2/3
A and B
A= defined $_->{"suit"}B= $_->{"suit"} eq $suit
ABresult
0X0
100
111
101 10544 ▶sub _three_suits { my @s = @_; my %seen; for (@s) { return 0 unless defined $_->{suit}; $seen{ $_->{suit} }++ } return scalar(keys %seen) == 3 ? 1 : 0 }
Subroutine _three_suits: called CC=4 SCAR=13.9
Branch: 2 branches
BranchTrueFalseTotal
unless defined $_->{"suit"} 0 31632 31632
scalar keys %seen == 3 ? : 2760 7784 10544
102 2998 ▶sub _bases_shifted { my ($by, @s) = @_; my @b = sort { $a <=> $b } map { $_->{base} } @s; for my $i (1 .. $#b) { return 0 unless $b[$i] == $b[$i - 1] + $by } return 1 }
Subroutine _bases_shifted: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
unless $b[$i] == $b[$i - 1] + $by 2799 891 3690
103 3392 ▶sub _bases_are { my ($want, @s) = @_; return join(',', sort { $a <=> $b } map { $_->{base} } @s) eq $want ? 1 : 0 }
Subroutine _bases_are: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
join(',', (sort {$a <=> $b;} map({$_->{'base'};} @s))) eq $want ? : 266 3126 3392
104 7353 ▶sub _wind_pungs { return grep { Game::Mahjong::Tiles::is_wind($_->{tile}) } @{ $_[0]->{pungs} } }
Subroutine _wind_pungs: called CC=1 SCAR=0.0
105 9804 ▶sub _dragon_pungs { return grep { Game::Mahjong::Tiles::is_dragon($_->{tile}) } @{ $_[0]->{pungs} } }
Subroutine _dragon_pungs: called CC=1 SCAR=0.0
106 14247 ▶sub _is_terminal_or_honour { my ($t) = @_; return Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_honour($t) ? 1 : 0 }
Subroutine _is_terminal_or_honour: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_honour($t) ? : 3748 10499 14247
Condition100%3/3
Game::Mahjong::Tiles::is_terminal($t) or Game::Mahjong::Tiles::is_honour($t)
l!l&&r!l&&!r
287887010499
MC/DC100%2/2
Game::Mahjong::Tiles::is_terminal($t) or Game::Mahjong::Tiles::is_honour($t)
Game::Mahjong::Tiles::is_terminal($t) Game::Mahjong::Tiles::is_honour($t)
Truth table100%3/3
A or B
A= Game::Mahjong::Tiles::is_terminal($t)B= Game::Mahjong::Tiles::is_honour($t)
ABresult
1X1
011
000
107 27035 ▶sub _rank_in { my ($lo, $hi) = @_; return sub { my $r = Game::Mahjong::Tiles::rank_of($_[0]); defined $r && $r >= $lo && $r <= $hi } }
Subroutine __ANON__: called CC=3 SCAR=11.0
Subroutine _rank_in: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
defined $r and $r >= $lo and $r <= $hi 20393 6642 27035
Condition100%3/3
defined $r and $r >= $lo
!ll&&!rl&&r
548609420393
MC/DC100%2/2
defined $r and $r >= $lo
defined $r $r >= $lo
Truth table100%3/3
A and B
A= defined $rB= $r >= $lo
ABresult
0X0
100
111
108  
109 2451 ▶sub _f_big_four_winds { my ($v) = @_; my @w = _wind_pungs($v); return @w == 4 ? _one(@w) : () }
Subroutine _f_big_four_winds: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@w == 4 ? : 5 2446 2451
110 2451 ▶sub _f_big_three_dragons { my ($v) = @_; my @d = _dragon_pungs($v); return @d == 3 ? _one(@d) : () }
Subroutine _f_big_three_dragons: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@d == 3 ? : 3 2448 2451
111 2451 ▶sub _f_all_green { my ($v) = @_; return _every($v, \&Game::Mahjong::Tiles::is_green) ? _one() : () }
Subroutine _f_all_green: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Tiles::is_green) ? : 34 2417 2451
112 2451 ▶sub _f_nine_gates {
Subroutine _f_nine_gates: called CC=13 SCAR=25.7
113 2451 my ($v) = @_;
114 2451 ▶ return () unless _standard($v) && $v->{exposed} == 0 && !@{ $v->{kongs} } && $v->{nsuits} == 1 && !$v->{honours};
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) and $v->{"exposed"} == 0 and not @{$v->{"kongs"};} and $v->{"nsuits"} == 1 and not $v->{"honours"} 2381 70 2451
Condition100%12/12
_standard($v) and $v->{"exposed"} == 0 and not @{$v->{"kongs"};} and $v->{"nsuits"} == 1 and not $v->{"honours"}
!ll&&!rl&&r
23572470
_standard($v) and $v->{"exposed"} == 0 and not @{$v->{"kongs"};} and $v->{"nsuits"} == 1
!ll&&!rl&&r
167867994
_standard($v) and $v->{"exposed"} == 0 and not @{$v->{"kongs"};}
!ll&&!rl&&r
16699773
_standard($v) and $v->{"exposed"} == 0
!ll&&!rl&&r
681601782
MC/DC100%5/5
_standard($v) and $v->{"exposed"} == 0 and not @{$v->{"kongs"};} and $v->{"nsuits"} == 1 and not $v->{"honours"}
_standard($v) $v->{"exposed"} == 0 not @{$v->{"kongs"};} $v->{"nsuits"} == 1 not $v->{"honours"}
Truth table100%6/6
A and B and not(C) and D and not(E)
A= _standard($v)B= $v->{"exposed"} == 0C= not @{$v->{"kongs"};}D= $v->{"nsuits"} == 1E= not $v->{"honours"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
115 70 ▶ my $win = $v->{ctx}{winning} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $win = $v->{"ctx"}{"winning"} or return () 55 15 70
116 55 my %c = %{ $v->{count} };
117 55 ▶ return () unless $c{$win};
Branch: 1 branch
BranchTrueFalseTotal
unless $c{$win} 0 55 55
118 55 $c{$win}--;
119 55 my $suit = $v->{suits}[0];
120 55 for my $r (1 .. 9) {
121 231 my $k = Game::Mahjong::Tiles::id_of($suit . $r);
122 231 ▶ my $want = ($r == 1 || $r == 9) ? 3 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$r == 1 || $r == 9 ? : 77 154 231
Condition100%3/3
$r == 1 or $r == 9
l!l&&r!l&&!r
5522154
MC/DC100%2/2
$r == 1 or $r == 9
$r == 1 $r == 9
Truth table100%3/3
A or B
A= $r == 1B= $r == 9
ABresult
1X1
011
000
123 231 ▶ return () unless ($c{$k} || 0) == $want;
Branch: 1 branch
BranchTrueFalseTotal
unless ($c{$k} || 0) == $want 33 198 231
Condition100%2/2
$c{$k} || 0
l!l
21318
MC/DC100%1/1
$c{$k} || 0
$c{$k}
Truth table100%2/2
A
A= $c{$k}
Aresult
11
00
124 }
125 22 return _one();
126 }
127 2451 ▶sub _f_four_kongs { my ($v) = @_; return @{ $v->{kongs} } == 4 ? _one(@{ $v->{kongs} }) : () }
Subroutine _f_four_kongs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@{$v->{'kongs'};} == 4 ? : 2 2449 2451
128 2451 ▶sub _f_seven_shifted_pairs {
Subroutine _f_seven_shifted_pairs: called CC=8 SCAR=20.8
129 2451 my ($v) = @_;
130 2451 ▶ return () unless $v->{form} eq 'seven_pairs';
Branch: 1 branch
BranchTrueFalseTotal
unless $v->{"form"} eq "seven_pairs" 2421 30 2451
131 30 my @k = sort { $a <=> $b } @{ $v->{split}{singles} };
132 30 my $suit = Game::Mahjong::Tiles::suit_of($k[0]);
133 30 ▶ return () unless defined $suit;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $suit 0 30 30
134 30 for my $i (0 .. 6) {
135 100 ▶ return () unless (Game::Mahjong::Tiles::suit_of($k[$i]) // '') eq $suit;
Branch: 1 branch
BranchTrueFalseTotal
unless (Game::Mahjong::Tiles::suit_of($k[$i]) // "") eq $suit 14 86 100
Condition50%1/2
Game::Mahjong::Tiles::suit_of($k[$i]) // ""
l!l
1000
MC/DC0%0/1
Game::Mahjong::Tiles::suit_of($k[$i]) // ""
Game::Mahjong::Tiles::suit_of($k[$i])
Truth table50%1/2
A
A= Game::Mahjong::Tiles::suit_of($k[$i])
Aresult
11
00
136 86 ▶ return () if $i && $k[$i] != $k[$i - 1] + 1;
Branch: 1 branch
BranchTrueFalseTotal
if $i and $k[$i] != $k[$i - 1] + 1 15 71 86
Condition100%3/3
$i and $k[$i] != $k[$i - 1] + 1
!ll&&!rl&&r
304115
MC/DC100%2/2
$i and $k[$i] != $k[$i - 1] + 1
$i $k[$i] != $k[$i - 1] + 1
Truth table100%3/3
A and B
A= $iB= $k[$i] != $k[$i - 1] + 1
ABresult
0X0
100
111
137 }
138 1 return _one();
139 }
140 2451 ▶sub _f_thirteen_orphans { my ($v) = @_; return $v->{form} eq 'thirteen_orphans' ? _one() : () }
Subroutine _f_thirteen_orphans: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'form'} eq 'thirteen_orphans' ? : 6 2445 2451
141 2451 ▶sub _f_all_terminals { my ($v) = @_; return _every($v, \&Game::Mahjong::Tiles::is_terminal) ? _one() : () }
Subroutine _f_all_terminals: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Tiles::is_terminal) ? : 52 2399 2451
142 2451 ▶sub _f_little_four_winds {
Subroutine _f_little_four_winds: called CC=5 SCAR=16.2
143 2451 my ($v) = @_;
144 2451 my @w = _wind_pungs($v);
145 2451 ▶ return () unless @w == 3 && $v->{pair} && Game::Mahjong::Tiles::is_wind($v->{pair});
Branch: 1 branch
BranchTrueFalseTotal
unless @w == 3 and $v->{"pair"} and Game::Mahjong::Tiles::is_wind($v->{"pair"}) 2449 2 2451
Condition83%5/6
@w == 3 and $v->{"pair"} and Game::Mahjong::Tiles::is_wind($v->{"pair"})
!ll&&!rl&&r
244722
@w == 3 and $v->{"pair"}
!ll&&!rl&&r
244704
MC/DC66%2/3
@w == 3 and $v->{"pair"} and Game::Mahjong::Tiles::is_wind($v->{"pair"})
@w == 3 $v->{"pair"} Game::Mahjong::Tiles::is_wind($v->{"pair"})
Truth table75%3/4
A and B and C
A= @w == 3B= $v->{"pair"}C= Game::Mahjong::Tiles::is_wind($v->{"pair"})
ABCresult
0XX0
10X0
1100
1111
146 2 ▶ return (grep { $_->{tile} == $v->{pair} } @w) ? () : _one(@w);
Branch: 1 branch
BranchTrueFalseTotal
grep({$_->{'tile'} == $v->{'pair'};} @w) ? : 0 2 2
147 }
148 2451 ▶sub _f_little_three_dragons {
Subroutine _f_little_three_dragons: called CC=5 SCAR=16.1
149 2451 my ($v) = @_;
150 2451 my @d = _dragon_pungs($v);
151 2451 ▶ return () unless @d == 2 && $v->{pair} && Game::Mahjong::Tiles::is_dragon($v->{pair});
Branch: 1 branch
BranchTrueFalseTotal
unless @d == 2 and $v->{"pair"} and Game::Mahjong::Tiles::is_dragon($v->{"pair"}) 2449 2 2451
Condition100%6/6
@d == 2 and $v->{"pair"} and Game::Mahjong::Tiles::is_dragon($v->{"pair"})
!ll&&!rl&&r
244182
@d == 2 and $v->{"pair"}
!ll&&!rl&&r
2439210
MC/DC100%3/3
@d == 2 and $v->{"pair"} and Game::Mahjong::Tiles::is_dragon($v->{"pair"})
@d == 2 $v->{"pair"} Game::Mahjong::Tiles::is_dragon($v->{"pair"})
Truth table100%4/4
A and B and C
A= @d == 2B= $v->{"pair"}C= Game::Mahjong::Tiles::is_dragon($v->{"pair"})
ABCresult
0XX0
10X0
1100
1111
152 2 ▶ return (grep { $_->{tile} == $v->{pair} } @d) ? () : _one(@d);
Branch: 1 branch
BranchTrueFalseTotal
grep({$_->{'tile'} == $v->{'pair'};} @d) ? : 0 2 2
153 }
154 2451 ▶sub _f_all_honours { my ($v) = @_; return _every($v, \&Game::Mahjong::Tiles::is_honour) ? _one() : () }
Subroutine _f_all_honours: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Tiles::is_honour) ? : 60 2391 2451
155 2451 ▶sub _f_four_concealed_pungs { my ($v) = @_; my @c = @{ $v->{concealed_pungs} }; return @c == 4 ? _one(@c) : () }
Subroutine _f_four_concealed_pungs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@c == 4 ? : 34 2417 2451
156 2451 ▶sub _f_pure_terminal_chows {
Subroutine _f_pure_terminal_chows: called CC=9 SCAR=22.0
157 2451 my ($v) = @_;
158 2451 my @c = @{ $v->{chows} };
159 2451 ▶ return () unless _standard($v) && @c == 4 && _same_suit(@c) && _bases_are('1,1,7,7', @c);
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) and @c == 4 and _same_suit(@c) and _bases_are("1,1,7,7", @c) 2447 4 2451
Condition100%9/9
_standard($v) and @c == 4 and _same_suit(@c) and _bases_are("1,1,7,7", @c)
!ll&&!rl&&r
2414334
_standard($v) and @c == 4 and _same_suit(@c)
!ll&&!rl&&r
183058437
_standard($v) and @c == 4
!ll&&!rl&&r
681762621
MC/DC100%4/4
_standard($v) and @c == 4 and _same_suit(@c) and _bases_are("1,1,7,7", @c)
_standard($v) @c == 4 _same_suit(@c) _bases_are("1,1,7,7", @c)
Truth table100%5/5
A and B and C and D
A= _standard($v)B= @c == 4C= _same_suit(@c)D= _bases_are("1,1,7,7", @c)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
160 4 ▶ return () unless $v->{pair} && (Game::Mahjong::Tiles::suit_of($v->{pair}) // '') eq $c[0]{suit} && Game::Mahjong::Tiles::rank_of($v->{pair}) == 5;
Branch: 1 branch
BranchTrueFalseTotal
unless $v->{"pair"} and (Game::Mahjong::Tiles::suit_of($v->{"pair"}) // "") eq $c[0]{"suit"} and Game::Mahjong::Tiles::rank_of($v->{"pair"}) == 5 2 2 4
Condition75%6/8
$v->{"pair"} and (Game::Mahjong::Tiles::suit_of($v->{"pair"}) // "") eq $c[0]{"suit"} and Game::Mahjong::Tiles::rank_of($v->{"pair"}) == 5
!ll&&!rl&&r
112
$v->{"pair"} and (Game::Mahjong::Tiles::suit_of($v->{"pair"}) // "") eq $c[0]{"suit"}
!ll&&!rl&&r
013
Game::Mahjong::Tiles::suit_of($v->{"pair"}) // ""
l!l
40
MC/DC33%1/3
$v->{"pair"} and (Game::Mahjong::Tiles::suit_of($v->{"pair"}) // "") eq $c[0]{"suit"} and Game::Mahjong::Tiles::rank_of($v->{"pair"}) == 5
$v->{"pair"} Game::Mahjong::Tiles::suit_of($v->{"pair"}) Game::Mahjong::Tiles::rank_of($v->{"pair"}) == 5
Truth table50%2/4
A and B and C
A= $v->{"pair"}B= Game::Mahjong::Tiles::suit_of($v->{"pair"})C= Game::Mahjong::Tiles::rank_of($v->{"pair"}) == 5
ABCresult
0XX0
10X0
1100
1111
161 2 return _one(@c);
162 }
163 2451 ▶sub _f_quadruple_chow { my ($v) = @_; my @c = @{ $v->{chows} }; return @c == 4 && _same_suit(@c) && _bases_shifted(0, @c) ? _one(@c) : () }
Subroutine _f_quadruple_chow: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
@c == 4 && _same_suit(@c) && _bases_shifted(0, @c) ? : 1 2450 2451
Condition100%6/6
@c == 4 and _same_suit(@c) and _bases_shifted(0, @c)
!ll&&!rl&&r
2414361
@c == 4 and _same_suit(@c)
!ll&&!rl&&r
183058437
MC/DC100%3/3
@c == 4 and _same_suit(@c) and _bases_shifted(0, @c)
@c == 4 _same_suit(@c) _bases_shifted(0, @c)
Truth table100%4/4
A and B and C
A= @c == 4B= _same_suit(@c)C= _bases_shifted(0, @c)
ABCresult
0XX0
10X0
1100
1111
164 2451 ▶sub _f_four_pure_shifted_pungs { my ($v) = @_; my @p = grep { defined $_->{suit} } @{ $v->{pungs} }; return @p == 4 && _same_suit(@p) && _bases_shifted(1, @p) ? _one(@p) : () }
Subroutine _f_four_pure_shifted_pungs: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
@p == 4 && _same_suit(@p) && _bases_shifted(1, @p) ? : 1 2450 2451
Condition100%6/6
@p == 4 and _same_suit(@p) and _bases_shifted(1, @p)
!ll&&!rl&&r
244911
@p == 4 and _same_suit(@p)
!ll&&!rl&&r
2435142
MC/DC100%3/3
@p == 4 and _same_suit(@p) and _bases_shifted(1, @p)
@p == 4 _same_suit(@p) _bases_shifted(1, @p)
Truth table100%4/4
A and B and C
A= @p == 4B= _same_suit(@p)C= _bases_shifted(1, @p)
ABCresult
0XX0
10X0
1100
1111
165 2451 ▶sub _f_four_pure_shifted_chows { my ($v) = @_; my @c = @{ $v->{chows} }; return @c == 4 && _same_suit(@c) && (_bases_shifted(1, @c) || _bases_shifted(2, @c)) ? _one(@c) : () }
Subroutine _f_four_pure_shifted_chows: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
@c == 4 && _same_suit(@c) && (_bases_shifted(1, @c) || _bases_shifted(2, @c)) ? : 4 2447 2451
Condition100%9/9
@c == 4 and _same_suit(@c) and _bases_shifted(1, @c) || _bases_shifted(2, @c)
!ll&&!rl&&r
2414334
@c == 4 and _same_suit(@c)
!ll&&!rl&&r
183058437
_bases_shifted(1, @c) or _bases_shifted(2, @c)
l!l&&r!l&&!r
1333
MC/DC100%4/4
@c == 4 and _same_suit(@c) and _bases_shifted(1, @c) || _bases_shifted(2, @c)
@c == 4 _same_suit(@c) _bases_shifted(1, @c) _bases_shifted(2, @c)
Truth table100%5/5
A and B and C or D
A= @c == 4B= _same_suit(@c)C= _bases_shifted(1, @c)D= _bases_shifted(2, @c)
ABCDresult
0XXX0
10XX0
11000
111X1
11011
166 2451 ▶sub _f_three_kongs { my ($v) = @_; return @{ $v->{kongs} } == 3 ? _one(@{ $v->{kongs} }) : () }
Subroutine _f_three_kongs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@{$v->{'kongs'};} == 3 ? : 2 2449 2451
167 2451 ▶sub _f_all_terminals_and_honours { my ($v) = @_; return _every($v, \&_is_terminal_or_honour) && $v->{form} ne 'thirteen_orphans' ? _one() : () }
Subroutine _f_all_terminals_and_honours: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Fans::_is_terminal_or_honour) && $v->{'form'} ne 'thirteen_orphans' ? : 124 2327 2451
Condition100%3/3
_every($v, \&Game::Mahjong::Fans::_is_terminal_or_honour) and $v->{"form"} ne "thirteen_orphans"
!ll&&!rl&&r
23216124
MC/DC100%2/2
_every($v, \&Game::Mahjong::Fans::_is_terminal_or_honour) and $v->{"form"} ne "thirteen_orphans"
_every($v, \&Game::Mahjong::Fans::_is_terminal_or_honour) $v->{"form"} ne "thirteen_orphans"
Truth table100%3/3
A and B
A= _every($v, \&Game::Mahjong::Fans::_is_terminal_or_honour)B= $v->{"form"} ne "thirteen_orphans"
ABresult
0X0
100
111
168 2451 ▶sub _f_seven_pairs { my ($v) = @_; return $v->{form} eq 'seven_pairs' ? _one() : () }
Subroutine _f_seven_pairs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'form'} eq 'seven_pairs' ? : 30 2421 2451
169 2451 ▶sub _f_greater_honours_and_knitted_tiles { my ($v) = @_; return $v->{form} eq 'honours_knitted' && $v->{honours} == 7 ? _one() : () }
Subroutine _f_greater_honours_and_knitted_tiles: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
$v->{'form'} eq 'honours_knitted' && $v->{'honours'} == 7 ? : 10 2441 2451
Condition100%3/3
$v->{"form"} eq "honours_knitted" and $v->{"honours"} == 7
!ll&&!rl&&r
24212010
MC/DC100%2/2
$v->{"form"} eq "honours_knitted" and $v->{"honours"} == 7
$v->{"form"} eq "honours_knitted" $v->{"honours"} == 7
Truth table100%3/3
A and B
A= $v->{"form"} eq "honours_knitted"B= $v->{"honours"} == 7
ABresult
0X0
100
111
170 2451 ▶sub _f_all_even_pungs {
Subroutine _f_all_even_pungs: called CC=4 SCAR=13.9
171 2451 my ($v) = @_;
172 2451 ▶ return () unless _standard($v) && @{ $v->{pungs} } == 4;
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) and @{$v->{"pungs"};} == 4 2408 43 2451
Condition100%3/3
_standard($v) and @{$v->{"pungs"};} == 4
!ll&&!rl&&r
68234043
MC/DC100%2/2
_standard($v) and @{$v->{"pungs"};} == 4
_standard($v) @{$v->{"pungs"};} == 4
Truth table100%3/3
A and B
A= _standard($v)B= @{$v->{"pungs"};} == 4
ABresult
0X0
100
111
173 43 ▶ my $even = sub { my $r = Game::Mahjong::Tiles::rank_of($_[0]); defined $r && $r % 2 == 0 };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $r and $r % 2 == 0 81 8 89
174 43 ▶ return _every($v, $even) ? _one(@{ $v->{pungs} }) : ();
Branch: 1 branch
BranchTrueFalseTotal
_every($v, $even) ? : 1 42 43
175 }
176 2451 ▶sub _f_full_flush { my ($v) = @_; return $v->{nsuits} == 1 && !$v->{honours} ? _one() : () }
Subroutine _f_full_flush: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
$v->{'nsuits'} == 1 && !$v->{'honours'} ? : 303 2148 2451
Condition100%3/3
$v->{"nsuits"} == 1 and not $v->{"honours"}
!ll&&!rl&&r
209850303
MC/DC100%2/2
$v->{"nsuits"} == 1 and not $v->{"honours"}
$v->{"nsuits"} == 1 not $v->{"honours"}
Truth table100%3/3
A and not(B)
A= $v->{"nsuits"} == 1B= not $v->{"honours"}
ABresult
0X0
100
111
177 2451 ▶sub _f_pure_triple_chow { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && _bases_shifted(0, @$_) } _triples_of($v->{chows}) }
Subroutine _f_pure_triple_chow: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && _bases_shifted(0, @$_)
!ll&&!rl&&r
310831321
MC/DC100%2/2
_same_suit(@$_) && _bases_shifted(0, @$_)
_same_suit(@$_) _bases_shifted(0, @$_)
Truth table100%3/3
A && B
A= _same_suit(@$_)B= _bases_shifted(0, @$_)
ABresult
0X0
100
111
178 2451 ▶sub _f_pure_shifted_pungs { my ($v) = @_; my @p = grep { defined $_->{suit} } @{ $v->{pungs} }; return map { _one(@$_) } grep { _same_suit(@$_) && _bases_shifted(1, @$_) } _triples_of(\@p) }
Subroutine _f_pure_shifted_pungs: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && _bases_shifted(1, @$_)
!ll&&!rl&&r
88615
MC/DC100%2/2
_same_suit(@$_) && _bases_shifted(1, @$_)
_same_suit(@$_) _bases_shifted(1, @$_)
Truth table100%3/3
A && B
A= _same_suit(@$_)B= _bases_shifted(1, @$_)
ABresult
0X0
100
111
179 2451 ▶sub _f_upper_tiles { my ($v) = @_; return _every($v, _rank_in(7, 9)) ? _one() : () }
Subroutine _f_upper_tiles: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, _rank_in(7, 9)) ? : 54 2397 2451
180 2451 ▶sub _f_middle_tiles { my ($v) = @_; return _every($v, _rank_in(4, 6)) ? _one() : () }
Subroutine _f_middle_tiles: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, _rank_in(4, 6)) ? : 48 2403 2451
181 2451 ▶sub _f_lower_tiles { my ($v) = @_; return _every($v, _rank_in(1, 3)) ? _one() : () }
Subroutine _f_lower_tiles: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, _rank_in(1, 3)) ? : 80 2371 2451
182 2451 ▶sub _f_pure_straight { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && _bases_are('1,4,7', @$_) } _triples_of($v->{chows}) }
Subroutine _f_pure_straight: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && _bases_are('1,4,7', @$_)
!ll&&!rl&&r
310829539
MC/DC100%2/2
_same_suit(@$_) && _bases_are('1,4,7', @$_)
_same_suit(@$_) _bases_are('1,4,7', @$_)
Truth table100%3/3
A && B
A= _same_suit(@$_)B= _bases_are('1,4,7', @$_)
ABresult
0X0
100
111
183 2451 ▶sub _f_three_suited_terminal_chows {
Subroutine _f_three_suited_terminal_chows: called CC=11 SCAR=24.0
184 2451 my ($v) = @_;
185 2451 my @c = @{ $v->{chows} };
186 2451 ▶ return () unless _standard($v) && @c == 4 && $v->{pair};
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) and @c == 4 and $v->{"pair"} 1830 621 2451
Condition83%5/6
_standard($v) and @c == 4 and $v->{"pair"}
!ll&&!rl&&r
18300621
_standard($v) and @c == 4
!ll&&!rl&&r
681762621
MC/DC66%2/3
_standard($v) and @c == 4 and $v->{"pair"}
_standard($v) @c == 4 $v->{"pair"}
Truth table75%3/4
A and B and C
A= _standard($v)B= @c == 4C= $v->{"pair"}
ABCresult
0XX0
10X0
1100
1111
187 621 my %by;
188 621 push @{ $by{ $_->{suit} } }, $_->{base} for @c;
189 621 my @s = keys %by;
190 621 ▶ return () unless @s == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @s == 2 328 293 621
191 293 ▶ for my $suit (@s) { return () unless join(',', sort { $a <=> $b } @{ $by{$suit} }) eq '1,7' }
Branch: 1 branch
BranchTrueFalseTotal
unless join(",", (sort {$a <=> $b;} @{$by{$suit};})) eq "1,7" 285 22 307
192 8 ▶ my $ps = Game::Mahjong::Tiles::suit_of($v->{pair}) // return ();
Condition50%1/2
Game::Mahjong::Tiles::suit_of($v->{"pair"}) // (return ())
l!l
80
MC/DC0%0/1
Game::Mahjong::Tiles::suit_of($v->{"pair"}) // (return ())
Game::Mahjong::Tiles::suit_of($v->{"pair"})
Truth table50%1/2
A
A= Game::Mahjong::Tiles::suit_of($v->{"pair"})
Aresult
11
00
193 8 ▶ return () if $by{$ps};
Branch: 1 branch
BranchTrueFalseTotal
if $by{$ps} 6 2 8
194 2 ▶ return Game::Mahjong::Tiles::rank_of($v->{pair}) == 5 ? _one(@c) : ();
Branch: 1 branch
BranchTrueFalseTotal
Game::Mahjong::Tiles::rank_of($v->{'pair'}) == 5 ? : 1 1 2
195 }
196 2451 ▶sub _f_pure_shifted_chows { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && (_bases_shifted(1, @$_) || _bases_shifted(2, @$_)) } _triples_of($v->{chows}) }
Subroutine _f_pure_shifted_chows: called CC=3 SCAR=11.0
Condition100%6/6
_same_suit(@$_) && (_bases_shifted(1, @$_) || _bases_shifted(2, @$_))
!ll&&!rl&&r
310831618
_bases_shifted(1, @$_) or _bases_shifted(2, @$_)
l!l&&r!l&&!r
99316
MC/DC100%3/3
_same_suit(@$_) && (_bases_shifted(1, @$_) || _bases_shifted(2, @$_))
_same_suit(@$_) _bases_shifted(1, @$_) _bases_shifted(2, @$_)
Truth table100%4/4
A && B or C
A= _same_suit(@$_)B= _bases_shifted(1, @$_)C= _bases_shifted(2, @$_)
ABCresult
0XX0
1000
11X1
1011
197 2451 ▶sub _f_all_fives {
Subroutine _f_all_fives: called CC=8 SCAR=20.8
198 2451 my ($v) = @_;
199 2451 ▶ return () unless _standard($v);
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) 68 2383 2451
200 2383 for my $e (@{ $v->{elements} }) {
201 3443 ▶ return () if $e->{kind} eq 'knit';
Branch: 1 branch
BranchTrueFalseTotal
if $e->{"kind"} eq "knit" 0 3443 3443
202 3443 ▶ return () unless defined $e->{base};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e->{"base"} 139 3304 3443
203 3304 ▶ my $has5 = $e->{kind} eq 'chow' ? ($e->{base} >= 3 && $e->{base} <= 5) : $e->{base} == 5;
Branch: 1 branch
BranchTrueFalseTotal
$e->{'kind'} eq 'chow' ? : 2503 801 3304
Condition100%3/3
$e->{"base"} >= 3 and $e->{"base"} <= 5
!ll&&!rl&&r
9125421049
MC/DC100%2/2
$e->{"base"} >= 3 and $e->{"base"} <= 5
$e->{"base"} >= 3 $e->{"base"} <= 5
Truth table100%3/3
A and B
A= $e->{"base"} >= 3B= $e->{"base"} <= 5
ABresult
0X0
100
111
204 3304 ▶ return () unless $has5;
Branch: 1 branch
BranchTrueFalseTotal
unless $has5 2197 1107 3304
205 }
206 47 return _one(@{ $v->{sets} });
207 }
208 2451 ▶sub _f_triple_pung { my ($v) = @_; my @p = grep { defined $_->{suit} } @{ $v->{pungs} }; return map { _one(@$_) } grep { _three_suits(@$_) && _bases_shifted(0, @$_) } _triples_of(\@p) }
Subroutine _f_triple_pung: called CC=2 SCAR=6.9
Condition100%3/3
_three_suits(@$_) && _bases_shifted(0, @$_)
!ll&&!rl&&r
61453
MC/DC100%2/2
_three_suits(@$_) && _bases_shifted(0, @$_)
_three_suits(@$_) _bases_shifted(0, @$_)
Truth table100%3/3
A && B
A= _three_suits(@$_)B= _bases_shifted(0, @$_)
ABresult
0X0
100
111
209 2451 ▶sub _f_three_concealed_pungs { my ($v) = @_; my @c = @{ $v->{concealed_pungs} }; return @c == 3 ? _one(@c) : () }
Subroutine _f_three_concealed_pungs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@c == 3 ? : 57 2394 2451
210 2451 ▶sub _f_lesser_honours_and_knitted_tiles { my ($v) = @_; return $v->{form} eq 'honours_knitted' ? _one() : () }
Subroutine _f_lesser_honours_and_knitted_tiles: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'form'} eq 'honours_knitted' ? : 30 2421 2451
211 2451 ▶sub _f_knitted_straight { my ($v) = @_; return $v->{form} eq 'knitted_straight' ? _one(@{ $v->{knits} }) : () }
Subroutine _f_knitted_straight: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'form'} eq 'knitted_straight' ? : 2 2449 2451
212 2451 ▶sub _f_upper_four { my ($v) = @_; return _every($v, _rank_in(6, 9)) ? _one() : () }
Subroutine _f_upper_four: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, _rank_in(6, 9)) ? : 80 2371 2451
213 2451 ▶sub _f_lower_four { my ($v) = @_; return _every($v, _rank_in(1, 4)) ? _one() : () }
Subroutine _f_lower_four: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, _rank_in(1, 4)) ? : 116 2335 2451
214 2451 ▶sub _f_big_three_winds { my ($v) = @_; my @w = _wind_pungs($v); return @w == 3 ? _one(@w) : () }
Subroutine _f_big_three_winds: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@w == 3 ? : 4 2447 2451
215 2451 ▶sub _f_mixed_straight { my ($v) = @_; return map { _one(@$_) } grep { _three_suits(@$_) && _bases_are('1,4,7', @$_) } _triples_of($v->{chows}) }
Subroutine _f_mixed_straight: called CC=2 SCAR=6.9
Condition100%3/3
_three_suits(@$_) && _bases_are('1,4,7', @$_)
!ll&&!rl&&r
255479791
MC/DC100%2/2
_three_suits(@$_) && _bases_are('1,4,7', @$_)
_three_suits(@$_) _bases_are('1,4,7', @$_)
Truth table100%3/3
A && B
A= _three_suits(@$_)B= _bases_are('1,4,7', @$_)
ABresult
0X0
100
111
216 2451 ▶sub _f_reversible_tiles { my ($v) = @_; return _every($v, \&Game::Mahjong::Tiles::is_reversible) ? _one() : () }
Subroutine _f_reversible_tiles: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Tiles::is_reversible) ? : 105 2346 2451
217 2451 ▶sub _f_mixed_triple_chow { my ($v) = @_; return map { _one(@$_) } grep { _three_suits(@$_) && _bases_shifted(0, @$_) } _triples_of($v->{chows}) }
Subroutine _f_mixed_triple_chow: called CC=2 SCAR=6.9
Condition100%3/3
_three_suits(@$_) && _bases_shifted(0, @$_)
!ll&&!rl&&r
255486622
MC/DC100%2/2
_three_suits(@$_) && _bases_shifted(0, @$_)
_three_suits(@$_) _bases_shifted(0, @$_)
Truth table100%3/3
A && B
A= _three_suits(@$_)B= _bases_shifted(0, @$_)
ABresult
0X0
100
111
218 2451 ▶sub _f_mixed_shifted_pungs { my ($v) = @_; my @p = grep { defined $_->{suit} } @{ $v->{pungs} }; return map { _one(@$_) } grep { _three_suits(@$_) && _bases_shifted(1, @$_) } _triples_of(\@p) }
Subroutine _f_mixed_shifted_pungs: called CC=2 SCAR=6.9
Condition100%3/3
_three_suits(@$_) && _bases_shifted(1, @$_)
!ll&&!rl&&r
612523
MC/DC100%2/2
_three_suits(@$_) && _bases_shifted(1, @$_)
_three_suits(@$_) _bases_shifted(1, @$_)
Truth table100%3/3
A && B
A= _three_suits(@$_)B= _bases_shifted(1, @$_)
ABresult
0X0
100
111
219 0 ▶sub _f_chicken_hand { return () }
Subroutine _f_chicken_hand: not called CC=1 SCAR=6.9
220 2451 ▶sub _f_last_tile_draw { my ($v) = @_; return ($v->{ctx}{by} // '') eq 'self' && $v->{ctx}{last_of_wall} ? _one() : () }
Subroutine _f_last_tile_draw: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
($v->{'ctx'}{'by'} // '') eq 'self' && $v->{'ctx'}{'last_of_wall'} ? : 10 2441 2451
Condition100%5/5
($v->{"ctx"}{"by"} // "") eq "self" and $v->{"ctx"}{"last_of_wall"}
!ll&&!rl&&r
212231910
$v->{"ctx"}{"by"} // ""
l!l
2123328
MC/DC100%2/2
($v->{"ctx"}{"by"} // "") eq "self" and $v->{"ctx"}{"last_of_wall"}
$v->{"ctx"}{"by"} $v->{"ctx"}{"last_of_wall"}
Truth table100%3/3
A and B
A= $v->{"ctx"}{"by"}B= $v->{"ctx"}{"last_of_wall"}
ABresult
0X0
100
111
221 2451 ▶sub _f_last_tile_claim { my ($v) = @_; return ($v->{ctx}{by} // '') eq 'discard' && $v->{ctx}{last_of_wall} ? _one() : () }
Subroutine _f_last_tile_claim: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
($v->{'ctx'}{'by'} // '') eq 'discard' && $v->{'ctx'}{'last_of_wall'} ? : 14 2437 2451
Condition100%5/5
($v->{"ctx"}{"by"} // "") eq "discard" and $v->{"ctx"}{"last_of_wall"}
!ll&&!rl&&r
662177514
$v->{"ctx"}{"by"} // ""
l!l
2123328
MC/DC100%2/2
($v->{"ctx"}{"by"} // "") eq "discard" and $v->{"ctx"}{"last_of_wall"}
$v->{"ctx"}{"by"} $v->{"ctx"}{"last_of_wall"}
Truth table100%3/3
A and B
A= $v->{"ctx"}{"by"}B= $v->{"ctx"}{"last_of_wall"}
ABresult
0X0
100
111
222 2451 ▶sub _f_out_with_replacement_tile { my ($v) = @_; return ($v->{ctx}{replacement} // '') eq 'kong' ? _one() : () }
Subroutine _f_out_with_replacement_tile: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
($v->{'ctx'}{'replacement'} // '') eq 'kong' ? : 5 2446 2451
Condition100%2/2
$v->{"ctx"}{"replacement"} // ""
l!l
212430
MC/DC100%1/1
$v->{"ctx"}{"replacement"} // ""
$v->{"ctx"}{"replacement"}
Truth table100%2/2
A
A= $v->{"ctx"}{"replacement"}
Aresult
11
00
223 2451 ▶sub _f_robbing_the_kong { my ($v) = @_; return ($v->{ctx}{by} // '') eq 'rob' ? _one() : () }
Subroutine _f_robbing_the_kong: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
($v->{'ctx'}{'by'} // '') eq 'rob' ? : 5 2446 2451
Condition100%2/2
$v->{"ctx"}{"by"} // ""
l!l
2123328
MC/DC100%1/1
$v->{"ctx"}{"by"} // ""
$v->{"ctx"}{"by"}
Truth table100%2/2
A
A= $v->{"ctx"}{"by"}
Aresult
11
00
224 2451 ▶sub _f_two_concealed_kongs { my ($v) = @_; my @c = grep { $_->{concealed} } @{ $v->{kongs} }; return @c >= 2 ? _one(@c[0, 1]) : () }
Subroutine _f_two_concealed_kongs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@c >= 2 ? : 2 2449 2451
225 2451 ▶sub _f_all_pungs { my ($v) = @_; return _standard($v) && @{ $v->{pungs} } == 4 ? _one(@{ $v->{pungs} }) : () }
Subroutine _f_all_pungs: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
_standard($v) && @{$v->{'pungs'};} == 4 ? : 43 2408 2451
Condition100%3/3
_standard($v) and @{$v->{"pungs"};} == 4
!ll&&!rl&&r
68234043
MC/DC100%2/2
_standard($v) and @{$v->{"pungs"};} == 4
_standard($v) @{$v->{"pungs"};} == 4
Truth table100%3/3
A and B
A= _standard($v)B= @{$v->{"pungs"};} == 4
ABresult
0X0
100
111
226 2451 ▶sub _f_half_flush { my ($v) = @_; return $v->{nsuits} == 1 && $v->{honours} ? _one() : () }
Subroutine _f_half_flush: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
$v->{'nsuits'} == 1 && $v->{'honours'} ? : 50 2401 2451
Condition100%3/3
$v->{"nsuits"} == 1 and $v->{"honours"}
!ll&&!rl&&r
209830350
MC/DC100%2/2
$v->{"nsuits"} == 1 and $v->{"honours"}
$v->{"nsuits"} == 1 $v->{"honours"}
Truth table100%3/3
A and B
A= $v->{"nsuits"} == 1B= $v->{"honours"}
ABresult
0X0
100
111
227 2451 ▶sub _f_mixed_shifted_chows { my ($v) = @_; return map { _one(@$_) } grep { _three_suits(@$_) && _bases_shifted(1, @$_) } _triples_of($v->{chows}) }
Subroutine _f_mixed_shifted_chows: called CC=2 SCAR=6.9
Condition100%3/3
_three_suits(@$_) && _bases_shifted(1, @$_)
!ll&&!rl&&r
255479791
MC/DC100%2/2
_three_suits(@$_) && _bases_shifted(1, @$_)
_three_suits(@$_) _bases_shifted(1, @$_)
Truth table100%3/3
A && B
A= _three_suits(@$_)B= _bases_shifted(1, @$_)
ABresult
0X0
100
111
228 2451 ▶sub _f_all_types {
Subroutine _f_all_types: called CC=10 SCAR=23.2
229 2451 my ($v) = @_;
230 2451 ▶ return () unless $v->{form} eq 'standard' || $v->{form} eq 'seven_pairs';
Branch: 1 branch
BranchTrueFalseTotal
unless $v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs" 38 2413 2451
Condition100%3/3
$v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs"
l!l&&r!l&&!r
23833038
MC/DC100%2/2
$v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs"
$v->{"form"} eq "standard" $v->{"form"} eq "seven_pairs"
Truth table100%3/3
A or B
A= $v->{"form"} eq "standard"B= $v->{"form"} eq "seven_pairs"
ABresult
1X1
011
000
231 2413 my %type;
232 2413 for my $e (@{ $v->{elements} }) {
233 10871 ▶ return () if $e->{kind} eq 'knit';
Branch: 1 branch
BranchTrueFalseTotal
if $e->{"kind"} eq "knit" 0 10871 10871
234 10871 ▶ my $t = $e->{suit} // (Game::Mahjong::Tiles::is_wind($e->{tile}) ? 'wind' : 'dragon');
Branch: 1 branch
BranchTrueFalseTotal
Game::Mahjong::Tiles::is_wind($e->{'tile'}) ? : 440 374 814
Condition66%2/3
$e->{"suit"} // (Game::Mahjong::Tiles::is_wind($e->{"tile"}) ? "wind" : "dragon")
l!l&&r!l&&!r
100578140
MC/DC0%0/2
$e->{"suit"} // (Game::Mahjong::Tiles::is_wind($e->{"tile"}) ? "wind" : "dragon")
$e->{"suit"} (Game::Mahjong::Tiles::is_wind($e->{"tile"}) ? "wind" : "dragon")
Truth table66%2/3
A // B
A= $e->{"suit"}B= (Game::Mahjong::Tiles::is_wind($e->{"tile"}) ? "wind" : "dragon")
ABresult
1X1
011
000
235 10871 $type{$t}++;
236 }
237 2413 ▶ return () unless keys %type == 5;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %type == 5 2401 12 2413
238 12 ▶ return () if $v->{form} eq 'standard' && grep { $_ != 1 } values %type;
Branch: 1 branch
BranchTrueFalseTotal
if $v->{"form"} eq "standard" and grep {$_ != 1;} values %type 0 12 12
Condition66%2/3
$v->{"form"} eq "standard" and grep {$_ != 1;} values %type
!ll&&!rl&&r
1110
MC/DC0%0/2
$v->{"form"} eq "standard" and grep {$_ != 1;} values %type
$v->{"form"} eq "standard" grep {$_ != 1;} values %type
Truth table66%2/3
A and B
A= $v->{"form"} eq "standard"B= grep {$_ != 1;} values %type
ABresult
0X0
100
111
239 12 return _one(@{ $v->{sets} });
240 }
241 2451 ▶sub _f_melded_hand {
Subroutine _f_melded_hand: called CC=7 SCAR=19.7
242 2451 my ($v) = @_;
243 2451 ▶ return () unless _standard($v) && $v->{exposed} == 4 && ($v->{ctx}{by} // '') ne 'self' && ($v->{place_in} // '') eq 'pair';
Branch: 1 branch
BranchTrueFalseTotal
unless _standard($v) and $v->{"exposed"} == 4 and ($v->{"ctx"}{"by"} // "") ne "self" and ($v->{"place_in"} // "") eq "pair" 2442 9 2451
Condition76%10/13
_standard($v) and $v->{"exposed"} == 4 and ($v->{"ctx"}{"by"} // "") ne "self" and ($v->{"place_in"} // "") eq "pair"
!ll&&!rl&&r
244209
_standard($v) and $v->{"exposed"} == 4 and ($v->{"ctx"}{"by"} // "") ne "self"
!ll&&!rl&&r
2431119
_standard($v) and $v->{"exposed"} == 4
!ll&&!rl&&r
68236320
$v->{"ctx"}{"by"} // ""
l!l
200
$v->{"place_in"} // ""
l!l
90
MC/DC50%2/4
_standard($v) and $v->{"exposed"} == 4 and ($v->{"ctx"}{"by"} // "") ne "self" and ($v->{"place_in"} // "") eq "pair"
_standard($v) $v->{"exposed"} == 4 $v->{"ctx"}{"by"} $v->{"place_in"}
Truth table60%3/5
A and B and C and D
A= _standard($v)B= $v->{"exposed"} == 4C= $v->{"ctx"}{"by"}D= $v->{"place_in"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
244 9 return _one(@{ $v->{sets} });
245 }
246 2451 ▶sub _f_two_dragon_pungs { my ($v) = @_; my @d = _dragon_pungs($v); return @d == 2 ? _one(@d) : () }
Subroutine _f_two_dragon_pungs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@d == 2 ? : 12 2439 2451
247 2451 ▶sub _f_outside_hand {
Subroutine _f_outside_hand: called CC=6 SCAR=17.9
248 2451 my ($v) = @_;
249 2451 ▶ return () unless $v->{form} eq 'standard' || $v->{form} eq 'seven_pairs';
Branch: 1 branch
BranchTrueFalseTotal
unless $v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs" 38 2413 2451
Condition100%3/3
$v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs"
l!l&&r!l&&!r
23833038
MC/DC100%2/2
$v->{"form"} eq "standard" or $v->{"form"} eq "seven_pairs"
$v->{"form"} eq "standard" $v->{"form"} eq "seven_pairs"
Truth table100%3/3
A or B
A= $v->{"form"} eq "standard"B= $v->{"form"} eq "seven_pairs"
ABresult
1X1
011
000
250 2413 for my $e (@{ $v->{elements} }) {
251 3452 ▶ return () if $e->{kind} eq 'knit';
Branch: 1 branch
BranchTrueFalseTotal
if $e->{"kind"} eq "knit" 0 3452 3452
252 3452 ▶ return () unless grep { _is_terminal_or_honour($_) } @{ $e->{tiles} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_is_terminal_or_honour($_);} @{$$e{"tiles"};} 2253 1199 3452
253 }
254 160 return _one(@{ $v->{sets} });
255 }
256 2451 ▶sub _f_fully_concealed_hand { my ($v) = @_; return $v->{exposed} == 0 && ($v->{ctx}{by} // '') eq 'self' ? _one() : () }
Subroutine _f_fully_concealed_hand: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'exposed'} == 0 && ($v->{'ctx'}{'by'} // '') eq 'self' ? : 226 2225 2451
Condition80%4/5
$v->{"exposed"} == 0 and ($v->{"ctx"}{"by"} // "") eq "self"
!ll&&!rl&&r
1602623226
$v->{"ctx"}{"by"} // ""
l!l
8490
MC/DC50%1/2
$v->{"exposed"} == 0 and ($v->{"ctx"}{"by"} // "") eq "self"
$v->{"exposed"} == 0 $v->{"ctx"}{"by"}
Truth table66%2/3
A and B
A= $v->{"exposed"} == 0B= $v->{"ctx"}{"by"}
ABresult
0X0
100
111
257 2451 ▶sub _f_two_melded_kongs {
Subroutine _f_two_melded_kongs: called CC=5 SCAR=16.1
258 2451 my ($v) = @_;
259 2451 my @m = grep { !$_->{concealed} } @{ $v->{kongs} };
260 2451 my @c = grep { $_->{concealed} } @{ $v->{kongs} };
261 2451 ▶ return _one(@m[0, 1]) if @m >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if @m >= 2 11 2440 2451
262 2440 ▶ return ({ sets => [ $m[0]{i}, $c[0]{i} ], points => 6 }) if @m == 1 && @c == 1 && @{ $v->{kongs} } == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @m == 1 and @c == 1 and @{$v->{"kongs"};} == 2 6 2434 2440
Condition83%5/6
@m == 1 and @c == 1 and @{$v->{"kongs"};} == 2
!ll&&!rl&&r
243406
@m == 1 and @c == 1
!ll&&!rl&&r
2403316
MC/DC66%2/3
@m == 1 and @c == 1 and @{$v->{"kongs"};} == 2
@m == 1 @c == 1 @{$v->{"kongs"};} == 2
Truth table75%3/4
A and B and C
A= @m == 1B= @c == 1C= @{$v->{"kongs"};} == 2
ABCresult
0XX0
10X0
1100
1111
263 2434 return ();
264 }
265 2451 ▶sub _f_last_tile { my ($v) = @_; return $v->{ctx}{last_tile} ? _one() : () }
Subroutine _f_last_tile: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'ctx'}{'last_tile'} ? : 118 2333 2451
266 2451 ▶sub _f_dragon_pung { my ($v) = @_; return map { _one($_) } _dragon_pungs($v) }
Subroutine _f_dragon_pung: called CC=1 SCAR=0.0
267 2451 ▶sub _f_prevalent_wind { my ($v) = @_; my $w = _wind_of($v, 'prevailing'); return map { _one($_) } grep { $_->{tile} == $w } @{ $v->{pungs} } }
Subroutine _f_prevalent_wind: called CC=1 SCAR=0.0
268 2451 ▶sub _f_seat_wind { my ($v) = @_; my $w = _wind_of($v, 'seat'); return map { _one($_) } grep { $_->{tile} == $w } @{ $v->{pungs} } }
Subroutine _f_seat_wind: called CC=1 SCAR=0.0
269 2451 ▶sub _f_concealed_hand { my ($v) = @_; return $v->{exposed} == 0 && ($v->{ctx}{by} // '') ne 'self' && defined $v->{ctx}{by} ? _one() : () }
Subroutine _f_concealed_hand: called CC=5 SCAR=16.3
Branch: 1 branch
BranchTrueFalseTotal
$v->{'exposed'} == 0 && ($v->{'ctx'}{'by'} // '') ne 'self' && defined $v->{'ctx'}{'by'} ? : 623 1828 2451
Condition75%6/8
$v->{"exposed"} == 0 and ($v->{"ctx"}{"by"} // "") ne "self" and defined $v->{"ctx"}{"by"}
!ll&&!rl&&r
18280623
$v->{"exposed"} == 0 and ($v->{"ctx"}{"by"} // "") ne "self"
!ll&&!rl&&r
1602226623
$v->{"ctx"}{"by"} // ""
l!l
8490
MC/DC33%1/3
$v->{"exposed"} == 0 and ($v->{"ctx"}{"by"} // "") ne "self" and defined $v->{"ctx"}{"by"}
$v->{"exposed"} == 0 $v->{"ctx"}{"by"} defined $v->{"ctx"}{"by"}
Truth table50%2/4
A and B and C
A= $v->{"exposed"} == 0B= $v->{"ctx"}{"by"}C= defined $v->{"ctx"}{"by"}
ABCresult
0XX0
10X0
1100
1111
270 2451 ▶sub _f_all_chows { my ($v) = @_; return _standard($v) && @{ $v->{chows} } == 4 && !$v->{honours} ? _one(@{ $v->{chows} }) : () }
Subroutine _f_all_chows: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
_standard($v) && @{$v->{'chows'};} == 4 && !$v->{'honours'} ? : 502 1949 2451
Condition100%6/6
_standard($v) and @{$v->{"chows"};} == 4 and not $v->{"honours"}
!ll&&!rl&&r
1830119502
_standard($v) and @{$v->{"chows"};} == 4
!ll&&!rl&&r
681762621
MC/DC100%3/3
_standard($v) and @{$v->{"chows"};} == 4 and not $v->{"honours"}
_standard($v) @{$v->{"chows"};} == 4 not $v->{"honours"}
Truth table100%4/4
A and B and not(C)
A= _standard($v)B= @{$v->{"chows"};} == 4C= not $v->{"honours"}
ABCresult
0XX0
10X0
1100
1111
271 2451 ▶sub _f_tile_hog {
Subroutine _f_tile_hog: called CC=3 SCAR=11.0
272 2451 my ($v) = @_;
273 2451 my %konged = map { $_->{tile} => 1 } @{ $v->{kongs} };
274 2451 ▶ my @hogs = grep { $v->{count}{$_} == 4 && !$konged{$_} && Game::Mahjong::Tiles::is_suit($_) } sort { $a <=> $b } keys %{ $v->{count} };
Condition83%5/6
$v->{'count'}{$_} == 4 && !$konged{$_} && Game::Mahjong::Tiles::is_suit($_)
!ll&&!rl&&r
214270174
$v->{"count"}{$_} == 4 and not $konged{$_}
!ll&&!rl&&r
21314113174
MC/DC66%2/3
$v->{'count'}{$_} == 4 && !$konged{$_} && Game::Mahjong::Tiles::is_suit($_)
$v->{"count"}{$_} == 4 not $konged{$_} Game::Mahjong::Tiles::is_suit($_)
Truth table75%3/4
A and not(B) && C
A= $v->{"count"}{$_} == 4B= not $konged{$_}C= Game::Mahjong::Tiles::is_suit($_)
ABCresult
0XX0
10X0
1100
1111
275 2451 return map { ({ sets => [], kind => $_ }) } @hogs;
276 }
277 2451 ▶sub _f_double_pung { my ($v) = @_; my @p = grep { defined $_->{suit} } @{ $v->{pungs} }; return map { _one(@$_) } grep { $_->[0]{suit} ne $_->[1]{suit} && $_->[0]{base} == $_->[1]{base} } _pairs_of(\@p) }
Subroutine _f_double_pung: called CC=2 SCAR=6.9
Condition100%3/3
$_->[0]{'suit'} ne $_->[1]{'suit'} && $_->[0]{'base'} == $_->[1]{'base'}
!ll&&!rl&&r
16127964
MC/DC100%2/2
$_->[0]{'suit'} ne $_->[1]{'suit'} && $_->[0]{'base'} == $_->[1]{'base'}
$_->[0]{'suit'} ne $_->[1]{'suit'} $_->[0]{'base'} == $_->[1]{'base'}
Truth table100%3/3
A && B
A= $_->[0]{'suit'} ne $_->[1]{'suit'}B= $_->[0]{'base'} == $_->[1]{'base'}
ABresult
0X0
100
111
278 2451 ▶sub _f_two_concealed_pungs { my ($v) = @_; my @c = @{ $v->{concealed_pungs} }; return @c == 2 ? _one(@c) : () }
Subroutine _f_two_concealed_pungs: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@c == 2 ? : 179 2272 2451
279 2451 ▶sub _f_concealed_kong { my ($v) = @_; return map { _one($_) } grep { $_->{concealed} } @{ $v->{kongs} } }
Subroutine _f_concealed_kong: called CC=1 SCAR=0.0
280 2451 ▶sub _f_all_simples { my ($v) = @_; return _every($v, \&Game::Mahjong::Tiles::is_simple) ? _one() : () }
Subroutine _f_all_simples: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
_every($v, \&Game::Mahjong::Tiles::is_simple) ? : 384 2067 2451
281 2451 ▶sub _f_pure_double_chow { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && $_->[0]{base} == $_->[1]{base} } _pairs_of($v->{chows}) }
Subroutine _f_pure_double_chow: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && $_->[0]{'base'} == $_->[1]{'base'}
!ll&&!rl&&r
48111840293
MC/DC100%2/2
_same_suit(@$_) && $_->[0]{'base'} == $_->[1]{'base'}
_same_suit(@$_) $_->[0]{'base'} == $_->[1]{'base'}
Truth table100%3/3
A && B
A= _same_suit(@$_)B= $_->[0]{'base'} == $_->[1]{'base'}
ABresult
0X0
100
111
282 2451 ▶sub _f_mixed_double_chow { my ($v) = @_; return map { _one(@$_) } grep { $_->[0]{suit} ne $_->[1]{suit} && $_->[0]{base} == $_->[1]{base} } _pairs_of($v->{chows}) }
Subroutine _f_mixed_double_chow: called CC=2 SCAR=6.9
Condition100%3/3
$_->[0]{'suit'} ne $_->[1]{'suit'} && $_->[0]{'base'} == $_->[1]{'base'}
!ll&&!rl&&r
21334243568
MC/DC100%2/2
$_->[0]{'suit'} ne $_->[1]{'suit'} && $_->[0]{'base'} == $_->[1]{'base'}
$_->[0]{'suit'} ne $_->[1]{'suit'} $_->[0]{'base'} == $_->[1]{'base'}
Truth table100%3/3
A && B
A= $_->[0]{'suit'} ne $_->[1]{'suit'}B= $_->[0]{'base'} == $_->[1]{'base'}
ABresult
0X0
100
111
283 2451 ▶sub _f_short_straight { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && abs($_->[0]{base} - $_->[1]{base}) == 3 } _pairs_of($v->{chows}) }
Subroutine _f_short_straight: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && abs $_->[0]{'base'} - $_->[1]{'base'} == 3
!ll&&!rl&&r
48111587546
MC/DC100%2/2
_same_suit(@$_) && abs $_->[0]{'base'} - $_->[1]{'base'} == 3
_same_suit(@$_) abs $_->[0]{'base'} - $_->[1]{'base'} == 3
Truth table100%3/3
A && B
A= _same_suit(@$_)B= abs $_->[0]{'base'} - $_->[1]{'base'} == 3
ABresult
0X0
100
111
284 2451 ▶sub _f_two_terminal_chows { my ($v) = @_; return map { _one(@$_) } grep { _same_suit(@$_) && _bases_are('1,7', @$_) } _pairs_of($v->{chows}) }
Subroutine _f_two_terminal_chows: called CC=2 SCAR=6.9
Condition100%3/3
_same_suit(@$_) && _bases_are('1,7', @$_)
!ll&&!rl&&r
48112001132
MC/DC100%2/2
_same_suit(@$_) && _bases_are('1,7', @$_)
_same_suit(@$_) _bases_are('1,7', @$_)
Truth table100%3/3
A && B
A= _same_suit(@$_)B= _bases_are('1,7', @$_)
ABresult
0X0
100
111
285 2451 ▶sub _f_pung_of_terminals_or_honours {
Subroutine _f_pung_of_terminals_or_honours: called CC=4 SCAR=13.9
286 2451 my ($v) = @_;
287 2451 my ($prev, $seat) = (_wind_of($v, 'prevailing'), _wind_of($v, 'seat'));
288 900 return map { _one($_) } grep {
289 2363 my $t = $_->{tile};
290 2363 ▶ (Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_wind($t)) && $t != $prev && $t != $seat
Condition100%9/9
(Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_wind($t)) && $t != $prev && $t != $seat
!ll&&!rl&&r
138479900
Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_wind($t) and $t != $prev
!ll&&!rl&&r
1280104979
Game::Mahjong::Tiles::is_terminal($t) or Game::Mahjong::Tiles::is_wind($t)
l!l&&r!l&&!r
7803031280
MC/DC100%4/4
(Game::Mahjong::Tiles::is_terminal($t) || Game::Mahjong::Tiles::is_wind($t)) && $t != $prev && $t != $seat
Game::Mahjong::Tiles::is_terminal($t) Game::Mahjong::Tiles::is_wind($t) $t != $prev $t != $seat
Truth table71%5/7
A or B and C && D
A= Game::Mahjong::Tiles::is_terminal($t)B= Game::Mahjong::Tiles::is_wind($t)C= $t != $prevD= $t != $seat
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
291 2451 } @{ $v->{pungs} };
292 }
293 2451 ▶sub _f_melded_kong { my ($v) = @_; return map { _one($_) } grep { !$_->{concealed} } @{ $v->{kongs} } }
Subroutine _f_melded_kong: called CC=1 SCAR=0.0
294 2451 ▶sub _f_one_voided_suit { my ($v) = @_; return $v->{nsuits} == 2 ? _one() : () }
Subroutine _f_one_voided_suit: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$v->{'nsuits'} == 2 ? : 619 1832 2451
295 2451 ▶sub _f_no_honours { my ($v) = @_; return !$v->{honours} && @{ $v->{tiles} } ? _one() : () }
Subroutine _f_no_honours: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
!$v->{'honours'} && @{$v->{'tiles'};} ? : 1698 753 2451
Condition66%2/3
not $v->{"honours"} and @{$v->{"tiles"};}
!ll&&!rl&&r
75301698
MC/DC50%1/2
not $v->{"honours"} and @{$v->{"tiles"};}
not $v->{"honours"} @{$v->{"tiles"};}
Truth table66%2/3
not(A) and B
A= not $v->{"honours"}B= @{$v->{"tiles"};}
ABresult
0X0
100
111
296 2451 ▶sub _f_edge_wait { my ($v) = @_; return ($v->{wait} // '') eq 'edge' && $v->{nwaits} == 1 ? _one() : () }
Subroutine _f_edge_wait: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
($v->{'wait'} // '') eq 'edge' && $v->{'nwaits'} == 1 ? : 114 2337 2451
Condition100%5/5
($v->{"wait"} // "") eq "edge" and $v->{"nwaits"} == 1
!ll&&!rl&&r
232017114
$v->{"wait"} // ""
l!l
1874577
MC/DC100%2/2
($v->{"wait"} // "") eq "edge" and $v->{"nwaits"} == 1
$v->{"wait"} $v->{"nwaits"} == 1
Truth table100%3/3
A and B
A= $v->{"wait"}B= $v->{"nwaits"} == 1
ABresult
0X0
100
111
297 2451 ▶sub _f_closed_wait { my ($v) = @_; return ($v->{wait} // '') eq 'closed' && $v->{nwaits} == 1 ? _one() : () }
Subroutine _f_closed_wait: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
($v->{'wait'} // '') eq 'closed' && $v->{'nwaits'} == 1 ? : 223 2228 2451
Condition100%5/5
($v->{"wait"} // "") eq "closed" and $v->{"nwaits"} == 1
!ll&&!rl&&r
217652223
$v->{"wait"} // ""
l!l
1874577
MC/DC100%2/2
($v->{"wait"} // "") eq "closed" and $v->{"nwaits"} == 1
$v->{"wait"} $v->{"nwaits"} == 1
Truth table100%3/3
A and B
A= $v->{"wait"}B= $v->{"nwaits"} == 1
ABresult
0X0
100
111
298 2451 ▶sub _f_single_wait { my ($v) = @_; my $w = $v->{wait} // ''; return ($w eq 'pair' || $w eq 'single') && $v->{nwaits} == 1 ? _one() : () }
Subroutine _f_single_wait: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
($w eq 'pair' || $w eq 'single') && $v->{'nwaits'} == 1 ? : 131 2320 2451
Condition100%8/8
$v->{"wait"} // ""
l!l
1874577
$w eq "pair" || $w eq "single" and $v->{"nwaits"} == 1
!ll&&!rl&&r
222496131
$w eq "pair" or $w eq "single"
l!l&&r!l&&!r
200272224
MC/DC100%1/1
$v->{"wait"} // ""
$v->{"wait"}
MC/DC100%3/3
$w eq "pair" || $w eq "single" and $v->{"nwaits"} == 1
$w eq "pair" $w eq "single" $v->{"nwaits"} == 1
Truth table100%2/2
A
A= $v->{"wait"}
Aresult
11
00
Truth table100%5/5
A or B and C
A= $w eq "pair"B= $w eq "single"C= $v->{"nwaits"} == 1
ABCresult
00X0
1X00
0100
1X11
0111
299 2451 ▶sub _f_self_drawn { my ($v) = @_; return ($v->{ctx}{by} // '') eq 'self' ? _one() : () }
Subroutine _f_self_drawn: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
($v->{'ctx'}{'by'} // '') eq 'self' ? : 329 2122 2451
Condition100%2/2
$v->{"ctx"}{"by"} // ""
l!l
2123328
MC/DC100%1/1
$v->{"ctx"}{"by"} // ""
$v->{"ctx"}{"by"}
Truth table100%2/2
A
A= $v->{"ctx"}{"by"}
Aresult
11
00
300 2451 ▶sub _f_flower_tiles { my ($v) = @_; my $n = $v->{ctx}{flowers} || 0; return map { _one() } 1 .. $n }
Subroutine _f_flower_tiles: called CC=2 SCAR=6.9
Condition100%2/2
$v->{'ctx'}{'flowers'} || 0
l!l
1699752
MC/DC100%1/1
$v->{'ctx'}{'flowers'} || 0
$v->{'ctx'}{'flowers'}
Truth table100%2/2
A
A= $v->{'ctx'}{'flowers'}
Aresult
11
00
301  
302 34 my @ROWS = (
303 [ 1, 'big_four_winds', 'Big Four Winds', 88,
304 'The hand includes Pungs (or Kongs) of all four Wind Tiles. Does not combine with Big Three Winds, All Pungs, Prevalent Wind, Seat Wind, or Pung of Terminals or Honors.',
305 [qw(big_three_winds all_pungs prevalent_wind seat_wind pung_of_terminals_or_honours)], [qw(little_four_winds)] ],
306 [ 2, 'big_three_dragons', 'Big Three Dragons', 88,
307 'The hand includes Pungs (or Kong) of all three Dragon tiles. Does not combine with Two Dragons or Dragon Pung.',
308 [qw(two_dragon_pungs dragon_pung)], [qw(little_three_dragons)] ],
309 [ 3, 'all_green', 'All Green', 88,
310 'Hand is composed entirely of any of the 2, 3, 4, 6, 8 of Bamboo and Green Dragon. Combines with Full Flush and Half Flush.',
311 [], [] ],
312 [ 4, 'nine_gates', 'Nine Gates', 88,
313 'Holding the 1,1,1,2,3,4,5,6,7,8,9,9,9 tiles in one suit, creating the nine-sided wait of 1, 2, 3, 4, 5, 6, 7, 8, 9. Does not combine with Full Flush, Concealed hand, and Pung of Terminals or Honors.',
314 [qw(full_flush concealed_hand pung_of_terminals_or_honours)], [qw(no_honours one_voided_suit)] ],
315 [ 5, 'four_kongs', 'Four Kongs', 88,
316 'A hand that includes four Kongs. Points for concealed pungs may be added. Does not combine with Single Wait.',
317 [qw(single_wait)], [qw(all_pungs three_kongs two_concealed_kongs two_melded_kongs concealed_kong melded_kong)] ],
318 [ 6, 'seven_shifted_pairs', 'Seven Shifted Pairs', 88,
319 'Hand is composed of seven pairs in the same suit, each shifted one up from the last. Does not combine with Full Flush, Concealed hand, or Single Wait.',
320 [qw(full_flush concealed_hand single_wait)], [qw(seven_pairs no_honours one_voided_suit)] ],
321 [ 7, 'thirteen_orphans', 'Thirteen Orphans', 88,
322 'Hand is composed of singles of any 12 of the 1, 9, and Honor tiles, along with a pair of the 13th. Does not combine with All Types, Concealed Hand, or Single Wait.',
323 [qw(all_types concealed_hand single_wait)], [qw(all_terminals_and_honours outside_hand)] ],
324 [ 8, 'all_terminals', 'All Terminals', 64,
325 'The pair(s), Pungs or Kongs are all made up of 1 or 9 Number Tiles, without Honor Tiles. Does not combine with All Pungs, Outside Hand, Pung of Terminals or Honors or No Honors. Can combine with Double Pung or Triple Pung.',
326 [qw(all_pungs outside_hand pung_of_terminals_or_honours no_honours)], [qw(all_terminals_and_honours)] ],
327 [ 9, 'little_four_winds', 'Little Four Winds', 64,
328 'Hand includes three Pungs of Winds, and a pair of the fourth Wind. Combines with Prevalent Wind and Seat Wind, but does not combine with Big Three Winds, or Pung of Terminals or Honors.',
329 [qw(big_three_winds pung_of_terminals_or_honours)], [] ],
330 [ 10, 'little_three_dragons', 'Little Three Dragons', 64,
331 'Hand includes Pungs of two Dragons and a pair of the third Dragon. Does not combine with Dragon Pung, or Two Dragons.',
332 [qw(dragon_pung two_dragon_pungs)], [] ],
333 [ 11, 'all_honours', 'All Honors', 64,
334 'The pair(s), Pungs or Kongs are all made up of Honor Tiles. Can be formed with Pungs or Kongs, any of which may be concealed or melded. Does not combine with All Pungs, Outside Hand, and Pung of Terminals or Honors.',
335 [qw(all_pungs outside_hand pung_of_terminals_or_honours)], [qw(all_terminals_and_honours)] ],
336 [ 12, 'four_concealed_pungs', 'Four Concealed Pungs', 64,
337 'Hand includes four Pungs achieved without melding. Does not combine with All Pungs or Concealed. Does combine with Fully Concealed if Self-Drawn.',
338 [qw(all_pungs concealed_hand)], [qw(three_concealed_pungs two_concealed_pungs)] ],
339 [ 13, 'pure_terminal_chows', 'Pure Terminal Chows', 64,
340 'Hand consists of two each of the lower and upper terminal Chows in one suit, with a pair of fives in the same suit. Does not combine with Seven Pairs, Full Flush, All Chows, Pure Double Chow, or Two Terminal Chows.',
341 [qw(seven_pairs full_flush all_chows pure_double_chow two_terminal_chows)], [qw(no_honours one_voided_suit)] ],
342 [ 14, 'quadruple_chow', 'Quadruple Chow', 48,
343 'Four chows of the same numerical sequences in the same suit. Does not combine with Pure Shifted Pungs, Tile Hog, or Pure Double Chow.',
344 [qw(pure_shifted_pungs tile_hog pure_double_chow)], [qw(pure_triple_chow)] ],
345 [ 15, 'four_pure_shifted_pungs', 'Four Pure Shifted Pungs', 48,
346 'Four Pungs or Kongs in the same suit, each shifted up one from the last. Does not combine with Pure Triple Chow or All Pungs.',
347 [qw(pure_triple_chow all_pungs)], [qw(pure_shifted_pungs)] ],
348 [ 16, 'four_pure_shifted_chows', 'Four Pure Shifted Chows', 32,
349 'Four chows in one suit, each shifted up 1 or 2 numbers from the last, but not a combination of both. Does not combine with Short Straight.',
350 [qw(short_straight)], [qw(pure_shifted_chows)] ],
351 [ 17, 'three_kongs', 'Three Kongs', 32,
352 'Hand contains three Kongs. May combine with Three Concealed Pengs if the Kongs are all concealed.',
353 [], [qw(two_melded_kongs two_concealed_kongs concealed_kong melded_kong)] ],
354 [ 18, 'all_terminals_and_honours', 'All Terminals and Honors', 32,
355 'The pair(s), Pungs or Kongs are all made up of 1 or 9 Number Tiles and Honor Tiles. Does not combine with All Pungs or Pung of Terminals or Honors.',
356 [qw(all_pungs pung_of_terminals_or_honours)], [qw(outside_hand)] ],
357 [ 19, 'seven_pairs', 'Seven Pairs', 24,
358 'Hand consisting of seven pairs. Does not combine with Concealed Hand or Single Wait. May combine with Fully Concealed if Self-Drawn.',
359 [qw(concealed_hand single_wait)], [] ],
360 [ 20, 'greater_honours_and_knitted_tiles', 'Greater Honors and Knitted Tiles', 24,
361 'Formed by 7 single Honors (one of every Wind and Dragon), and singles of suit tiles belonging to separate Knitted sequences (for example, 1-4-7 of Bamboos, 2-5-8 of Characters, and 3-6-9 of Dots). Does not combine with All Types or Concealed Hand. May be combined with Fully Concealed if Self-Drawn.',
362 [qw(all_types concealed_hand)], [qw(lesser_honours_and_knitted_tiles)] ],
363 [ 21, 'all_even_pungs', 'All Even Pungs', 24,
364 'A hand formed with Pungs of even-numbered suit tiles, and a pair of the same. Does not combine with All Pungs or All Simples.',
365 [qw(all_pungs all_simples)], [qw(no_honours)] ],
366 [ 22, 'full_flush', 'Full Flush', 24,
367 'All the tiles are in the same suit. Does not combine with No Honors.',
368 [qw(no_honours)], [qw(one_voided_suit)] ],
369 [ 23, 'pure_triple_chow', 'Pure Triple Chow', 24,
370 'Three chows of the same numerical sequence and in the same suit. Does not combine with Pure Shifted Pungs or Pure Double Chow.',
371 [qw(pure_shifted_pungs pure_double_chow)], [] ],
372 [ 24, 'pure_shifted_pungs', 'Pure Shifted Pungs', 24,
373 'Three Pungs or Kongs of the same suit, each shifted one up from the last. Does not combine with Pure Triple Chow.',
374 [qw(pure_triple_chow)], [] ],
375 [ 25, 'upper_tiles', 'Upper Tiles', 24,
376 'Hand consisting entirely of 7, 8, and 9 tiles. Does not combine with No Honors.',
377 [qw(no_honours)], [qw(upper_four)] ],
378 [ 26, 'middle_tiles', 'Middle Tiles', 24,
379 'A hand consisting entirely of 4, 5, and 6 tiles. Does not combine with No Honors or All Simples.',
380 [qw(no_honours all_simples)], [] ],
381 [ 27, 'lower_tiles', 'Lower Tiles', 24,
382 'A hand consisting entirely of 1, 2, and 3 tiles. Does not combine with No Honors.',
383 [qw(no_honours)], [qw(lower_four)] ],
384 [ 28, 'pure_straight', 'Pure Straight', 16,
385 'Hand using one of every number, 1-9, in three consecutive chows, in the same suit.',
386 [], [] ],
387 [ 29, 'three_suited_terminal_chows', 'Three-Suited Terminal Chows', 16,
388 "Hand consisting of 1-2-3 + 7-8-9 in one suit (Two Terminal Chows), 1-2-3 + 7-8-9 in another suit, a pair of fives in the third suit. Doesn't combine with Pure Double Chow, Two Terminal Chows, No Honors, or All Chows.",
389 [qw(pure_double_chow two_terminal_chows no_honours all_chows)], [qw(mixed_double_chow)] ],
390 [ 30, 'pure_shifted_chows', 'Pure Shifted Chows', 16,
391 'Three chows in one suit, each shifted up either one or two numbers from the last, but not a combination of both.',
392 [], [] ],
393 [ 31, 'all_fives', 'All Fives', 16,
394 'A hand in which every element includes a 5 tile. Does not combine with All Simples.',
395 [qw(all_simples)], [qw(no_honours)] ],
396 [ 32, 'triple_pung', 'Triple Pung', 16,
397 'Three Pungs of the same number, in each suit.',
398 [], [qw(double_pung)] ],
399 [ 33, 'three_concealed_pungs', 'Three Concealed Pungs', 16,
400 'Three Pungs achieved without melding.',
401 [], [qw(two_concealed_pungs)] ],
402 [ 34, 'lesser_honours_and_knitted_tiles', 'Lesser Honors and Knitted Tiles', 12,
403 'A hand made of singles of the following tiles: Any Honors, along with Suit tiles that belong to different Knitted sequences (for example, 1-4-7 of Characters, 2-5-8 of Bamboos, and 3-6-9 of Dots - each of the 3 suits must belong to a different Knitted sequence, but not necessarily in the order listed here). Does not Combines with All Types and Concealed Hand. (Combines with Fully Concealed if Self-Drawn.)',
404 [qw(all_types concealed_hand)], [] ],
405 [ 35, 'knitted_straight', 'Knitted Straight', 12,
406 'A special Straight which is formed not with standard Chows but with 3 different Knitted sequences. For example, 1-4-7 of Dots, 2-5-8 of Characters, and 3-6-9 of Bamboos - but not necessarily in this order.',
407 [], [] ],
408 [ 36, 'upper_four', 'Upper Four', 12,
409 'A hand created solely with suit tiles 6 through 9. Does not combine with No Honors.',
410 [qw(no_honours)], [] ],
411 [ 37, 'lower_four', 'Lower Four', 12,
412 'A hand created with suit tiles 1 through 4 only. Does not combine with No Honors.',
413 [qw(no_honours)], [] ],
414 [ 38, 'big_three_winds', 'Big Three Winds', 12,
415 'Hand includes Pungs or Kongs of three of the Winds.',
416 [], [] ],
417 [ 39, 'mixed_straight', 'Mixed Straight', 8,
418 'Three chows in three suits making 9 continuous numbers (1-9).',
419 [], [] ],
420 [ 40, 'reversible_tiles', 'Reversible Tiles', 8,
421 'A hand created entirely with those tiles which are vertically symmetrical (1,2,3,4,5,8,9 Dots - 2,4,5,6,8,9 Bams , and White Dragon). Does not combine with One Voided Suit.',
422 [qw(one_voided_suit)], [] ],
423 [ 41, 'mixed_triple_chow', 'Mixed Triple Chow', 8,
424 'Three chows of the same numerical sequence, one in each suit.',
425 [], [qw(mixed_double_chow)] ],
426 [ 42, 'mixed_shifted_pungs', 'Mixed Shifted Pungs', 8,
427 'Three Pungs or Kongs, one in each suit, each shifted up one number from the last.',
428 [], [] ],
429 [ 43, 'chicken_hand', 'Chicken Hand', 8,
430 'A hand that would otherwise earn 0 points (excluding Flowers).',
431 [], [], 'chicken' ],
432 [ 44, 'last_tile_draw', 'Last Tile Draw', 8,
433 'Going out (making mahjong) on a pick of the very last tile of the wall. (Points for Self-Drawn may not be combined.)',
434 [qw(self_drawn)], [] ],
435 [ 45, 'last_tile_claim', 'Last Tile Claim', 8,
436 'The last tile (of the game) discarded by another player.',
437 [], [] ],
438 [ 46, 'out_with_replacement_tile', 'Out with Replacement Tile', 8,
439 'Going out (making mahjong) on the replacement tile drawn after achieving a kong (not on a Flower replacement).',
440 [], [] ],
441 [ 47, 'robbing_the_kong', 'Robbing The Kong', 8,
442 'Winning off the tile that somebody adds to a melded pung (to create a Kong). (The points for Last Tile may not be combined.)',
443 [qw(last_tile)], [] ],
444 [ 48, 'two_concealed_kongs', 'Two Concealed Kongs', 8,
445 'Hand includes two Concealed Kongs.',
446 [], [qw(concealed_kong two_concealed_pungs)] ],
447 [ 49, 'all_pungs', 'All Pungs', 6,
448 'Hand includes four Pungs or Kongs and a pair.',
449 [], [] ],
450 [ 50, 'half_flush', 'Half Flush', 6,
451 'Formed by tiles from any one of the three suits, in combination with Honors.',
452 [], [] ],
453 [ 51, 'mixed_shifted_chows', 'Mixed Shifted Chows', 6,
454 'Three chows one in each suit, each shifted up one number from the last.',
455 [], [] ],
456 [ 52, 'all_types', 'All Types', 6,
457 'A hand in which each of the five sets is composed of a different type of tile (Characters, Bamboos, Dots, Winds, and Dragons).',
458 [], [] ],
459 [ 53, 'melded_hand', 'Melded Hand', 6,
460 'Every element or set in the hand, including the pair, must be completed with tiles discarded by other players. Does not combine with Single Wait.',
461 [qw(single_wait)], [] ],
462 [ 54, 'two_dragon_pungs', 'Two Dragons Pungs', 6,
463 'Two Pungs (or Kongs) of Dragon tiles.',
464 [], [qw(dragon_pung)] ],
465 [ 55, 'outside_hand', 'Outside Hand', 4,
466 'Hand includes Terminals and Honors in each element or set, including the Pair.',
467 [], [] ],
468 [ 56, 'fully_concealed_hand', 'Fully Concealed Hand', 4,
469 'A hand that a player completes without any melds and Self-Draws to win.',
470 [], [qw(self_drawn)] ],
471 [ 57, 'two_melded_kongs', 'Two Melded Kongs', 4,
472 'Hand includes two Melded Kongs. (A Melded Kong and a Concealed Kong make 6 points.)',
473 [], [qw(melded_kong concealed_kong)] ],
474 [ 58, 'last_tile', 'Last Tile', 4,
475 'Winning on a tile that is the last of its kind. (It must be clear to all players based on the discards and exposures.)',
476 [], [] ],
477 [ 59, 'dragon_pung', 'Dragon Pung', 2,
478 'A Pung or Kong of Dragon Tiles.',
479 [], [] ],
480 [ 60, 'prevalent_wind', 'Prevalent Wind', 2,
481 'A Pung or Kong of the Wind Tile corresponding to the current Prevalent Wind.',
482 [], [] ],
483 [ 61, 'seat_wind', 'Seat Wind', 2,
484 "A Pung or Kong of the Wind Tile corresponding to the player's Seat position at the table.",
485 [], [] ],
486 [ 62, 'concealed_hand', 'Concealed Hand', 2,
487 'All the tiles are Concealed; winning on a discard.',
488 [], [] ],
489 [ 63, 'all_chows', 'All Chows', 2,
490 'Hand consists of all Chows and no Honors. No Honors is implied.',
491 [], [qw(no_honours)] ],
492 [ 64, 'tile_hog', 'Tile Hog', 2,
493 'Using all four of a single suit tile, without using them as any kind of Kong.',
494 [], [] ],
495 [ 65, 'double_pung', 'Double Pung', 2,
496 'Two Pungs of the same number in two different suits.',
497 [], [] ],
498 [ 66, 'two_concealed_pungs', 'Two Concealed Pungs', 2,
499 'Two Pungs which are achieved without melding.',
500 [], [] ],
501 [ 67, 'concealed_kong', 'Concealed Kong', 2,
502 'Created when four identical tiles, all self-drawn, are declared as a Kong.',
503 [], [] ],
504 [ 68, 'all_simples', 'All Simples', 2,
505 'Hand formed without any Terminal or Honor Tiles.',
506 [], [qw(no_honours)] ],
507 [ 69, 'pure_double_chow', 'Pure Double Chow', 1,
508 'Two identical chows in the same suit.',
509 [], [] ],
510 [ 70, 'mixed_double_chow', 'Mixed Double Chow', 1,
511 'Two chows of the same numbers but in different suits.',
512 [], [] ],
513 [ 71, 'short_straight', 'Short Straight', 1,
514 'Two chows in the same suit that runs consecutively after one another to make a six-tile straight.',
515 [], [] ],
516 [ 72, 'two_terminal_chows', 'Two Terminal Chows', 1,
517 'Chows of 1-2-3 and 7-8-9 in the same suit.',
518 [], [] ],
519 [ 73, 'pung_of_terminals_or_honours', 'Pung of Terminals or Honors', 1,
520 'A Pung or Kong of Ones, Nines, or Winds. (A dragon pung scores 2 points.)',
521 [], [] ],
522 [ 74, 'melded_kong', 'Melded Kong', 1,
523 'A kong that was claimed from another player or promoted from a melded pung.',
524 [], [] ],
525 [ 75, 'one_voided_suit', 'One Voided Suit', 1,
526 'A hand that uses tiles from only two of the three suits (it lacks any tiles from one of the three suits).',
527 [], [] ],
528 [ 76, 'no_honours', 'No Honors', 1,
529 'A hand formed entirely of suit tiles, without Winds or Dragons.',
530 [], [] ],
531 [ 77, 'edge_wait', 'Edge Wait', 1,
532 'Waiting solely for a 3 to form a 1-2-3 chow, or solely for a 7 to form a 7-8-9 chow. Not valid if waiting for more than one tile. Not valid if the edge wait is combined with any other waits.',
533 [], [] ],
534 [ 78, 'closed_wait', 'Closed Wait', 1,
535 'Waiting solely for a tile whose number is "inside" (in the middle) to form a chow. Not valid if waiting for more than one tile. Not valid if the closed wait is combined with other waits',
536 [], [] ],
537 [ 79, 'single_wait', 'Single Waiting', 1,
538 'Waiting solely for a tile to form a pair. Not valid if waiting for more than one tile (for example, holding 1-2-3-4 and waiting on the 1 and 4).',
539 [], [] ],
540 [ 80, 'self_drawn', 'Self-Drawn', 1,
541 'Going out (making mahjong) with a fresh tile picked from the wall.',
542 [], [] ],
543 [ 81, 'flower_tiles', 'Flower Tiles', 1,
544 'Each tile carved with Chinese word for Spring, Summer, Autumn, Winter, Plum, Orchid, Bamboo or Chrysanthemum, will award you one point when you succeed in Hu.',
545 [], [] ],
546 );
547  
548 34 my %COMBINING = map { $_ => 1 } qw(
549 pure_double_chow mixed_double_chow short_straight two_terminal_chows double_pung
550 pure_triple_chow mixed_triple_chow pure_straight mixed_straight
551 pure_shifted_chows mixed_shifted_chows pure_shifted_pungs mixed_shifted_pungs triple_pung
552 quadruple_chow four_pure_shifted_chows four_pure_shifted_pungs
553 pure_terminal_chows three_suited_terminal_chows
554 );
555  
556 34 my %WHOLE = map { $_ => 1 } qw(
557 all_pungs all_chows all_fives all_even_pungs all_types outside_hand
558 melded_hand knitted_straight
559 );
560  
561 34 my (@FANS, %BY_KEY, %BY_N);
562 34 for my $row (@ROWS) {
563 2754 my ($n, $key, $name, $points, $says, $excludes, $implies, $special) = @$row;
564 2754 ▶ my $check = __PACKAGE__->can("_f_$key") or die "Game::Mahjong::Fans: no checker for $key";
Branch: 1 branch
BranchTrueFalseTotal
my $check = __PACKAGE__->can("_f_$key") or die "Game::Mahjong::Fans: no checker for $key" 2754 0 2754
565 my $fan = Game::Mahjong::Fan->new(
566 n => $n, key => $key, name => $name, points => $points, says => $says,
567 excludes => $excludes, implies => $implies, check => $check,
568 combining => $COMBINING{$key} ? 1 : 0,
569 2754 ▶ whole => $WHOLE{$key} ? 1 : 0,
Branch: 3 branches
BranchTrueFalseTotal
$COMBINING{$key} ? : 646 2108 2754
$WHOLE{$key} ? : 272 2482 2754
defined $special ? : 34 2720 2754
570 (defined $special ? (special => $special) : ()),
571 );
572 2754 push @FANS, $fan;
573 2754 $BY_KEY{$key} = $fan;
574 2754 $BY_N{$n} = $fan;
575 }
576  
577 2 ▶sub all { return @FANS }
Subroutine all: called CC=1 SCAR=0.0
Pod documented
578  
579 16509 ▶sub by_key {
Subroutine by_key: called CC=3 SCAR=11.1
Pod documented
580 16509 my ($key) = @_;
581 16509 ▶ return $BY_KEY{$key} || die "Game::Mahjong::Fans: no fan '" . (defined $key ? $key : 'undef') . "'";
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 1 0 1
Condition100%2/2
$BY_KEY{$key} || die(q[Game::Mahjong::Fans: no fan '] . (defined $key ? $key : 'undef') . q['])
l!l
165081
MC/DC0%0/1
$BY_KEY{$key} || die(q[Game::Mahjong::Fans: no fan '] . (defined $key ? $key : 'undef') . q['])
$BY_KEY{$key}
Truth table50%1/2
A
A= $BY_KEY{$key}
Aresult
11
00
582 }
583  
584 1 ▶sub by_n {
Subroutine by_n: called CC=3 SCAR=14.2
Pod documented
585 1 my ($n) = @_;
586 1 ▶ return $BY_N{$n} || die "Game::Mahjong::Fans: no fan number " . (defined $n ? $n : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
defined $n ? : 0 0 0
Condition50%1/2
$BY_N{$n} || die('Game::Mahjong::Fans: no fan number ' . (defined $n ? $n : 'undef'))
l!l
10
MC/DC0%0/1
$BY_N{$n} || die('Game::Mahjong::Fans: no fan number ' . (defined $n ? $n : 'undef'))
$BY_N{$n}
Truth table50%1/2
A
A= $BY_N{$n}
Aresult
11
00
587 }
588  
589 0 ▶sub keys_of { return map { $_->key } @FANS }
Subroutine keys_of: not called CC=1 SCAR=6.9
Pod documented
590  
591 2451 ▶sub check_all {
Subroutine check_all: called CC=4 SCAR=13.9
Pod documented
592 2451 my ($split, $ctx) = @_;
593 2451 my $v = view($split, $ctx);
594 2451 my %found;
595 2451 for my $fan (@FANS) {
596 198531 ▶ next if $fan->special;
Branch: 1 branch
BranchTrueFalseTotal
if $fan->special 2451 196080 198531
597 196080 my @i = $fan->instances($v);
598 196080 ▶ $found{ $fan->key } = \@i if @i;
Branch: 1 branch
BranchTrueFalseTotal
if @i 11614 184466 196080
599 }
600 2451 return \%found;
601 }
602  
603 34 1;
604  
605 __END__
« blib/lib/Game/Mahjong/Meld.pm ↑ Summary blib/lib/Game/Mahjong/Wall.pm »