!++ ! ! LIFE.EDT -- John Conway's game of LIFE, EDT version.... ! ! Uses 21x21 playfield (19x19 calculated points) ! To change playfield size to (say) 40x40, use (from EDT command mode): ! ! S/19/38/w ! S/21/40/w ! ! Remember that if the playfield is increased n times, the time taken to ! calculate each pass is multiplied by n squared. ! ! (21x21 is used so that it takes up an entire screenful after a dividing ! line is added.) ! ! The LIFE macro can be run multiple times; the new playfield is copied ! above the old; the old is padded to full size during the calculation. ! The new playfield is in suitable format for re-submission. ! ! Note that the playfield must consist only of spaces or "O"s ("O" ! representing a live cell). Don't use tabs. The playfield needn't be ! padded out to full size prior to running the macro. ! ! To run this, assuming this file is called LIFE.EDT, enter (at DCL): ! ! $ EDIT/EDT/COMMAND=LIFE file (file could be NL:) ! ! Enter your "organism" into the playfield (ie in the middle of the 21x21 ! area), eg: ! ! OOO ! O ! O ! ! Then return to EDT line mode (or use GOLD-7), and type LIFE. ! ! ! Don Stokes (don@gp.co.nz) 29-Dec-1990 ! !-- ! ! Install LIFE.... ! clear life find buffer life ! ! ----------------------------------------------------------------------------- i;! i;! Pad out playfield and move to scratch buffer i;! i;c;br ^m 21(-c el 100i ^Z bl +21c del l) br dl ex i;! i;! Gather cell groups i;! i;clear z i;c;br 19(19(3(cut+3c paste sel paste appendsr=z -3c+v)-3v +c^M append-c=z)l)ex i;! i;! Gather the cells together so we can count them i;! i;find buffer z i;c;br 19(19(+4c d+c bl i:^z undc el 9(i ^Z)bl+c 8(" "d+c bl+c)bl+10c del l))ex i;! i;! Calculate cell life i;! i;s/: OOO /$O/w/not ;! Cell surrounded by three live cells is born i;s/:OOOO /$O/w/not ;! Live cell surrounded by three others lives i;s/:OOO /$O/w/not ;! Live cell surrounded by two others lives i;s/:O/: /w/not ;! All others die i;! i;! Massage back into playfield i;! i;c;br ^m -c 19(32asc 19(d+2c +c d+el) 32asc ^m) ex i;c;br 21(32asc) ^m +19l 21(32asc) ex i;! i;! Copy rebuilt playfield back to where it came from i;! i;find last i;c;br paste=z 21(i-^z) ^m br ex ! ----------------------------------------------------------------------------- ! find last define macro life ! ! That's all, folks!