Update 3: You need to have Perl/Tk installed for this program to work.
s''map{$j ^=1;map{$g{$j}{ $_}=1}split//}spl it"/",$G||="23/3";s ub#g{$z=pop;$r=\$C[ 64*$x+$y];$Q=$x<0|| $x>63||$y<0||$y>63? 0:$$r;if($z>=0&&$ Q!=$z){$$r=$z;$ M=512*$x+ 8*$y;$I=$ I[$M]and$c->del ete($I);$I[$M]=cr eateOval$c(3+8*$x,3 +8*$y,9+8*$x,9+8*$y ,-f=>$z?"blue":$N,o utline=>$N)}$Q}use# Tk;$m=new#MainWin dow(title=>$G); $c=$m->Ca nvas(w,51 4,he,514) ->pack;af ter$m(1,sub{$N= cget$c(bg);@S=0 ..63;map{$a=2+8 *$_;@D=(2,$a,515, $a);map{createLin e$c(@D);@D=($a,@D );pop@D}7..8}@S,64; $F?do{open(_,$F);ma p{$x=0;map{g(/@/);$ x++}split//;++$y;}< _>}:map{$x=$_;map{$ y=$_;g(1>rand#4)}@S }@S;{for$p(@S){map{ $q=$_;$t=0;for$v(-1 ..1){map{$x=$p+$_;$ y=$v+$q;$g=g(-1);$_ ||$v#or$G=$g;$t+=$g ;}(-1..1)}$N[64*$p+ $q]=$g{$G||0}{$t- $G}}@S}for$x(@S){ map{$y=$_;g+$N[64 *$x+$_]}@S}upda te$m;redo}});Ma inLoop';s#\s##g ;s&#& &g; ($F,$G)=@ ARGV;eval
But wait, there's more... If you give a single filename argument (other than "0", which is ignored), it will read the starting setup from that file, where each line (of up to 64 lines) contains up to 64 characters; '@' = living cell, and anything else is non-living.
And, if you specify a second command-line argument, it changes the rules! This link describes the more interesting variations of the super-set of John Horton Conway's game (which can be classified as "23/3" life).
A second argument of "23/34", for example, would switch the rules to those of HighLife, whereas "34678/3678" would use the rules of Day & Night. (You can always give a first argument of "0" to generate a random pattern instead of reading from a file).
....................................... .........................@............. .......................@.@............. .............@@......@@............@@.. ............@...@....@@............@@.. .@@........@.....@...@@................ .@@........@...@.@@....@.@............. ...........@.....@.......@............. ............@...@...................... .............@@........................
And you can try different rules, sometimes with surprising results.
For example, try using the same file, but substitute the "1357/1357 = Replicator" pattern: life.pl gg.txt 1357/1357. The results are completely different.
Or try: life.pl 0 2345/45678 to see the results of "Walled Cities" rule ("2345/45678"), applied to to a random pattern.
Update 2: I can't resist adding another one that I just now tried for the first time (again, from this page).
This one is called "Diamoeba (5678/35678)", and works best with a pattern that contains many living cells close together; for example:
................................................ ................................................ ................................................ ................................................ ................................................ ................................................ ................................................ ................................................ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Assuming the above file is called "block.txt", you can see the results with: life.pl block.txt 5678/35678.
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Evolutionary Japh
by sh1tn (Priest) on Nov 15, 2006 at 01:35 UTC | |
Re: Evolutionary Japh
by wulvrine (Friar) on Nov 20, 2006 at 14:01 UTC | |
Re: Evolutionary Japh
by NateTut (Deacon) on Nov 27, 2006 at 22:00 UTC | |
by liverpole (Monsignor) on Nov 28, 2006 at 13:11 UTC | |
by NateTut (Deacon) on Nov 28, 2006 at 17:29 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |