10 REM                       **** LINELIFE.BAS ****
20 REM
30 REM  (c) 1984, KENNETH L. LUNDERS, ANALOGIC DESIGN, SUNNYVALE, CA.
40 REM  DONATED TO THE `FOG' LIBRARY FOR NON-COMMERCIAL USE 
50 REM  BY ITS MEMBERSHIP.
60 REM
100 OPTION BASE 1
110 DEFINT A-Z
120 PRINT CHR$(26);TAB(36);"LINELIFE"
130 PRINT:PRINT:PRINT
140 PRINT "WOULD YOU LIKE A BRIEF EXPLANATION OF THIS PROGRAM";
150 INPUT A$
160 IF A$="NO" THEN 440
170 IF A$="YES" THEN 200
180 INPUT "PLEASE ANSWER 'YES' OR 'NO'.  >",A$
190 GOTO 160
200 PRINT CHR$(&H1A);CHR$(&H1E);
210 PRINT "THIS IS A PROGRAM FOR A CELLULAR-AUTOMATON MACHINE.  IT OPERATES IN"
220 PRINT "ONE DIMENSION, A LINE,";
230 PRINT " AND SHOWS SUCCESSIVE STATES (GENERATIONS) OF A"
240 PRINT "CLASS 4 AUTOMATON, WHICH YOU WILL ORIGINATE."
250 PRINT
260 PRINT "EACH CELL WILL EXIST IN THE FOLLOWING STATE";
270 PRINT " IF THERE ARE EITHER 2 OR 4"
280 PRINT "`LIVE' CELLS WITHIN A + OR - 2 CELL";
290 PRINT " NEIGHBORHOOD IN THE CURRENT STATE,"
300 PRINT "A `LIVE' CELL WILL BE SHOWN AS `*'."
310 PRINT
320 PRINT "THE LINE ENDS IN THIS PROGRAM ARE CONSIDERED";
330 PRINT " TO BE ADJECENT, AS THOUGH"
340 PRINT "A CIRCLE HAD BEEN CUT AND STRETCHED ACROSS THE SCREEN."
350 PRINT 
360 PRINT "THE INSPIRATION FOR THIS PROGRAM COMES FROM AN ARTICLE IN THE MARCH"
370 PRINT "1984 ISSUE OF SCIENTIFIC AMERICAN.  ";
380 PRINT "THE ARTICLE WAS AUTHORED BY BRIAN"
390 PRINT "HAYES FOR THE COMPUTER RECREATIONS DEPARTMENT."
400 PRINT
410 PRINT
420 PRINT TAB(26);"PRESS ANY KEY TO CONTINUE";
430 K$=INPUT$(1):IF K$<=>"" THEN 440
440 PRINT CHR$(&H1A);CHR$(&H1E);
450 PRINT "DO YOU WANT OUTPUT TO YOUR PRINTER";
460 INPUT A$
470 IF A$="NO" THEN 520
480 IF A$="YES" THEN 510
490 INPUT "PLEASE ANSWER 'YES' OR 'NO'.  >",A$
500 GOTO 470
510 P=1
520 PRINT
530 PRINT
540 PRINT "ENTER YOUR PATTERN AFTER THE PROMPT (0=DEAD, 1=LIVE)."
550 FOR BB=1 TO 1000:NEXT BB
560 DIM A(82),B$(82),C$(78)
570 PRINT
580 INPUT "> ",A$
590 L=LEN(A$)
600 IF L>78 THEN L=78
610 FOR X=1 TO L
620  IF MID$(A$,X,1)="0" THEN A(X+2)=0 ELSE A(X+2)=1
630 NEXT X
640 IF L>=78 GOTO 680
650 FOR X=L+3 TO 80
660  A(X)=0
670 NEXT X
680 A(1)=A(79)
690 A(2)=A(80)
700 A(81)=A(1)
710 A(82)=A(2)
720 PRINT CHR$(&H1A);CHR$(&H1E);
730 FOR X=1 TO 82
740  IF A(X)=0 THEN B$(X)=" " ELSE B$(X)="*"
750 NEXT X
760 FOR X=3 TO 80
770 NEXT X
780 FOR X=3 TO 80
790  PRINT B$(X);
800 NEXT X
810 PRINT
820 IF P<>1 GOTO 870
830 FOR X=3 TO 80
840  LPRINT B$(X);
850 NEXT X
860 LPRINT
870 C=0
880 FOR X=3 TO 80
890  IF B$(X-2)="*" THEN C=C+1
900  IF B$(X-1)="*" THEN C=C+1
910  IF B$(X)="*" THEN C=C+1
920  IF B$(X+1)="*" THEN C=C+1
930  IF B$(X+2)="*" THEN C=C+1
940  IF C=2 THEN 980
950  IF C=4 THEN 980
960  C$(X-2)=" "
970  GOTO 990
980  C$(X-2)="*"
990  C=0
1000 NEXT X
1010 FOR X=1 TO 78
1020  PRINT C$(X);
1030  B$(X+2)=C$(X)
1040 NEXT X
1050 PRINT
1060 B$(1)=C$(77)
1070 B$(2)=C$(78)
1080 B$(81)=C$(1)
1090 B$(82)=C$(2)
1100 IF P<>1 GOTO 870
1110 FOR X=1 TO 78
1120  LPRINT C$(X);
1130 NEXT X
1140 LPRINT
1150 GOTO 870
1160 END
(82)=C$(2)
1100 IF P<>1 GOTO 870
1110 FOR X=1 TO 78
1120  LPRINT C$(X);
1130 NEXT X
1140