As
halley pointed out to me in node
433726, there is in fact a way to avoid the necessity of changing AI::Genetic at all, though it requires a small use of prototyping, which I know you abhor, to make it work.
In my version, you just have to write the make_config sub like this:
sub make_config {
my (@genes) = @_;
# sort classes in order by genes:
# stupid #!@#!#$! sort bug
my $sortsub = sub ($$) {
my ($a,$b) = @_;
$genes[$a] <=> $genes[$b];
};
my (@sclasses) = @CLASSES[sort $sortsub (0..$#CLASSES)];
push(@sclasses, (qw{XXX}) x ($SLOTS * $ROOMS));
my ($config) = [];
for my $s (0..$SLOTS-1) {
push @$config, [];
for my $r (0..$ROOMS-1) {
my $i=0;
while (!is_acceptable($sclasses[$i],$s,$r,$config)) {$i++;}
push @{$config->[-1]}, splice(@sclasses,$i,1);
}
}
$config;
}
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/;
map{y/X_/\n /;print}map{pop@$_}@/for@/
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.