line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::MasterMind::Partition_Most; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
956
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use lib qw(../../lib ../../../lib); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/g; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
241
|
use base 'Algorithm::MasterMind'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
12
|
1
|
|
|
1
|
|
526
|
use Algorithm::MasterMind::Consistent_Set; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
448
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub initialize { |
15
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
16
|
1
|
|
|
|
|
2
|
my $options = shift; |
17
|
1
|
|
|
|
|
4
|
for my $o ( keys %$options ) { |
18
|
2
|
|
|
|
|
14
|
$self->{"_$o"} = $options->{$o}; |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
|
|
4
|
$self->{'_partitions'} = {}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub issue_first { |
24
|
1
|
|
|
1
|
1
|
958
|
my $self = shift; |
25
|
1
|
|
|
|
|
12
|
my @combinations = $self->all_combinations(); |
26
|
1
|
|
|
|
|
84
|
$self->{'_evaluated'} = scalar( @combinations ); |
27
|
1
|
|
|
|
|
13
|
$self->{'_partitions'} = new Algorithm::MasterMind::Consistent_Set \@combinations; |
28
|
1
|
|
|
|
|
13
|
my $partitions = $self->{'_partitions'}; |
29
|
1
|
|
|
|
|
23
|
$partitions->compute_most_score; |
30
|
1
|
|
|
|
|
25582
|
my @top_scorers = $partitions->top_scorers( 'most' ); |
31
|
1
|
|
|
|
|
12263
|
return $self->{'_last'} = $top_scorers[ rand(@top_scorers)]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub issue_next { |
35
|
4
|
|
|
4
|
1
|
4615
|
my $self = shift; |
36
|
4
|
|
|
|
|
1629
|
my $last_rule = $self->{'_rules'}->[scalar(@{$self->{'_rules'}})-1]; |
|
4
|
|
|
|
|
15
|
|
37
|
4
|
|
|
|
|
864
|
$self->{'_partitions'}->cull_inconsistent_with( $last_rule->{'combination'}, $last_rule ); |
38
|
4
|
100
|
|
|
|
562
|
if ( @{$self->{'_partitions'}->{'_combinations'}} > 1 ) { |
|
4
|
|
|
|
|
28
|
|
39
|
3
|
|
|
|
|
24
|
$self->{'_partitions'}->compute_most_score; |
40
|
3
|
|
|
|
|
83
|
my @top_scorers = $self->{'_partitions'}->top_scorers('most'); |
41
|
3
|
|
|
|
|
6203
|
return $self->{'_last'} = $top_scorers[ rand(@top_scorers)]; |
42
|
|
|
|
|
|
|
} else { |
43
|
1
|
|
|
|
|
639
|
return $self->{'_last'} = $self->{'_partitions'}->{'_combinations'}->[0]->string; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
"some blacks, 0 white"; # Magic true value required at end of module |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |