Algorithm-MasterMind

 view release on metacpan or  search on metacpan

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


=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.

=head2 all_combinations

Returns all possible combinations of the current alphabet and length
in an array. Be careful with that, it could very easily fill up your
memory, depending on length and alphabet size.

=head2 entropy( $string )

Computes the string entropy

=head2 distance_taxicab( $string )

Computes the sums of taxicab distances to all combinations in the
game, and returns it as [$distance, $matches]

=head2 distance_chebyshev( $string )

Computes the Chebyshev distance, that is, the max of distances in all
dimensions. Returns as a arrayref with [$distance, matches]

=head2 all_responses()

Returns all possible responses (combination of black and white pegs)
for the combination length

=head2 random_string

Returns a random string in with the length and alphabet defined

=head2 response_as_string ( $response )

From a hash that uses keys C<blacks> and C<whites>, returns a string
"xb-yw" in a standard format that can be used for comparing.

=head1 CONFIGURATION AND ENVIRONMENT

Algorithm::MasterMind requires no configuration files or environment variables.


=head1 DEPENDENCIES

L<Algorithm::Evolutionary>, but only for one of the
strategies. L<Algorithm::Combinatorics>, used to generate combinations
and for exhaustive search strategies. 


=head1 INCOMPATIBILITIES

None reported.


=head1 BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to
C<bug-algorithm-mastermind@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.

=head1 SEE ALSO

Other modules in CPAN which you might find more useful than this one
are at L<Games::Mastermind::Solver>, which I didn't use and extend for
no reason, although I should have. Also L<Games::Mastermind::Cracker>. 

Formerly, you could try and play this game at
http://geneura.ugr.es/~jmerelo/GenMM/mm-eda.cgi, restricted to 4 pegs
and 6 colors. It's, for the time being, under reparations. The program C<mm-eda.cgi> should also be available in 
the C<apps> directory of this distribution.

The development of this projects is hosted at sourceforge,
https://sourceforge.net/projects/opeal/develop, check it out for the
latest bleeding edge release. In fact, right now this module is at
least a year away from the latest development. 

If you use any of these modules for your own research, we would very
grateful if you would reference the papers that describe this, such as
this one:

 @article{merelo2010finding,
  title={{Finding Better Solutions to the Mastermind Puzzle Using Evolutionary Algorithms}},
  author={Merelo-Guerv{\'o}s, J. and Runarsson, T.},
  journal={Applications of Evolutionary Computation},
  pages={121--130},
  year={2010},
  publisher={Springer}
 }

or


 @inproceedings{DBLP:conf/cec/GuervosMC11,
  author    = {Juan-J. Merelo-Guerv{\'o}s and
               Antonio-Miguel Mora and
               Carlos Cotta},
  title     = {Optimizing worst-case scenario in evolutionary solutions
               to the {MasterMind} puzzle},
  booktitle = {IEEE Congress on Evolutionary Computation},
  year      = {2011},
  pages     = {2669-2676},
  ee        = {http://dx.doi.org/10.1109/CEC.2011.5949952},
  crossref  = {DBLP:conf/cec/2011},
  bibsource = {DBLP, http://dblp.uni-trier.de}
 }

 @proceedings{DBLP:conf/cec/2011,
  title     = {Proceedings of the IEEE Congress on Evolutionary Computation,
               CEC 2011, New Orleans, LA, USA, 5-8 June, 2011},
  booktitle = {IEEE Congress on Evolutionary Computation},
  publisher = {IEEE},
  year      = {2011},
  isbn      = {978-1-4244-7834-7},



( run in 1.435 second using v1.01-cache-2.11-cpan-524268b4103 )