Algorithm-MasterMind

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


	* t/00_functions.t: Fixed typo in test

2009-10-02    <jmerelo@localhost.localdomain>

	* Makefile.PL: Added Algorithm::Combinatorics which is used to
	compute next combination in the Sequential algorithm

2009-10-02  Juan J. Merelo  <jmerelo@vega>

	* lib/Algorithm/MasterMind.pm (not_in_combination): Starting 0.0.4
	with adding info to the main module file.

	* MANIFEST: Fixing a distribution but in 0.0.2 and also adding new
	methods. Fixed bugs in Sequential, and added program to run
	experiments. 

2009-10-01  Juan Julian Merelo Guervos  <jmerelo@geneura.ugr.es>

	* MANIFEST: Started version 0.0.3 after fixing docs form version
	one. Still waiting for fail reports.

2009-09-30    <jmerelo@localhost.localdomain>

	* lib/Algorithm/MasterMind.pm (not_in_combination): Changing all
	documentation to avoid problems, and added a few things.

	* MANIFEST: Added set of files to the MANIFEST, and preparing
	stuff for initial release 

Revision history for Algorithm-MasterMind

0.0.1  Sun Sep  6 13:54:21 2009
       Initial release.

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

	   whites => $whites };
}

sub hashify {
  my $str = shift;
  my %hash;
  map( $hash{$_}++, split(//, $str));
  return %hash;
}

sub not_in_combination {
  my $self = shift;
  my $combination = shift;
  my @alphabet = @{$self->{'_alphabet'}};
  my %alphabet_hash;
  map( $alphabet_hash{$_}=1, @alphabet );
  for my $l ( split(//, $combination ) ) {
    delete $alphabet_hash{$l} if  $alphabet_hash{$l};
  }
  return keys %alphabet_hash;
}

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


Returns a hash with the number of matches, and whether it matches
every rule with the number of blacks and whites it obtains with each
of them

=head2 hashify ( $string )

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



( run in 0.552 second using v1.01-cache-2.11-cpan-cc502c75498 )