rokicki@rocky.UUCP (08/31/87)
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