Algorithm-MasterMind

 view release on metacpan or  search on metacpan

lib/Algorithm/MasterMind.pm  view on Meta::CPAN

410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
mastermind. Proposed by Knuth in one of his original papers.
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind.pm  view on Meta::CPAN

445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
Turns a string into a hash, to help with comparisons. Used internally,
mainly.
 
=head2 not_in_combination( $string)
 
Returns the letters from the alphabet that are _not_ in this
combination. Might be useful for certain strategies.
 
=head2 random_combination
 
Combines randomly the alphabet, issuing, you guessed it, a random
combination.
 
=head2 partitions
 
From a set of combinations, returns the "partitions", that is, the
number of combinations that would return every set of black and white
response. Inputs an array, returns a hash keyed to the combination,
each key containing a value corresponding to the number of elements in
each partition.

lib/Algorithm/MasterMind/CGA_Partitions.pm  view on Meta::CPAN

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
This function, and all the rest, are directly inherited from base
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind/EDA.pm  view on Meta::CPAN

168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Yields the first combination
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind/EDA_Partitions.pm  view on Meta::CPAN

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
This function, and all the rest, are directly inherited from base
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind/Evo.pm  view on Meta::CPAN

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
my $rules $self->number_of_rules();
my $ga = $self->{'_ga'};
my $max_number_of_consistent  = $self->{'_max_consistent'};
 
my $last_rule = $rules[$#rules];
my $alphabet_size = @{$self->{'_alphabet'}};
 
if ( $self->{'_played_out'} ) {
  $self->eliminate_last_played;
}
#Check for combination guessed right except for permutation
if ($last_rule->{'blacks'}+$last_rule->{'whites'} == $length ) {
  if ( ! $self->{'_consistent_endgame'} ) {
    my %permutations;
    map( $permutations{$_} = 1,
         map(join("",@$_),
             permutations([ split( //, $last_rule->{'combination'} ) ] ) ) );
    my @permutations = keys %permutations;
    $self->{'_endgame'}  =
      Algorithm::MasterMind::Partition::Most->start_from( { evaluated => $self->{'_evaluated'},
                                                            alphabet => \@alphabet,

lib/Algorithm/MasterMind/MOGA.pm  view on Meta::CPAN

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
way
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind/Random.pm  view on Meta::CPAN

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
way
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()

lib/Algorithm/MasterMind/Sequential.pm  view on Meta::CPAN

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
way
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()
 
Returns the rules (combinations, blacks, whites played so far) y a
reference to array

lib/Algorithm/MasterMind/Sequential_Alt.pm  view on Meta::CPAN

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
way
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()
 
Returns the rules (combinations, blacks, whites played so far) y a
reference to array

lib/Algorithm/MasterMind/Test.pm  view on Meta::CPAN

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
way
 
=head2 issue_next()
 
Issues the next combination
 
=head2 feedback()
 
Obtain the result to the last combination played
 
=head2 guesses()
 
Total number of guesses
 
=head2 evaluated()
 
Total number of combinations checked to issue result
 
=head2 number_of_rules ()
 
Returns the number of rules in the algorithm
 
=head2 rules()



( run in 0.350 second using v1.01-cache-2.11-cpan-95122f20152 )