Algorithm-MasterMind

 view release on metacpan or  search on metacpan

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

=head1 DESCRIPTION

Uses L<Algorithm::Evolutionary> instance of canonical genetic algorithm to solve MM; as there
are two different fitness functions you can use; probably
C<fitness_orig> works better. 

=head1 INTERFACE 

=head2 initialize 

Performs bookkeeping, and assigns flags depending on the
initialization values

=head2 new ( $options )

This function, and all the rest, are directly inherited from base

=head2 issue_next()

Issues the next combination

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

=head1 DESCRIPTION

Uses L<Algorithm::Evolutionary> instance of EDAs to solve MM; as there
are two different fitness functions you can use; probably
C<fitness_orig> works better. 

=head1 INTERFACE 

=head2 initialize 

Performs bookkeeping, and assigns flags depending on the
initialization values

=head2 new ( $options )

This function, and all the rest, are directly inherited from base

=head2 issue_first()

Yields the first combination 

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

=head1 DESCRIPTION

Uses L<Algorithm::Evolutionary> instance of EDAs to solve MM; as there
are two different fitness functions you can use; probably
C<fitness_orig> works better. 

=head1 INTERFACE 

=head2 initialize 

Performs bookkeeping, and assigns flags depending on the
initialization values

=head2 new ( $options )

This function, and all the rest, are directly inherited from base

=head2 issue_next()

Issues the next combination

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

    $fitness += abs( $rules[$r]->{'blacks'} - $matches->{'result'}->[$r]->{'blacks'} ) +
      abs( $rules[$r]->{'whites'} - $matches->{'result'}->[$r]->{'whites'} );
  }
  return 1/$fitness;
}

sub issue_first {
  my $self = shift;
  #Initialize population for next step
  $self->reset();
  $self->{'_first'} = 1; # flag for first
  return $self->{'_last'} = $self->issue_first_Knuth();
}

sub reset {
  my $self=shift;
  my %pop;
  if (  scalar( (@{$self->{'_alphabet'}})** $self->{'_length'} ) < $self->{'_pop_size'} ) {
      croak( "Can't do, population bigger than space" );
  }
  while ( scalar ( keys %pop ) < $self->{'_pop_size'} ) {

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

=head1 DESCRIPTION

Uses L<Algorithm::Evolutionary> instance of MOGAs to solve MM; as there
are two different fitness functions you can use; probably
C<fitness_orig> works better. 

=head1 INTERFACE 

=head2 initialize 

Performs bookkeeping, and assigns flags depending on the
initialization values

=head2 entropy( $combination)

Computes the Jensen-Shannon entropy of the string and returns it.

=head2 fitness_compress( $object ) 

Uses as fitness the entropy of the string attached to all the strings
already played computed above. 



( run in 1.512 second using v1.01-cache-2.11-cpan-94b05bcf43c )