Life (Life Revisited)
- Type
- Education
- Category
- Conway's Game of Life simulation
- Author
- Charles Jackson (program); article by Gigi Bisson
- Published in
- Antic, April 1986 (Vol. 4, No. 12), "Life Revisited"
- Year
- 1986
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC, joystick in port 1
- Tags
- antic, game-of-life, cellular-automaton, conway, simulation, joystick, graphics-2, charles-jackson, 1986
- Related
- Alpha Run, Bats, Black Box, Bomb Squad, Bumblbee, Cliffhanger!
About the program
Antic's April 1986 feature "Life Revisited" (program by Charles Jackson, article by Gigi Bisson) retold the story of John Horton Conway's Game of Life. Conway, a Cambridge mathematician, created it in 1970, and Martin Gardner introduced it in Scientific American in February 1971. The article tells how Conway offered a $50 prize to anyone who could prove or disprove that a population could grow without limit, and how MIT's Bill Gosper spent 18 months hacking Life on a PDP-1. It also quotes William Poundstone's The Recursive Universe, which called the Life screen "a window onto an alternate universe".
Life, the article said, "is more like a lava lamp than a game". You set up a pattern of cells, and from then on it plays itself by three rules:
- Death: a cell with four or more neighbours dies of overcrowding, and one with one or none dies of loneliness. In this version, cells that reach the edge of the screen also die.
- Survival: a cell with two or three neighbours lives on.
- Birth: an empty square with exactly three neighbours gets a new cell.
Typing it in
The listing is short and plain, with no special characters. The magazine printed TYPO II codes. If you want to know where the time goes, it's in the neighbour count (lines 500–520), which BASIC repeats for every cell and every square around it.
How to use it
A blinking asterisk cursor appears on a blue GRAPHICS 2 screen. Move it with the joystick and press the trigger to place a cell (an X). Press the trigger again on an X to remove it. The X shows once the cursor moves away. When your pattern is ready, press START. The generations then alternate between gold and black cells. When every cell has died, the program starts again.
The article suggests trying a box made of four clusters of three cells, or a cross of six. Small patterns are faster: one of 35 cells "will be about as exciting as watching grass grow, and not much faster". It also recommends Martin Gardner's Wheels, Life and Other Mathematical Amusements (W. H. Freeman, 1983) for further reading.
How it works
- Two arrays,
FIRSTandSECOND, hold the current and next generation on a 22 × 14 grid. The visible area is 20 × 12, and the extra border means the neighbour count never runs off the edge of the array. - To save time, the program tracks the leftmost and rightmost columns in use (
MINX,MAXX) and only examines that band of the grid (lines 200–250). - Each cell is a GRAPHICS 2 character.
COLOR (120+128*D)*SECOND(Y,X)prints anxin one of two colours, depending on the flagD, which flips every generation. That's where the alternating gold and black comes from. IF D/2=INT(D/2)(line 90) is a compact test for the three "up" joystick positions, which all have even values (10, 14 and 6).
Listing
2 REM LIFE
4 REM BY CHARLES JACKSON
6 REM (c) 1985, ANTIC PUBLISHING
10 GRAPHICS 0:DIM FIRST(22,14),SECOND(22,14)
15 GOSUB 10000
20 FOR X=1 TO 22:FOR Y=1 TO 14
30 FIRST(X,Y)=0:SECOND(X,Y)=0
40 NEXT Y:NEXT X
50 GRAPHICS 2+16:POKE 712,148
60 OLDX=0:OLDY=0:CURX=0:CURY=0:MAXX=1:MINX=22
65 MX=1:MI=22
70 COLOR 10:PLOT CURX,CURY
80 D=STICK(0)
81 IF STRIG(0) THEN 90
82 FIRST(CURX+2,CURY+2)= NOT (FIRST(CURX+2,CURY+2))
83 IF CURX+2>MAXX THEN MAXX=CURX+2
84 IF CURX+2<MINX THEN MINX=CURX+2
87 FOR TIME=1 TO 100:NEXT TIME
90 IF D/2=INT(D/2) THEN CURY=CURY-1
100 IF D=9 OR D=13 OR D=5 THEN CURY=CURY+1
110 IF D>8 AND D<12 THEN CURX=CURX-1
120 IF D>4 AND D<8 THEN CURX=CURX+1
130 CURX=CURX*(CURX>=0):CURY=CURY*(CURY>=0)
140 IF CURX>19 THEN CURX=19
150 IF CURY>11 THEN CURY=11
160 COLOR 0:PLOT OLDX,OLDY:IF FIRST(OLDX+2,OLDY+2)=1 THEN COLOR 120:PLOT OLDX,OLDY
165 COLOR 10:PLOT CURX,CURY
170 OLDX=CURX:OLDY=CURY
175 IF PEEK(53279)=6 THEN COLOR 0:PLOT OLDX,OLDY:D=1:GOTO 200
180 GOTO 70
200 EXT=1:POKE 709,30:POKE 711,0
210 FOR X=2 TO 13:FOR Y=MINX TO MAXX
215 IF FIRST(Y,X)=0 THEN 250
220 EXT=0:FOR X1=-1 TO 1:FOR Y1=-1 TO 1
221 GOSUB 500
222 TRAP 40000
230 IF FIRST(Y+Y1,X+X1)=1 THEN IF NBORS=2 OR NBORS=3 THEN SECOND(Y+Y1,X+X1)=1:GOSUB 300
232 IF NBORS=3 THEN SECOND(Y+Y1,X+X1)=1:GOSUB 300
245 NEXT Y1:NEXT X1
250 NEXT Y:NEXT X:MINX=MI:MAXX=MX:IF EXT THEN RUN
260 FOR X=2 TO 13:FOR Y=2 TO 21
265 COLOR (120+128*D)*SECOND(Y,X)
270 FIRST(Y,X)=SECOND(Y,X):PLOT Y-2,X-2:SECOND(Y,X)=0
280 NEXT Y:NEXT X
290 D= NOT (D):GOTO 200
300 IF Y+Y1>MX THEN MX=Y+Y1
310 IF Y+Y1<MI THEN MI=Y+Y1
320 RETURN
500 POKE 77,0:NBORS=0:FOR A=-1 TO 1:FOR B=-1 TO 1:IF A=0 AND B=0 THEN 520
505 IF Y+A+Y1>22 OR X+B+X1>14 THEN 520
510 NBORS=NBORS+FIRST(Y+A+Y1,X+B+X1)
520 NEXT B:NEXT A:RETURN
10000 GRAPHICS 2:POSITION 7,4:? #6;"LIFE":POKE 710,0:POKE 752,1
10010 ? " Atari Version by Charles Jackson"
10020 ? :? " (c) 1985, Antic Publishing"
10060 RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: LIFE.BAS.
Credits
- Program listing: Life (Life Revisited) — program listing (Antic, April 1986 (Vol. 4, No. 12), "Life Revisited") — Charles Jackson (program); article by Gigi Bisson
- Antic, April 1986 - Vol. 4 No. 12: scan of the printed magazine, Life Revisited, program by Charles Jackson, article by Gigi Bisson, pp. 37, 40 — Internet Archive, 1986
- Antic disk, April 1986 - Vol. 4 No. 12: LIFE.BAS (detokenized listing) — Charles Jackson (program); article by Gigi Bisson, 1986
