Article View: comp.text
Article #3983LIFE in TeX
From: rokicki
Date: Sun, 30 Aug 1987 23:29
Date: Sun, 30 Aug 1987 23:29
91 lines
3091 bytes
3091 bytes
Here is an implementation of LIFE in TeX, on a 32 by 32 grid.
Output goes to the screen; if anyone wants to hack it up to
send output to a .dvi file in some pretty format, I would be
interested. It's a true hack, but an interesting One.
To run, simply run TeX over it, and enter the coordinates of
the points, one by one. Enter a -1 for the last x coordinate.
Try, for instance, 15, 16, 16, 15, 16, 16, 17, 16, 17, 15, -1.
% Life in TeX by Tomas Rokicki
\font\a=cmr10 at 11truept
\fontdimen2246\a=0pt
\newcount\p\newcount\q\newcount\x\newcount\y\newcount\t
\newcount\qq\newcount\abase\newcount\bbase\newcount\g
\abase=35\bbase=1158
\p=1
\loop
\ifnum\p<23
\fontdimen\p\a=0sp
\advance\p by1
\repeat
\loop
\read0 to\xcoord
\x=\xcoord
\ifnum\x>-1
\read0 to\ycoord
\y=\ycoord
\multiply\y by 33
\advance\y by\abase
\advance\y by\x
\fontdimen\y\a=5sp
\repeat
\def\yloop{{
\y=0
\def\w{}
\loop
\t=\fontdimen\p\a
\ifnum\t>4
\ifnum\t<8
\qq=\q
\advance\qq by-34
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by31
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by1\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by31
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\advance\qq by1
\t=\fontdimen\qq\a\advance\t by2\fontdimen\qq\a=\t sp
\xdef\w{\w*}
\else
\xdef\w{\w.}
\fi
\else
\xdef\w{\w.}
\fi
\fontdimen\p\a=0sp
\global\advance\p by1
\global\advance\q by1
\advance\y by1
\ifnum\y<32\repeat
\immediate\write0{|\w|}
}}
\def\dogeneration{{
\global\p=\abase
\global\q=\bbase
\immediate\write0{|--------------------------------| Generation \number\g}
\x=0
\loop
\yloop
\global\advance\p by1
\global\advance\q by1
\advance\x by1
\ifnum\x<32\repeat
\t=\abase
\global\abase=\bbase
\global\bbase=\t
}}
\loop
\global\advance\g by1
\dogeneration
\iftrue\repeat
Technical Details
Message-ID:
<535@rocky.STANFORD.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!labrea!rocky!rokickiShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!labrea!rocky!rokicki From: rokicki@rocky.UUCP Newsgroups: comp.text Subject: LIFE in TeX Message-ID: <535@rocky.STANFORD.EDU> Date: Sun, 30-Aug-87 19:29:21 EDT Article-I.D.: rocky.535 Posted: Sun Aug 30 19:29:21 1987 Date-Received: Mon, 31-Aug-87 03:42:48 EDT Organization: Stanford University Computer Science Department Lines: 91