Algorithm-MasterMind

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 85.4   10.31 10.310 500146   0.0000 0.0000  Algorithm::MasterMind::check_combi
                                             nation
 9.71   1.172 12.806    367   0.0032 0.0349  Algorithm::MasterMind::Random::iss
                                             ue_next
 6.16   0.744 11.625 138572   0.0000 0.0001  Algorithm::MasterMind::matches
 5.06   0.611 10.881 499779   0.0000 0.0000  Algorithm::MasterMind::check_rule
 0.58   0.070  0.090      1   0.0699 0.0897  YAML::Type::code::BEGIN
 0.50   0.060  0.389      7   0.0085 0.0555  main::BEGIN
 0.49   0.059  0.195  40252   0.0000 0.0000  YAML::Base::__ANON__
 0.49   0.059  0.059    454   0.0001 0.0001  Params::Validate::_validate
 0.33   0.040  0.192      7   0.0057 0.0274  DateTime::Locale::BEGIN
 0.31   0.038  0.097    449   0.0001 0.0002  DateTime::Locale::_register
 0.30   0.036  0.065   5404   0.0000 0.0000  overload::AddrRef
 0.24   0.029  0.029    322   0.0001 0.0001  Params::Validate::_validate_pos
 0.22   0.026  0.026   5404   0.0000 0.0000  Scalar::Util::blessed
 0.18   0.022  0.029   2335   0.0000 0.0000  YAML::Dumper::_emit_str
 0.17   0.021  0.086   2235   0.0000 0.0000  YAML::Dumper::_emit_node
	

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

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

app/run_experiment.pl  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;

use lib qw(../lib ../../Algorithm-Evolutionary/lib);

use YAML qw(LoadFile);
use IO::YAML;
use DateTime;

use Algorithm::MasterMind qw( check_combination );

my $config_file = shift || die "Usage: $0 <configfile.yaml>\n";

$config_file .= ".yaml" if ! ($config_file =~ /\.ya?ml$/);

my $conf = LoadFile($config_file) || die "Can't open $config_file: $@\n";

my $method = $conf->{'Method'};
eval "require Algorithm::MasterMind::$method" || die "Can't load $method: $@\n";

my $io = IO::YAML->new($conf->{'ID'}."-$method-".DateTime->now().".yaml", ">");
my $method_options = $conf->{'Method_options'};

for my $i (1..$conf->{'tests'}) {

  my $solver;
  eval "\$solver = new Algorithm::MasterMind::$method \$method_options";
  die "Can't instantiate $solver: $@\n" if !$solver;
  my $secret_code = $solver->random_combination();
  my $game = { code => $secret_code,
	       combinations => []};

app/run_experiment_all.pl  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;

use lib qw(../lib ../../Algorithm-Evolutionary/lib);

use YAML qw(LoadFile);
use IO::YAML;
use DateTime;
use Algorithm::Combinatorics qw(variations_with_repetition);

use Algorithm::MasterMind qw( check_combination );

my $config_file = shift || die "Usage: $0 <configfile.yaml>\n";

$config_file .= ".yaml" if ! ($config_file =~ /\.ya?ml$/);

my $conf = LoadFile($config_file) || die "Can't open $config_file: $@\n";

my $method = $conf->{'Method'};
eval "require Algorithm::MasterMind::$method" || die "Can't load $method: $@\n";

my $io = IO::YAML->new($conf->{'ID'}."-$method-".DateTime->now().".yaml", ">");

my $method_options = $conf->{'Method_options'};
$io->print( $method, $method_options );

my $engine = variations_with_repetition($method_options->{'alphabet'}, 
					$method_options->{'length'});

my $combination;
my $repeats = $conf->{'repeats'} || 10;
while ( $combination = $engine->next() ) {



( run in 0.313 second using v1.01-cache-2.11-cpan-05444aca049 )