[Coco] Conway's game of life

Jim Gerrie jim_gerrie at yahoo.ca
Mon Aug 1 20:58:06 EDT 2016


If you’re interested in a glacial Basic Conway’s life here’s one:

0 CLS:PRINT"WAIT...":DIMA(29,63),L(1,8),X,Y,A,C,B,D,H,J,I,K,NO,W,Z,L,M,P,O,Q,T2,T3,GN,P2,MC:GOTO1000
2 A(Y,X)=1:RETURN
3 A(Y,X)=0:RETURN
4 SET(X,Y,W):RETURN
5 A=X-W:IFA=Q THENA=H
6 C=X+W:IFC=L THENC=Z
7 B=Y-W:IFB=Q THENB=I
8 D=Y+W:IFD=M THEND=Z
9 ONL(POINT(X,Y),POINT(A,B)+POINT(X,B)+POINT(C,B)+POINT(A,Y)+POINT(C,Y)+POINT(A,D)+POINT(X,D)+POINT(C,D))GOSUB2,3:RETURN
20 I$="GENERATION: 0              "+CHR$(192):PRINT at P2,I$;
24 X=Z:A=H:C=X+W:FORY=W TOP:B=Y-W:D=Y+W:GOSUB9:NEXT:X=H:A=X-W:C=Z:FORY=W TOP:B=Y-W:D=Y+W:GOSUB9:NEXT
26 Y=Z:B=I:D=Y+W:FORX=W TOO:A=X-W:C=X+W:GOSUB9:NEXT:Y=I:B=Y-W:D=Z:FORX=W TOO:A=X-W:C=X+W:GOSUB9:NEXT
28 X=Z:Y=Z:GOSUB5:Y=I:GOSUB5:X=H:GOSUB5:Y=Z:GOSUB5
29 FORY=W TOP:FORX=W TOO:A=X-W:C=X+W:B=Y-W:D=Y+W
30 ONL(POINT(X,Y),POINT(A,B)+POINT(X,B)+POINT(C,B)+POINT(A,Y)+POINT(C,Y)+POINT(A,D)+POINT(X,D)+POINT(C,D))GOSUB2,3:NEXT
41 POKEMC+Y,PEEK(MC+Y)-L:NEXT
42 CLSZ:PRINT at P2,I$;:PRINT at P2,"GENERATION:";GN;:GN=GN+W
43 FORY=K TOI:FORX=J TOH:ONA(Y,X)GOSUB4:NEXT:NEXT:GOTO24
500 H=63:J=0:I=29:K=0:W=1:Q=-1:Z=0:L=64:M=30
505 P=28:O=62
510 T2=2:T3=3:GN=1:P2=480
520 FORX=0 TO1:FORY=0 TO8:READNO:L(X,Y)=NO
525 NEXT:NEXT
530 CLS:PRINTTAB(6);"JOHN CONWAY'S LIFE"
535 PRINTTAB(8);"FOR THE COCO":PRINTTAB(8)"BY JIM GERRIE":PRINT:PRINT"RUN THE R PENTOMINO (Y/N)?"
540 I$=INKEY$:IFI$=""THEN540
550 IFI$="Y"THENCLS0:FORNO=1TO5:READX,Y:SET(X,Y,W):A(Y,X)=W:NEXT:GOTO20
560 IFI$<>"N"THEN540
565 PRINT:PRINT"RUN THE GLIDER (Y/N)?"
570 I$=INKEY$:IFI$=""THEN570
575 IFI$="Y"THENCLS0:FORNO=1 TO5:READX,Y:NEXT:FORNO=1 TO5:READX,Y:SET(X,Y,W):A(Y,X)=W:NEXT:GOTO20
580 IFI$="N"THEN600
585 GOTO570
587 DATA0,0,0,1,0,0,0,0,0
588 DATA2,2,0,0,2,2,2,2,2
590 DATA31,10,32,10,31,11,30,11,31,12,32,25,33,26,33,27,32,27,31,27
600 CLS0:X=32:Y=16
610 PRINT at 480,"a,s,w,z=MOVE spc=ON/OFF q=QUIT";
611 T=POINT(X,Y):SET(X,Y,1):A(Y,X)=1:I$=INKEY$:IFI$="S"THENGOSUB620:X=X+1:IFX>63THENX=0
612 IFI$="A"THENGOSUB620:X=X-1:IFX<0THENX=63
613 IFI$="W"THENGOSUB620:Y=Y-1:IFY<0THENY=29
614 IFI$="Z"THENGOSUB620:Y=Y+1:IFY>29THENY=0
615 IFI$=" "THENT=(T*-1)+1
616 IFI$="Q"THENGOSUB620:X=0:Y=0:T=0:PRINT at 480,"";:FORT=1TO30:PRINTCHR$(128);:NEXT:GOTO20
617 GOSUB620:GOTO611
620 IFT=0THENRESET(X,Y):A(Y,X)=0:RETURN
621 SET(X,Y,T):A(Y,X)=1:RETURN
1000 MC=1503:POKE65497,0
1020 GOTO500

Jim G


More information about the Coco mailing list