| 1 | package Game::Senet::Engine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 80 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 80 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 80 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 80 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 80 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 80 | ▶ | use Object::Proto::Sugar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 80 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 80 | ▶ | use Game::Senet::Move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 80 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 80 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 80 | XSLoader::load('Game::Senet', $VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 80 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 80 | EMPTY => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | LIGHT => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | DARK => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | SIDE_LIGHT => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | SIDE_DARK => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | HOUSES => 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ROWS => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | COLS => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | PIECES_MAX => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ROLL_MAX => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | MOVES_MAX => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | WIN => 1_000_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | DEPTH_MAX => 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | CHAIN_MAX => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | REBIRTH => 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 80 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 80 | PROTECT_NONE => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | PROTECT_RUN => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | PROTECT_ENDS => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | REACH_EXACT => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | REACH_ANY => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | X_END => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | X_OFF => 31, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | X_WALK => 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | X_STAY => 33, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | RULES_KENDALL => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | RULES_SKYRUK => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 80 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 80 | ONGOING => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | WON => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | DRAWN => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | BY_HOME => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | BY_PLY_CAP => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 80 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 80 | POS_OK => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | POS_NULL => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | POS_GROUPS => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | POS_WIDTH => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | POS_LETTER => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | POS_SIDE => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | POS_PIECES => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | POS_EXCESS => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | POS_FIELD => 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | POS_LONG => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 80 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | EMPTY LIGHT DARK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | SIDE_LIGHT SIDE_DARK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | HOUSES ROWS COLS PIECES_MAX ROLL_MAX MOVES_MAX CHAIN_MAX REBIRTH WIN DEPTH_MAX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | PROTECT_NONE PROTECT_RUN PROTECT_ENDS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | REACH_EXACT REACH_ANY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | X_END X_OFF X_WALK X_STAY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | RULES_KENDALL RULES_SKYRUK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | POS_OK POS_NULL POS_GROUPS POS_WIDTH POS_LETTER POS_SIDE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | POS_PIECES POS_EXCESS POS_FIELD POS_LONG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ONGOING WON DRAWN BY_HOME BY_PLY_CAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | other piece_of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 80 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | sub other { $_[0] == SIDE_LIGHT ? SIDE_DARK : SIDE_LIGHT } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 232653 | ▶ | sub piece_of { $_[0] == SIDE_LIGHT ? LIGHT : DARK } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
piece_of: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 80 | has _ptr => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 80 | has _hold => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 80 | has _given_pieces => (is => 'ro', init_arg => 'pieces', private => 1, default => 5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 80 | has _position => (is => 'ro', init_arg => 'position', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 80 | my %ADOPTING; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 758481 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 758481 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 758481 | my $given = $self->_ptr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 758481 | ▶ | if ($given) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 583102 | ▶ | if (delete $ADOPTING{$given}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 583101 | $self->_hold(_hold_board($given)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 583101 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | $self->_ptr(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | Carp::croak("Game::Senet::Engine: a board is made by new, of_string or clone"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 175379 | my $position = $self->_position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 175379 | ▶ | if (defined $position) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 82477 | my ($ptr, $err) = _of_string($position); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 82477 | ▶ | Carp::croak("Game::Senet::Engine: the position was refused, code $err") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | unless defined $ptr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 82476 | $self->_ptr($ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 82476 | $self->_hold(_hold_board($ptr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 82476 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 92902 | my $pieces = $self->_given_pieces; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 92902 | ▶ | Carp::croak("Game::Senet::Engine: pieces is a whole number from 1 to 7") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $pieces and $pieces =~ /\A[1-7]\z/
MC/DC50%1/2
defined $pieces and $pieces =~ /\A[1-7]\z/
defined $pieces
$pieces =~ /\A[1-7]\z/
Truth table66%2/3
A and B
A= defined $piecesB= $pieces =~ /\A[1-7]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | unless defined $pieces && $pieces =~ /\A[1-7]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 92896 | $self->_ptr(_new_board($pieces)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 92896 | $self->_hold(_hold_board($self->_ptr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 92896 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 583101 | ▶ | my $adopt = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 583101 | my ($class, $ptr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 583101 | $ADOPTING{$ptr} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 583101 | return $class->new(_ptr => $ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1110 | ▶ | sub of_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
of_string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1110 | my ($class, $position) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1110 | ▶ | my ($ptr, $err) = _of_string(defined $position ? $position : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1110 | ▶ | return (undef, $err) unless defined $ptr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1023 | return ($adopt->($class, $ptr), POS_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 582078 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 582078 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 582078 | return $adopt->(ref($self), _copy_board($self->_ptr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 703559 | ▶ | sub at { _at($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 645891 | ▶ | sub put { _put($_[0]->_ptr, $_[1], $_[2]); return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 6 | ▶ | sub lift { _lift($_[0]->_ptr, $_[1]); return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lift: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3408057 | ▶ | sub side { _side($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
side: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 355895 | ▶ | sub set_side { _set_side($_[0]->_ptr, $_[1]); return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_side: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 661 | ▶ | sub pieces { _pieces($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pieces: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 403522 | ▶ | sub count { _count($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 15573 | ▶ | sub home { _home($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
home: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | sub consistent { _consistent($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consistent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 879579 | ▶ | sub ply { _ply($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ply: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2007 | ▶ | sub set_ply { _set_ply($_[0]->_ptr, $_[1]); return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_ply: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 116448 | ▶ | sub to_string { _to_string($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 119370 | ▶ | sub key_hex { _key_hex($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 36 | ▶ | sub house_of { my $c = shift; _house_of($_[0], $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
house_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 35 | ▶ | sub row_of { my $c = shift; _row_of($_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 39 | ▶ | sub col_of { my $c = shift; _col_of($_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 34 | ▶ | sub is_marked { my $c = shift; _is_marked($_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_marked: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | sub all_houses { 1 .. HOUSES } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_houses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub marked_houses { grep { _is_marked($_) } 1 .. HOUSES } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
marked_houses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 80 | my (@PROTECT_NAME, @REACH_NAME, %EXIT_WORD); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 80 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 80 | @PROTECT_NAME = ('none', 'run', 'ends'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 80 | @REACH_NAME = ('exact', 'any'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 80 | %EXIT_WORD = (31 => 'off', 32 => 'walk', 33 => 'stay'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 85998 | ▶ | my $as_hash = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 85998 | my ($pieces, $blockade, $protect, $backward, $reach26, $throw_on_26, $safe, @chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 85998 | my %exits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 85998 | for my $h (0 .. 4) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 429990 | for my $roll (1 .. ROLL_MAX) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2149950 | my @entries = splice @chain, 0, CHAIN_MAX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | $exits{ 26 + $h }{$roll} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2149950 | ▶ | map { $EXIT_WORD{$_} // $_ } grep { $_ != X_END } @entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$EXIT_WORD{$_} // $_
MC/DC0%0/2
$EXIT_WORD{$_} // $_
$EXIT_WORD{$_}
$_
Truth table66%2/3
A // B
A= $EXIT_WORD{$_}B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | pieces => $pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | blockade => $blockade, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | protect => $PROTECT_NAME[$protect], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | backward => $backward, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | reach26 => $REACH_NAME[$reach26], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | throw_on_26 => $throw_on_26, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 85998 | safe => [ grep { $safe & (1 << $_) } 1 .. HOUSES ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | exits => \%exits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 86007 | ▶ | sub rules { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rules: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 86007 | my ($class, $rules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 86007 | return $as_hash->(_rules($rules)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | ▶ | sub rules_named { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rules_named: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | my ($class, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | my @flat = _rules_named($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | ▶ | return undef unless @flat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | return $as_hash->(@flat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | sub rules_id { my $c = shift; _rules_id($_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rules_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11892 | ▶ | sub chances { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chances: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 11892 | return map { [ _chance($_) ] } 0 .. _chance_count() - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | ▶ | sub extra { my $c = shift; _extra($_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extra: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 80 | my @SIDE_NAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 80 | ▶ | BEGIN { @SIDE_NAME = ('light', 'dark') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1227707 | ▶ | sub moves { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
moves: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1227707 | my ($self, $roll, $rules, $only) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1227707 | ▶ | Carp::croak('Game::Senet::Engine: a roll is a whole number of houses from 1 to 5') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $roll and $roll =~ /\A[1-5]\z/
MC/DC50%1/2
defined $roll and $roll =~ /\A[1-5]\z/
defined $roll
$roll =~ /\A[1-5]\z/
Truth table66%2/3
A and B
A= defined $rollB= $roll =~ /\A[1-5]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | unless defined $roll && $roll =~ /\A[1-5]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1227701 | ▶ | $only //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$only //= 0
MC/DC100%1/1
$only //= 0
$only
Truth table100%2/2
A
A= $only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1227701 | ▶ | Carp::croak('Game::Senet::Engine: only is a house, 1 to 30, or 0 for any') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$only =~ /\A\d{1,2}\z/ and $only <= 30
MC/DC50%1/2
$only =~ /\A\d{1,2}\z/ and $only <= 30
$only =~ /\A\d{1,2}\z/
$only <= 30
Truth table66%2/3
A and B
A= $only =~ /\A\d{1,2}\z/B= $only <= 30
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | unless $only =~ /\A\d{1,2}\z/ && $only <= HOUSES; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1227700 | my $side = $SIDE_NAME[ _side($self->_ptr) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | my @moves = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1227700 | my ($from, $to, $r, $swap, $back, $off, $walk) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2461496 | ▶ | Game::Senet::Move->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | side => $side, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | roll => $r, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | from => $from, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | to => ($off ? 'off' : $to), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | swap => $swap, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | back => $back, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | off => $off, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | walk => $walk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } _moves($self->_ptr, $roll, $rules, $only); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1227700 | ▶ | return wantarray ? @moves : scalar @moves; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 943206 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 943206 | my ($self, $move, $rules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 943206 | ▶ | Carp::croak('Game::Senet::Engine: apply takes a move') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($move) and $move->isa("Game::Senet::Move")
MC/DC0%0/2
builtin::blessed($move) and $move->isa("Game::Senet::Move")
builtin::blessed($move)
$move->isa("Game::Senet::Move")
Truth table33%1/3
A and B
A= builtin::blessed($move)B= $move->isa("Game::Senet::Move")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | unless Scalar::Util::blessed($move) && $move->isa('Game::Senet::Move'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 943206 | ▶ | my ($undo, $bound) = _apply($self->_ptr, $rules, $move->from, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | ($move->off ? -1 : $move->to), $move->roll, $move->off); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 943206 | ▶ | return wantarray ? ($undo, $bound) : $undo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 235686 | ▶ | sub forfeit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forfeit: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 235686 | my ($self, $roll) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 235686 | ▶ | Carp::croak('Game::Senet::Engine: a roll is a whole number of houses from 1 to 5') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $roll and $roll =~ /\A[1-5]\z/
MC/DC50%1/2
defined $roll and $roll =~ /\A[1-5]\z/
defined $roll
$roll =~ /\A[1-5]\z/
Truth table66%2/3
A and B
A= defined $rollB= $roll =~ /\A[1-5]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | unless defined $roll && $roll =~ /\A[1-5]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 235685 | return _forfeit($self->_ptr, $roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 71519 | ▶ | sub unapply { _unapply($_[0]->_ptr, $_[1]); return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unapply: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 7382630 | ▶ | sub status { _status($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1413 | ▶ | sub how { _how($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
how: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 62704 | ▶ | sub winner { _winner($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
winner: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | ▶ | sub ply_cap { _ply_cap() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ply_cap: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 40 | ▶ | sub walk { _walk($_[0]->_ptr, $_[1], $_[2]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
walk: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 84134 | ▶ | my $check_roll = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 84134 | ▶ | Carp::croak('Game::Senet::Engine: a roll is a whole number of houses from 1 to 5') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] =~ /\A[1-5]\z/
MC/DC0%0/2
defined $_[0] and $_[0] =~ /\A[1-5]\z/
defined $_[0]
$_[0] =~ /\A[1-5]\z/
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] =~ /\A[1-5]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | unless defined $_[0] && $_[0] =~ /\A[1-5]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 55806 | ▶ | my $check_options = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 55806 | my ($what, $option, @allowed) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 55806 | my %ok = map { $_ => 1 } @allowed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 55806 | for my $key (sort keys %$option) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 263584 | ▶ | Carp::croak("Game::Senet::Engine: $what has no option called '$key'") unless $ok{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 56188 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 56188 | my ($self, $side, $rules, $weights) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 56188 | ▶ | Carp::croak('Game::Senet::Engine: evaluate asks for a side') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $side and $side =~ /\A[01]\z/
MC/DC0%0/2
defined $side and $side =~ /\A[01]\z/
defined $side
$side =~ /\A[01]\z/
Truth table33%1/3
A and B
A= defined $sideB= $side =~ /\A[01]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | unless defined $side && $side =~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 56188 | return _evaluate($self->_ptr, $rules, $weights, $side); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 6627 | ▶ | my $check_house = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 6627 | my ($house) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 6627 | ▶ | Carp::croak('Game::Senet::Engine: a house is a whole number from 1 to 30') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $house and $house =~ /\A[0-9]{1,2}\z/ and $house >= 1 and $house <= 30
defined $house and $house =~ /\A[0-9]{1,2}\z/ and $house >= 1
defined $house and $house =~ /\A[0-9]{1,2}\z/
MC/DC100%4/4
defined $house and $house =~ /\A[0-9]{1,2}\z/ and $house >= 1 and $house <= 30
defined $house
$house =~ /\A[0-9]{1,2}\z/
$house >= 1
$house <= 30
Truth table100%5/5
A and B and C and D
A= defined $houseB= $house =~ /\A[0-9]{1,2}\z/C= $house >= 1D= $house <= 30
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | unless defined $house && $house =~ /\A[0-9]{1,2}\z/ && $house >= 1 && $house <= HOUSES; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 80 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2360 | ▶ | sub protected { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protected: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2360 | my ($self, $house, $rules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2360 | $check_house->($house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2355 | return _protected($self->_ptr, $rules, $house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 4267 | ▶ | sub in_blockade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
in_blockade: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 4267 | my ($self, $house, $rules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 4267 | $check_house->($house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 4262 | return _in_blockade($self->_ptr, $rules, $house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 30734 | ▶ | sub greedy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
greedy: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 30734 | my ($self, $roll, $rules, $only) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 30734 | $check_roll->($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 30734 | ▶ | return _greedy($self->_ptr, $roll, $rules, $only // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$only // 0
MC/DC100%1/1
$only // 0
$only
Truth table100%2/2
A
A= $only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 53400 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 53400 | my ($self, $roll, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 53400 | $check_roll->($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 53400 | $check_options->('search', \%option, qw(rules weights budget depth only)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 53399 | ▶ | my $budget = defined $option{budget} ? $option{budget} : 2_000_000_000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 53399 | ▶ | my $depth = defined $option{depth} ? $option{depth} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 53399 | ▶ | Carp::croak('Game::Senet::Engine: a budget is a whole number of nodes from 0 to 2000000000') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$budget =~ /\A\d{1,10}\z/ and $budget <= 2000000000
MC/DC100%2/2
$budget =~ /\A\d{1,10}\z/ and $budget <= 2000000000
$budget =~ /\A\d{1,10}\z/
$budget <= 2000000000
Truth table100%3/3
A and B
A= $budget =~ /\A\d{1,10}\z/B= $budget <= 2000000000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | unless $budget =~ /\A\d{1,10}\z/ && $budget <= 2_000_000_000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 53397 | ▶ | Carp::croak('Game::Senet::Engine: a depth is a whole number from 0 to 32') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$depth =~ /\A\d{1,2}\z/ and $depth <= 32
MC/DC50%1/2
$depth =~ /\A\d{1,2}\z/ and $depth <= 32
$depth =~ /\A\d{1,2}\z/
$depth <= 32
Truth table66%2/3
A and B
A= $depth =~ /\A\d{1,2}\z/B= $depth <= 32
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | unless $depth =~ /\A\d{1,2}\z/ && $depth <= DEPTH_MAX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | my ($index, $nodes, $reached, $value, $stopped) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 53396 | ▶ | _search($self->_ptr, $roll, $option{rules}, $option{weights}, $budget, $depth, $option{only} // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$option{"only"} // 0
MC/DC100%1/1
$option{"only"} // 0
$option{"only"}
Truth table100%2/2
A
A= $option{"only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 53396 | return { index => $index, nodes => $nodes, depth => $reached, value => $value, stopped => $stopped }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2406 | ▶ | sub expect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expect: called CC=6 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2406 | my ($self, $depth, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2406 | $check_options->('expect', \%option, qw(rules weights only side)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2406 | ▶ | Carp::croak('Game::Senet::Engine: a depth is a whole number from 0 to 32') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $depth and $depth =~ /\A\d{1,2}\z/ and $depth <= 32
defined $depth and $depth =~ /\A\d{1,2}\z/
MC/DC0%0/3
defined $depth and $depth =~ /\A\d{1,2}\z/ and $depth <= 32
defined $depth
$depth =~ /\A\d{1,2}\z/
$depth <= 32
Truth table25%1/4
A and B and C
A= defined $depthB= $depth =~ /\A\d{1,2}\z/C= $depth <= 32
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | unless defined $depth && $depth =~ /\A\d{1,2}\z/ && $depth <= DEPTH_MAX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2406 | ▶ | my $side = defined $option{side} ? $option{side} : _side($self->_ptr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2406 | ▶ | return _expect($self->_ptr, $option{rules}, $option{weights}, $option{only} // 0, $depth, $side); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$option{"only"} // 0
MC/DC100%1/1
$option{"only"} // 0
$option{"only"}
Truth table100%2/2
A
A= $option{"only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | ▶ | sub abi_version { _abi_version() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abi_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 5 | ▶ | sub live { _live() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
live: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 80 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||