100 REM CONWAY'S GAME OF LIFE 102 REM G IS NUMBER OF GENERATIONS, M IS MATRIX SIZE (M X M) 104 REM A(X, Y) IS 1 IFF CELL AT (X, Y) IS LIVE 106 REM L(SELF_ALIVE, NEIGHBORS_ALIVE) IS 1 IFF CELL WITH THOSE COUNTS SHOULD LIVE ON 110 LET G = 10 120 LET M = 12 121 DIM A(12, 12) L(12, 12) B(12, 12) 125 READ A(3,4), A(3,5), A(3,6), A(6,5), A(6,6), A(7,5), A(7,6) 130 DATA 1, 1, 1, 1, 1, 1, 1 140 READ L(0, 3), L(1, 3), L(1, 2) 145 DATA 1, 1, 1 150 REM MAIN LOOP: PRINT, THEN REPEAT G TIMES: UPDATE / COPY / PRINT 155 LET I = 0 160 GOSUB 700 170 FOR I = 1 TO G+1 180 GOSUB 300 190 GOSUB 500 200 GOSUB 700 210 NEXT I 220 STOP 300 REM SUBROUTINE: UPDATE B = NEXT_GENERATION(A) 310 FOR Y = 1 TO M-1 320 FOR X = 1 TO M-1 325 LET N = A(X-1,Y)+A(X+1,Y)+A(X,Y-1)+A(X,Y+1)+A(X-1,Y-1)+A(X+1,Y+1)+A(X-1,Y+1)+A(X+1,Y-1) 330 LET B(X, Y) = L(A(X, Y), N) 340 NEXT X 350 NEXT Y 360 RETURN 500 REM SUBROUTINE: COPY A = B 510 FOR Y = 0 TO M 520 FOR X = 0 TO M 530 LET A(X, Y) = B(X, Y) 540 NEXT X 550 NEXT Y 560 RETURN 700 REM SUBROUTINE: PRINT A 705 PRINT " GENERATION ", I, "\n" 710 FOR Y = 0 TO M 720 FOR X = 0 TO M 730 IF A(X, Y) = 0 THEN 750 740 PRINT "O" 750 IF A(X, Y) = 1 THEN 770 760 PRINT "." 770 NEXT X 780 PRINT "\n" 790 NEXT Y 795 RETURN