| 1 | package Game::Brandubh::Rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 50 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 50 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 50 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 50 | ▶ | use Object::Proto::Sugar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 50 | ▶ | use Game::Brandubh::Engine (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 50 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 50 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 50 | ONGOING => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | BY_CORNER => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | BY_CAPTURE => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | BY_NO_PIECES => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | DRAW_REPETITION => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | DRAW_NO_MOVE => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | DRAW_PLY_CAP => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 50 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 50 | PLAY_OK => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | PLAY_OVER => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | PLAY_ILLEGAL => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 50 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ONGOING BY_CORNER BY_CAPTURE BY_NO_PIECES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | DRAW_REPETITION DRAW_NO_MOVE DRAW_PLY_CAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | PLAY_OK PLAY_OVER PLAY_ILLEGAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | outcome_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 50 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 50 | my @NAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 50 | ▶ | BEGIN { @NAME = qw(ongoing corner capture no_pieces repetition no_move ply_cap) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4692 | ▶ | sub outcome_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
outcome_name: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4692 | my ($outcome) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4692 | ▶ | return undef unless defined $outcome && $outcome =~ /\A[0-9]+\z/ && $outcome < @NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $outcome and $outcome =~ /\A[0-9]+\z/ and $outcome < @NAME
defined $outcome and $outcome =~ /\A[0-9]+\z/
MC/DC100%3/3
defined $outcome and $outcome =~ /\A[0-9]+\z/ and $outcome < @NAME
defined $outcome
$outcome =~ /\A[0-9]+\z/
$outcome < @NAME
Truth table100%4/4
A and B and C
A= defined $outcomeB= $outcome =~ /\A[0-9]+\z/C= $outcome < @NAME
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4689 | return $NAME[$outcome]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 50 | has _ptr => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 50 | has _start => (is => 'ro', init_arg => 'position', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 50 | has _rules => (is => 'ro', init_arg => 'variant', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 50 | my %ADOPTING; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 8923 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8923 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 8923 | my $given = $self->_ptr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 8923 | ▶ | if ($given) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | return if delete $ADOPTING{$given}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | $self->_ptr(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | Carp::croak("Game::Brandubh::Rules: a game is made by new or clone"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 8919 | my ($ptr, $err) = _new_game($self->_start, $self->_rules); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8918 | ▶ | Carp::croak("Game::Brandubh::Rules: the position was refused, code $err") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | unless defined $ptr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8917 | $self->_ptr($ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8917 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | my $adopt = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | my ($class, $ptr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | $ADOPTING{$ptr} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | return $class->new(_ptr => $ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | return $adopt->(ref($self), _copy_game($self->_ptr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 8920 | ▶ | sub DEMOLISH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 8920 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 8920 | my $ptr = $self->_ptr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 8920 | ▶ | return unless $ptr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8920 | _drop_game($ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8920 | $self->_ptr(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8920 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 21211 | ▶ | sub position { _position($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
position: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 7842 | ▶ | sub key_hex { _key_hex($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 14 | ▶ | sub key_at { _key_at_hex($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8779 | ▶ | sub side { _side($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
side: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2319061 | ▶ | sub at { _at($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 31241 | ▶ | sub count { _count($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 28111 | ▶ | sub ply { _ply($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ply: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | ▶ | sub ply_cap { _cap($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ply_cap: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | ▶ | sub variant { _variant($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variant: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | sub board { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
board: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | return Game::Brandubh::Engine->new(position => _position($self->_ptr)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4755 | ▶ | sub outcome { _outcome($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
outcome: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 383552 | ▶ | sub is_over { _outcome($_[0]->_ptr) != ONGOING } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_over: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 9 | ▶ | sub is_draw { _outcome($_[0]->_ptr) >= DRAW_REPETITION } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_draw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 6074 | ▶ | sub repeats { _repeats($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repeats: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4188 | ▶ | sub winner { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
winner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4188 | my $side = _winner($_[0]->_ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4188 | ▶ | return $side < 0 ? undef : $side; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 7 | ▶ | sub winner_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
winner_of: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | my $side = _winner_of($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | ▶ | return $side < 0 ? undef : $side; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 100965 | ▶ | sub moves { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
moves: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 100965 | my @m = _moves($_[0]->_ptr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 100965 | ▶ | return wantarray ? @m : scalar @m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 249052 | ▶ | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 249052 | my ($answer, $flags) = _play($_[0]->_ptr, $_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 249052 | ▶ | return wantarray ? ($answer, $flags) : $answer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 23641 | ▶ | sub undo { _undo($_[0]->_ptr) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1616571 | ▶ | sub preview { _preview($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 179634 | ▶ | sub why_not { _why_not($_[0]->_ptr, $_[1], $_[2]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
why_not: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | ▶ | sub live { _games_live() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
live: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 8186 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 8186 | my ($self, %with) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 8186 | my $budget = $with{budget}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 8186 | ▶ | Carp::croak('Game::Brandubh::Rules: search needs a budget, a whole number of nodes from 1 up') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
defined $budget and not ref $budget and $budget =~ /\A[0-9]{1,9}\z/ and $budget >= 1
defined $budget and not ref $budget and $budget =~ /\A[0-9]{1,9}\z/
defined $budget and not ref $budget
MC/DC75%3/4
defined $budget and not ref $budget and $budget =~ /\A[0-9]{1,9}\z/ and $budget >= 1
defined $budget
not ref $budget
$budget =~ /\A[0-9]{1,9}\z/
$budget >= 1
Truth table80%4/5
A and not(B) and C and D
A= defined $budgetB= not ref $budgetC= $budget =~ /\A[0-9]{1,9}\z/D= $budget >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | unless defined $budget && !ref $budget && $budget =~ /\A[0-9]{1,9}\z/ && $budget >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 8181 | ▶ | my $seed = defined $with{seed} ? $with{seed} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 8181 | ▶ | Carp::croak('Game::Brandubh::Rules: a search seed is a whole number below 4294967296') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not ref $seed and $seed =~ /\A[0-9]{1,10}\z/ and $seed < 4294967296
not ref $seed and $seed =~ /\A[0-9]{1,10}\z/
MC/DC66%2/3
not ref $seed and $seed =~ /\A[0-9]{1,10}\z/ and $seed < 4294967296
not ref $seed
$seed =~ /\A[0-9]{1,10}\z/
$seed < 4294967296
Truth table75%3/4
not(A) and B and C
A= not ref $seedB= $seed =~ /\A[0-9]{1,10}\z/C= $seed < 4294967296
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | unless !ref $seed && $seed =~ /\A[0-9]{1,10}\z/ && $seed < 4294967296; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 8179 | ▶ | my $depth = defined $with{depth} ? $with{depth} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 8179 | ▶ | Carp::croak('Game::Brandubh::Rules: a search depth is a whole number') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $depth and $depth =~ /\A[0-9]{1,3}\z/
MC/DC50%1/2
not ref $depth and $depth =~ /\A[0-9]{1,3}\z/
not ref $depth
$depth =~ /\A[0-9]{1,3}\z/
Truth table66%2/3
not(A) and B
A= not ref $depthB= $depth =~ /\A[0-9]{1,3}\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | unless !ref $depth && $depth =~ /\A[0-9]{1,3}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 8178 | my ($mv, $nodes, $reached, $score, $stopped) = _search($self->_ptr, $budget, $seed, $depth, $with{weights}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 8176 | ▶ | return undef unless $mv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 8174 | return { move => $mv, nodes => $nodes, depth => $reached, score => $score, stopped => $stopped }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4517 | ▶ | sub evaluate { _evaluate($_[0]->_ptr, $_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | sub weights { _weights() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
weights: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||