Perl creates life! (was Re: Game of Life)

[email protected]
Newsgroups perl.ai
Message-ID <[email protected]>
On 27 Aug 01 at 11:40:36AM, Ala Qumsieh wrote:
> 
> Hey all,
> 
> I hacked a very quick Perl/Tk version of Conway's Game of Life and thought
> some of you might enjoy it.
> 
> --Ala


Interesting coincidence. I've just been working on a perl version of
"life" myself.

It's not Tk and it's not quite as easily customised. But it's
obfuscated, and hopefully amusing. I was going to post it to clpm, but
why miss an opportunity like this to post it here?

Regards,


Ian



--------------------
#!/usr/bin/perl -w

$u =
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "          o  o   o   ooo  ooooo      ooo   o   o   ooo  ooooo  o   o ooooo ooo            \n".
      "          o  o   o  o       o       o   o  oo  o  o   o   o    o   o o     o  o           \n".
      "          o  o   o   ooo    o       ooooo  o o o  o   o   o    ooooo ooo   ooo            \n".
      "      o   o  o   o      o   o       o   o  o  oo  o   o   o    o   o o     o  o           \n".
      "       ooo    ooo    ooo    o       o   o  o   o   ooo    o    o   o ooooo o  o           \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "      o      o  ooooo ooooo    o   o   ooo    ooo   o  o  ooooo  oooo                     \n".
      "      o      o  o     o        o   o  o   o  o   o  o o   o      o   o                    \n".
      "      o      o  ooo   ooo      ooooo  ooooo  o      oo    ooo    oooo                     \n".
      "      o      o  o     o        o   o  o   o  o   o  o o   o      o   o                    \n".
      "      ooooo  o  o     ooooo    o   o  o   o   ooo   o  o  ooooo  o   o                    \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".
      "                                                                                          \n".

    "\n";

$w = index $u, "\n";

%genes = (
	  "CA" => "(?<=(.)[\\w\\W]{" . ($w+1) . "})",
	  "A" => "(?<=(.)[\\w\\W]{" . ($w) . "})",
	  "GA" => "(?<=(.)[\\w\\W]{" . ($w-1) . "})",
	  "C" => "(?<=(.))",
	  "G" => "(?=(.))",
	  "TC" => "(?=[\\w\\W]{" . ($w-1) . "}(.))",
	  "T" => "(?=[\\w\\W]{" . ($w) . "}(.))",
	  "TG" => "(?=[\\w\\W]{" . ($w+1) . "}(.))",
	  );

($dna = "CAAGAC.GTCTTG|CAAGAC.G|C.GTCTTG|CAAC.TCT|AGA.GTTG|CAAC.|AGA.G|C.TCT|.GTTG")
    =~ s/CA|GA|A|TC|TG|T|A|C|G|T/$genes{$&}/g;

sub evolve
{
    my ($n);
    $n += (defined($$_) and $$_ eq "o")? 1: 0 for (1 .. 42);
    return (($n == 2 and $& eq "o") or $n == 3)? "o": " ";
}

print($u), $u =~ s/$dna/evolve/ego while("universe exists");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.