From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

sub new {
my ($class) = @_;
my $self = { population => (), ### genomes instances
};
$class = ref($class) || $class;
bless $self, $class;
}
sub add_to {
my ($self, $genome) = @_;
push (@{$self->{population}}, $genome);
}
sub fittest_simple {
my ($self) = @_;
my $fittest_genome = undef;
my $fitness = 0.0;
for (my $i = 0; $i < scalar $self->{population}; $i++) {
if ($self->{population}[$i]->fitness_simple > $fitness) {
$fittest_genome = $self->{population}[$i];
}
}
return $fittest_genome;
}
1;