Algorithm-MasterMind
view release on metacpan or search on metacpan
lib/Algorithm/MasterMind/Consistent_Set.pm view on Meta::CPAN
$top_score = $this_score;
}
}
for my $s ( @keys ) {
if ( $self->{'_score'}{$score}->{ $s } == $top_score ) {
push @top_scorers, $s;
}
}
} else { # either 0 or 1
@top_scorers = @keys;
}
return @top_scorers;
}
sub consistent_strings {
return keys %{shift->{'_partitions'}};
}
"As Jack the Ripper said..."; # Magic true value required at end of module
__END__
=head1 NAME
Algorithm::MasterMind::Consistent_Set - Class for handling the set of consistent combinations
=head1 SYNOPSIS
use Algorithm::MasterMind::Consistent_Set;
=head1 DESCRIPTION
The consistent set in Mastermind contains the set of strings that
could possibly be a solution, that is, those that meet all partitions
made so far.
=head1 INTERFACE
=head2 new( @string_array )
Creates set and associated data structures
=head2 compute_partitions ( \@secrets )
Computes partitions for an array of secrets, returns a hashref to the
partition set.
=head2 is_in ( $string )
Checks whether the combination is in the consistent set already
=head2 add_combination ( $string )
Adds another combination checking it against previous combinations
=head2 result_to_string ( $result )
Converts result hash into string in a more or less standard way, to
avoid conversion errors
=head2 partitions_for ( $string )
Returns the partition hash for combination $string
=head2 cull_inconsistent_with ( $string, $result )
After a move, eliminates inconsistent elements, recomputing the partitions.
=head2 compute_entropy_score
Computes the entropy score of existent partitions
=head2 compute_most_score
Computes the Most Parts score of existent partitions, that is, the number of non-zero parts
=head2 consistent_strings
Returns the consistent set
=head2 create_consistent_with( $combinations, $rules )
Creates a consistent eliminating from the set of combinations those
not consistent with the rules
=head2 result_as_string
Returns the response as a fixed format string, for comparisons
=head2 score_entropy ($string)
Returns the Entropy score of the C<$string>, if it's in the consistent
set.
=head2 score_most ($string)
Returns the Most Parts score of the C<$string>, if it's in the consistent
set.
=head2 top_scorers ( $mode )
Returns the set of top scorers for a particular mode. Now $mode can be
"most" or "entropy"
=head1 AUTHOR
JJ Merelo C<< <jj@merelo.net> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2009-2012 JJ Merelo C<< <jj@merelo.net> >>. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
=head1 DISCLAIMER OF WARRANTY
( run in 1.493 second using v1.01-cache-2.11-cpan-adec679a428 )