Ninja/Metropolis.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 27 CC 2 SCAR 12.8
CC
2
Cov
0%
do
6.0
new
2.0
setLower
2.0
CRAP 3.6
1 ### A subclass for using an Attacking/DefendingFunctor with a
2 ### Metropolis-Hastings algorithm.
3  
4 sub new {
5 my ($class) = @_;
6  
7 $self = { lowerbound => 0.25, upperbound => 0.4 };
8  
9 bless $self, $class;
10 };
11  
12 sub setLower {
13 my ($self, $lb) = @_;
14  
15 $self->{lowerbound} = $lb;
16 }
17  
18 sub setUpper {
19 my ($self, $ub) = @_;
20  
21 $self->{upperbound} = $ub;
22 }
23  
24 sub do {
25 my ($self, $entity1, $entity2) = @_;
26  
27 if (my $random = 1 / rand >= $self->{lowerbound} or $random <= $self->{upperbound}) {
28  
29 return 1;
30 } else {
31 return 0;
32 }
33
34 };
35 1;