Dale's Home Page

Dale’s Atari 800 Games › Stan Ockers

Life

By Stan Ockers, in the ACE newsletter of April 1984.

Play Life

Stan’s write-up

The game of Life is a good test of the speed of a language. In the game, one to four players arrange an initial ‘colony’ on a grid in some pattern. Each colony is then transformed into a new colony, the next generation, according to two simple rules:

1) Each organism with 2 or 3 neighbors survives to the next generation.

2) Each empty space with exactly 3 neighbors has a ‘birth’ of a new organism in the next generation.

In this version, the grid is 20 X 20. Consider how much calculation must be done for each generation. Eight adjacent squares must be investigated for each of the 400 grid positions, a total of 3200 locations. The whole grid is examined before any changes are made. Since this version runs at about 58 generations/minute, you can see how programs created with Action! run quite fast.

Use the joystick to plant organisms for the initial population. Pressing the trigger will set or reset the location. ‘Select’ allows cycling between four available colors. Press ‘Start’ when you are ready to view the changing generations. Pressing ‘Select’ will clear the screen for a new initial population.

You may at first have difficulty in creating colonies which can exist for a very long time. If you want proof that simple arrangements can lead to long lasting populations, try the PI arrangement. The PI is made of a square, three unit on a side, with the central bottom organism missing. Gliders are also interesting. On the same three unit square, put in only the bottom, the middle right and central upper organisms. This glider will repeat itself after four generations and gradually slide off the lower right portion of the screen.

I have modified the rules slightly because of the different colors. When rule 2 is obeyed, the birth organism appears only when there are at least two parents of the same color. It then takes on the color of the parents.

—Stan Ockers

Stan Ockers' Life in Action! write-up in the April 1984 ACE newsletter
As printed: page 14 of the April 1984 issue.

The program

The listing, “LIFE in Action! by Stan Ockers”, is on page 8 of the issue. Stan wrote it in Action!, the compiled language from Optimized Systems Software, and readers needed the Action! cartridge to type it in and compile it. There is no Action! compiler here, so the game page runs a hand translation of the listing into JavaScript: one function for each of Stan’s procedures, with his variable names, sizes and memory addresses, driving the same emulated Atari 800 (its screen, player-missile graphics, collisions and sound) that runs the BASIC games.

Where this copy came from: Written in Action!. The listing was transcribed by hand from the scan (page 8; there is no typed-in or compiled copy). The game page runs a hand translation of the listing into JavaScript, paced so a generation takes about as long as Stan measured on the 800 (about 58 a minute). The printer set “population” in italics, which is how it printed inverse characters, so it appears here in inverse (a different colour on the big-letter line).

Show the listing
;          ACTION! LISTING
; ACE NEWSLETTER, 3662 VINE MAPLE DR
;    EUGENE, OR 97405  $12 YEAR
;  LIFE BY STAN OCKERS, APRIL 1984

MODULE ; LIFE in Action!
BYTE x,y,tot,consol=53279,hue
BYTE ARRAY old(400),new(400),near(7)
CARD cnt,pos,pop,gen

PROC Nbors() ; Find # neighbors of sq.
  tot=0 pos=y*20+x
  SetBlock(near,8,0)
  IF y>0 THEN
    IF x>0 THEN
      IF old(pos-21)>0 THEN
         tot==+1 near(0)=old(pos-21)
      FI FI
    IF old(pos-20)>0 THEN
       tot==+1 near(1)=old(pos-20) FI
    IF x<19 THEN
      IF old(pos-19)>0 THEN
         tot==+1 near(2)=old(pos-19)
      FI FI FI
  IF x<19 THEN
    IF old(pos+1)>0 THEN
       tot==+1 near(3)=old(pos+1) FI FI
  IF y<19 THEN
    IF x<19 THEN
      IF old(pos+21)>0 THEN
         tot==+1 near(4)=old(pos+21)
      FI FI
    IF old(pos+20)>0 THEN
       tot==+1 near(5)=old(pos+20) FI
    IF x>0 THEN
      IF old(pos+19)>0 THEN
         tot==+1 near(6)=old(pos+19)
      FI FI FI
  IF x>0 THEN
    IF old(pos-1)>0 THEN
       tot==+1 near(7)=old(pos-1) FI FI
