line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::MasterMind::Random; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
701
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use lib qw(../../lib); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/g; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
129
|
use base 'Algorithm::MasterMind'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
316
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub initialize { |
14
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
15
|
1
|
|
|
|
|
3
|
my $options = shift; |
16
|
1
|
|
|
|
|
4
|
for my $o ( keys %$options ) { |
17
|
2
|
|
|
|
|
12
|
$self->{"_$o"} = $options->{$o}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub issue_next { |
22
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
23
|
3
|
|
|
|
|
8
|
my $rules = $self->number_of_rules(); |
24
|
3
|
|
|
|
|
5
|
my ($match, $string); |
25
|
3
|
|
|
|
|
4
|
my @alphabet = @{$self->{'_alphabet'}}; |
|
3
|
|
|
|
|
11
|
|
26
|
3
|
|
|
|
|
6
|
my $length = $self->{'_length'}; |
27
|
3
|
|
|
|
|
4
|
do { |
28
|
537
|
|
|
|
|
573
|
$string =''; |
29
|
537
|
|
|
|
|
942
|
for ( my $i = 0; $i < $length; $i++ ) { |
30
|
2148
|
|
|
|
|
4414
|
$string .= $alphabet[rand(@alphabet)]; |
31
|
|
|
|
|
|
|
} |
32
|
537
|
|
|
|
|
1151
|
$match = $self->matches($string); |
33
|
537
|
|
|
|
|
1757
|
$self->{'_evaluated'}++; |
34
|
|
|
|
|
|
|
} while ( $match->{'matches'} < $rules ); |
35
|
3
|
|
|
|
|
23
|
return $self->{'_last'} = $string; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
"some blacks, 0 white"; # Magic true value required at end of module |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |