|
|
@ -97,16 +97,9 @@ for (my $gen = 0; $gen < $gens; $gen++) {
|
|
|
|
# This is the next evoultion of the the automation
|
|
|
|
# This is the next evoultion of the the automation
|
|
|
|
my @next;
|
|
|
|
my @next;
|
|
|
|
for (my $elem = 0; $elem < $width ; $elem++) {
|
|
|
|
for (my $elem = 0; $elem < $width ; $elem++) {
|
|
|
|
# Boundary conditions
|
|
|
|
# Boundary conditions handled by modulo so we wrap around
|
|
|
|
my $state;
|
|
|
|
my $state = $initial[$elem - 1 % $width] . $initial[$elem] . $initial[$elem +1 % $width];
|
|
|
|
if($elem == 0 ) {
|
|
|
|
|
|
|
|
$state = $initial[$width -1] . $initial[$elem] . $initial[$elem +1 ] ;
|
|
|
|
|
|
|
|
} elsif ($elem == $width -1 ) {
|
|
|
|
|
|
|
|
$state = $initial[$elem-1] . $initial[$elem] . $initial[0];
|
|
|
|
|
|
|
|
# Normal, we are not on the boundary
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$state = $initial[$elem - 1] . $initial[$elem] . $initial[$elem +1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the corresponding value for this state
|
|
|
|
# Get the corresponding value for this state
|
|
|
|
$next[$elem] = get_val_at_pos oct("0b".$state);
|
|
|
|
$next[$elem] = get_val_at_pos oct("0b".$state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|