RETURN

PROC Init()
CARD dl
 Graphics(1) x=10 y=10 hue=1
 Setblock(old,400,0) Setblock(new,400,0)
 dl=Peek(560) dl==+256*Peek(561)
 Poke(dl+25,70) Poke(dl+29,6) Poke(82,0)
 Poke(dl+30,6) Poke(656,0) Poke(657,7)
 Print("lIFe") Poke(657,29) Poke(752,1)
 Print("Written in Action!") Poke(656,1)
 Poke(657,22) Print("generation")
 Poke(656,2)
 Poke(657,2) Print("{inv}population{/inv}")
RETURN

PROC Dly(CARD wait)
DO wait==-1 UNTIL wait=0 OD
RETURN

PROC Cursor()
BYTE stk,under
Dly(1000) Position(x,y) PutD(6,120)
Dly(1000) Position(x,y)
under=old(y*20+x)
IF under=0 THEN PutD(6,32)
ELSEIF under=1 THEN PutD(6,42)
ELSEIF under=2 THEN PutD(6,10)
ELSEIF under=3 THEN PutD(6,170)
ELSEIF under=4 THEN PutD(6,138) FI
stk=Stick(0) stk==!15
IF stk&1 THEN IF y>0 THEN y==-1 FI FI
IF stk&2 THEN IF y<19 THEN y==+1 FI FI
IF stk&4 THEN IF x>0 THEN x==-1 FI FI
IF stk&8 THEN IF x<19 THEN x==+1 FI FI
IF STrig(0)=0 THEN
  IF old(y*20+x)=0 THEN old(y*20+x)=hue
  ELSE old(y*20+x)=0 FI Poke(77,0)
  DO UNTIL Strig(0)=1 OD FI
DO UNTIL STrig(0)=1 OD
IF consol=5 THEN hue==+1
  IF hue=5 THEN hue=1 FI FI
IF consol<>6 THEN
DO UNTIL (consol&7)=7 OD FI
RETURN

PROC Fillscr()
Position(0,0) pop=0
FOR cnt=0 TO 399
DO IF old(cnt)=1 THEN PutD(6,42)
   ELSEIF old(cnt)=2 THEN PutD(6,10)
   ELSEIF old(cnt)=3 THEN PutD(6,170)
   ELSEIF old(cnt)=4 THEN PutD(6,138)
   ELSE PutD(6,32) FI
   IF old(cnt)>0 THEN pop==+1 FI OD
Poke(656,1) Poke(657,35) PrintC(gen)
Poke(656,2) Poke(657,15) PrintC(pop)
Print("   ")
RETURN

PROC Nxtgen()
BYTE try,j
FOR y=0 TO 19
DO FOR x=0 TO 19
  DO Nbors() new(pos)=0
  IF old(pos)>0 THEN
    IF(tot=2)OR(tot=3)THEN
      new(pos)=old(pos)
    FI FI
  IF old(pos)=0 THEN
    IF tot=3 THEN
      FOR cnt=0 TO 7
      DO try=near(cnt)
        FOR j=cnt+1 TO 7
        DO IF(near(j)=try)AND try>0
          THEN hue=try EXIT FI OD OD
    new(pos)=hue FI FI
  OD OD
RETURN

PROC Main()
DO
Init() gen=0
DO Cursor() UNTIL consol=6 OD
DO Nxtgen() Fillscr()
  FOR cnt=0 TO 399
  DO old(cnt)=new(cnt) OD
  gen==+1
IF consol=5 THEN EXIT FI OD OD
RETURN

Play Life