|Perl Monk, Perl Meditation|
Evolutionary Japhby liverpole (Monsignor)
|on Nov 14, 2006 at 19:05 UTC||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.
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.