Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
This was inspired by this obfuscation and this one, which present golfed obfuscations of Conway's Game of Life.  It seemed like a natural extension to write it in Perl/Tk, and then try to golf it down.  (It runs a little slower than it would if it were optimized for speed, which would naturally take more code).

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).

Update:  Here's an example of a file (the pattern is called a "Gosper Glider Gun") which, when passed as the first argument to the obfuscation (eg. life.pl gg.txt), causes an never-ending stream of "gliders" to be produced:
....................................... .........................@............. .......................@.@............. .............@@......@@............@@.. ............@...@....@@............@@.. .@@........@.....@...@@................ .@@........@...@.@@....@.@............. ...........@.....@.......@............. ............@...@...................... .............@@........................

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$..$/

In reply to Evolutionary Japh by liverpole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (7)
    As of 2014-04-17 01:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (437 votes), past polls