セルオートマトン
#!/usr/bin/perl

package au;

use strict;
use warnings;
use List::Util qw(reduce);


%au::kigou = (
0=>" ",
1=>"+",
2=>"|",
3=>"-",
);

srand(time);

my @swarm = map{&birth;}0..200;
map{&$_(0);} @swarm;
&{$swarm[0]}(1);
map{

my @pre = map{&$_(-1);}@swarm;
my $last = pop @pre; my $first = shift @pre;
unshift @pre, $first; unshift @pre, $last ;
push @pre, $last ; push @pre, $first;
my $i =0;
print map{
$au::kigou{&$_(&trancode(($pre[++$i-1] << 2) + ($pre[$i] << 1) + $pre[$i+1]))};
}@swarm;
print "\n";
}0..1000;

sub trancode{
my @tran =(0,1,1,1,1,0,0,0,);
return $tran[$_[0]];
}


#Cell Automaton
sub birth{
my $state = rand(1);
if($state>0.5){$state=1;}else{$state=0;}
return sub{
if($_[0] != -1){$state = $_[0];}
return $state;
}
}