100 ' **********************************************" 110 ' ********************************************** 120 ' ** ** 130 ' ** CONNECT THE DOTS ** 140 ' ** ** 150 ' ** by Chuck Lund ** 160 ' ** ** 170 ' ** originally appeared in ** 180 ' ** Creative Computing ** 190 ' ** Jan/Feb 1976 ** 200 ' ** ** 210 ' ** Modified for use on the ** 220 ' ** OSBORNE 1 Computer ** 230 ' ** by ** 240 ' ** ALEX MORALES ** 250 ' ** (213) 969-4921 ** 260 ' ** ** 270 ' ********************************************** 280 ' ********************************************** 290 GR$=CHR$(27)+"g" 'GRAPHICS MODE 300 NG$=CHR$(27)+"G" 'END GRAPHICS MODE 310 HI$=CHR$(27)+CHR$(41) 'HALF INTENSITY MODE 320 NI$=CHR$(27)+CHR$(40) 'NORMAL INTENSITY MODE 330 ' 61440 IS THE START OF SCREEN RAM 340 GOSUB 2230 350 PRINT CHR$(26);"INITIALIZING...":IF X$="Y" THEN ERASE A,X,Y 360 DIM A(12,12),X(9,9),Y(9,9) 370 V=0:GOSUB 2120 380 FOR R=1 TO 12 390 FOR C=1 TO 12 400 IF R/2=INT(R/2) THEN 440 410 IF C/2=INT(C/2) THEN 440 420 A(R,C)=-50 430 GOTO 450 440 A(R,C)=0 450 NEXT C,R 460 IF V=1 THEN 480 470 PRINT CHR$(26) 480 GOSUB 1210 490 PRINT:PRINT"YOUR MOVE..." 500 GOSUB 1480 510 A(X,Y)=50 520 IF X/2=INT(X/2) THEN 590 530 IF A(X-2,Y)+A(X-1,Y+1)+A(X-1,Y-1)<>150 THEN 560 540 P=1 550 A(X-1,Y)=1 560 IF A(X+2,Y)+A(X+1,Y+1)+A(X+1,Y-1)<>150 THEN 650 570 A(X+1,Y)=1 580 GOTO 480 590 IF A(X,Y-2)+A(X+1,Y-1)+A(X-1,Y-1)<>150 THEN 620 600 A(X,Y-1)=1 610 P=1 620 IF A(X,Y+2)+A(X+1,Y+1)+A(X-1,Y+1)<>150 THEN 650 630 A(X,Y+1)=1 640 GOTO 480 650 IF P=1 THEN 480 660 GOSUB 1210 670 PRINT:PRINT"MY MOVE... " 680 FOR R=4 TO 10 STEP 2 690 FOR C=4 TO 10 STEP 2 700 IF A(R-1,C)+A(R+1,C)+A(R,C-1)+A(R,C+1)<>150 THEN 890 710 A(R,C)=-1 720 IF A(R-1,C)<>0 THEN 760 730 A(R-1,C)=50 740 IF A(R-3,C)+A(R-2,C-1)+A(R-2,C+1)<>150 THEN 660 750 A(R-2,C)=-1 760 IF A(R+1,C)<>0 THEN 800 770 A(R+1,C)=50 780 IF A(R+3,C)+A(R+2,C-1)+A(R+2,C+1)<>150 THEN 660 790 A(R+2,C)=-1 800 IF A(R,C-1)<>0 THEN 840 810 A(R,C-1)=50 820 IF A(R,C-3)+A(R-1,C-2)+A(R+1,C+2)<>150 THEN 660 830 A(R,C-2)=-1 840 IF A(R,C+1)<>0 THEN 660 850 A(R,C+1)=50 860 IF A(R,C+3)+A(R-1,C+2)+A(R+1,C+2)<>150 THEN 660 870 A(R,C+2)=-1 880 GOTO 660 890 NEXT C,R 900 IF E>1 THEN 950 910 IF A(12-X,12-Y)<>0 THEN 950 920 A(12-X,12-Y)=50 930 IF E>1 THEN 1080 940 GOTO 480 950 FOR R=3 TO 9 960 FOR C=3 TO 9 970 IF (R+C)/2=INT((R+C)/2) THEN 1060 980 IF A(R,C)<>0 THEN 1060 990 IF R/2=INT(R/2) THEN 1040 1000 IF A(R-2,C)+A(R-1,C-1)+A(R-1,C+1)=100 THEN 1060 1010 IF A(R+2,C)+A(R+1,C-1)+A(R+1,C+1)=100 THEN 1060 1020 A(R,C)=50 1030 GOTO 480 1040 IF A(R,C-2)+A(R-1,C-1)+A(R+1,C-1)=100 THEN 1060 1050 IF A(R,C+2)+A(R-1,C+2)+A(R+1,C+1)<>100 THEN 1020 1060 NEXT C,R 1070 IF E>1 THEN 910 1080 R=INT(RND*7)+3 1090 C=INT(RND*7)+3 1100 IF R/2=INT(R/2) THEN 1130 1110 IF C/2=INT(C/2) THEN 1150 1120 GOTO 1080 1130 IF C/2<>INT(C/2) THEN 1150 1140 GOTO 1080 1150 IF A(R,C)<>0 THEN 1080 1160 A(R,C)=50 1170 GOTO 480 1180 PRINT:PRINT"PLAY AGAIN? (Y/N) ";:X$=INPUT$(1) 1190 IF X$="Y" THEN 350 1200 PRINT X$:END 1210 P=0:D=0:E=0 1220 FOR R=3 TO 9 1230 ON R-2 GOSUB 1250,1260,1250,1260,1250,1260,1250 1240 NEXT:GOTO 1370 1250 A$(R-2)=GR$+CHR$(13)+STRING$(6,(32+((A(R,4)=50)*10)))+CHR$(13)+STRING$(6,(32+((A(R,6)=50)*10)))+CHR$(13)+STRING$(6,(32+((A(R,8)=50)*10)))+CHR$(13)+NG$:RETURN 1260 A$(R-2)=GR$+CHR$(32+((A(R,3)=50)*10))+NG$ 1270 IF A(R,4)=1 THEN A$(R-2)=A$(R-2)+HI$+"PLAYER"+NI$:E=E+1:GOTO 1290 1280 IF A(R,4)=-1 THEN A$(R-2)=A$(R-2)+HI$+" COMP "+NI$:D=D+1 ELSE A$(R-2)=A$(R-2)+" " 1290 A$(R-2)=A$(R-2)+GR$+CHR$(32+((A(R,5)=50)*10))+NG$ 1300 IF A(R,6)=1 THEN A$(R-2)=A$(R-2)+HI$+"PLAYER"+NI$:E=E+1:GOTO 1320 1310 IF A(R,6)=-1 THEN A$(R-2)=A$(R-2)+HI$+" COMP "+NI$:D=D+1 ELSE A$(R-2)=A$(R-2)+" " 1320 A$(R-2)=A$(R-2)+GR$+CHR$(32+((A(R,7)=50)*10))+NG$ 1330 IF A(R,8)=1 THEN A$(R-2)=A$(R-2)+HI$+"PLAYER"+NI$:E=E+1:GOTO 1350 1340 IF A(R,8)=-1 THEN A$(R-2)=A$(R-2)+HI$+" COMP "+NI$:D=D+1 ELSE A$(R-2)=A$(R-2)+" " 1350 A$(R-2)=A$(R-2)+GR$+CHR$(32+((A(R,9)=50)*10))+NG$ 1360 RETURN 1370 PRINT CHR$(&H1E) 1380 FOR XXX=1 TO 7 1390 IF XXX MOD 2 = 0 THEN 1410 1400 PRINT TAB(15);A$(XXX):GOTO 1440 1410 FOR YYY=1 TO 3 1420 PRINT TAB(15);A$(XXX) 1430 NEXT YYY 1440 NEXT XXX 1450 IF E>=5 THEN PRINT:PRINT"YOU WON! ":PRINT:GOTO 1180 1460 IF D>=5 THEN PRINT:PRINT"I WON! ":PRINT:GOTO 1180 1470 RETURN 1480 FOR R=3 TO 9 1490 FOR C=3 TO 9 1500 IF X(R,C)=0 THEN 1520 1510 IF A(R,C)=0 THEN 1530 1520 NEXT C,R 1530 XX=X(R,C):YY=Y(R,C) 1540 POKE 61440!+XX+128*YY,0 1550 M$=INPUT$(1) 1560 IF M$=CHR$(8) THEN GOSUB 1620 1570 IF M$=CHR$(10) THEN GOSUB 1730 1580 IF M$=CHR$(11) THEN GOSUB 1860 1590 IF M$=CHR$(12) THEN GOSUB 2010 1600 IF M$=CHR$(13) THEN X=R:Y=C:RETURN 1610 GOTO 1540 1620 IF XX=14 AND (YY=3 OR YY=7 OR YY=11) THEN PRINT CHR$(7);:RETURN 1630 IF XX=17 AND (YY=1 OR YY=5 OR YY=9 OR YY=13) THEN PRINT CHR$(7);:RETURN 1640 IF (YY=1 OR YY=5 OR YY=9 OR YY=13) THEN 1690 1650 CC=C-2 1660 IF CC>=3 THEN 1670 ELSE PRINT CHR$(7);:RETURN 1670 IF A(R,CC)<>0 THEN CC=CC-2:GOTO 1660 1680 POKE 61440!+XX+128*YY,32:C=CC:XX=X(R,C):RETURN 1690 CC=C-2 1700 IF CC>=4 THEN 1710 ELSE PRINT CHR$(7);:RETURN 1710 IF A(R,CC)<>0 THEN CC=CC-2:GOTO 1700 1720 GOTO 1680 1730 RR=R 1740 IF RR>8 THEN PRINT CHR$(7);:RETURN 1750 IF (RR=4 OR RR=6 OR RR=8) THEN 1790 1760 RR=RR+1:FOR CC=3 TO 9 STEP 2 1770 IF A(RR,CC)<>50 THEN 1840 1780 NEXT CC 1790 RR=RR+1 1800 FOR CC=4 TO 8 STEP 2 1810 IF A(RR,CC)<>50 THEN 1840 1820 NEXT CC 1830 R=R+1:GOTO 1740 1840 POKE 61440!+XX+128*YY,32:R=RR:C=CC:XX=X(R,C):YY=Y(R,C) 1850 RETURN 1860 RR=R 1870 RR=RR-1 1880 IF RR<3 THEN PRINT CHR$(7);:RETURN 1890 IF (RR=3 OR RR=5 OR RR=7 OR RR=9) THEN 1940 1900 FOR CC=3 TO 9 STEP 2 1910 IF A(RR,CC)<>50 THEN 1990 1920 NEXT CC 1930 RR=RR-1 1940 FOR CC=4 TO 8 STEP 2 1950 IF A(RR,CC)<>50 THEN 1990 1960 NEXT CC 1970 RR=RR-1 1980 GOTO 1880 1990 POKE 61440!+XX+128*YY,32:R=RR:C=CC:XX=X(R,C):YY=Y(R,C) 2000 RETURN 2010 IF XX=35 AND (YY=3 OR YY=7 OR YY=11) THEN PRINT CHR$(7);:RETURN 2020 IF XX=31 AND (YY<=1 OR YY=5 OR YY=9 OR YY=13) THEN PRINT CHR$(7);:RETURN 2030 IF (YY=1 OR YY=5 OR YY=9 OR YY=13) THEN 2080 2040 CC=C+2 2050 IF CC<=9 THEN 2060 ELSE PRINT CHR$(7);:RETURN 2060 IF A(R,CC)<>0 THEN CC=CC+2:GOTO 2050 2070 POKE 61440!+XX+128*YY,32:C=CC:XX=X(R,C):RETURN 2080 CC=C+2 2090 IF CC<=8 THEN 2100 ELSE PRINT CHR$(7);:RETURN 2100 IF A(R,CC)<>0 THEN CC=CC+2:GOTO 2090 2110 GOTO 2070 2120 J=1 2130 FOR I=3 TO 9 STEP 2 2140 X(I,4)=17:Y(I,4)=J 2150 X(I,6)=24:Y(I,6)=J 2160 X(I,8)=31:Y(I,8)=J:J=J+2 2170 IF I=9 THEN RETURN 2180 X(I+1,3)=14:Y(I+1,3)=J 2190 X(I+1,5)=21:Y(I+1,5)=J 2200 X(I+1,7)=28:Y(I+1,7)=J 2210 X(I+1,9)=35:Y(I+1,9)=J:J=J+2 2220 NEXT I 2230 PRINT CHR$(26) 2240 PRINT"THIS PROGRAM WILL PLAY CONNECT THE DOTS WITH YOU." 2250 PRINT:PRINT"THE GAME IS PLAYED ON A 4 x 4 ARRAY. WHEN YOU" 2260 PRINT"WANT TO MAKE A MOVE, USE THE FOUR ARROW KEYS TO" 2270 PRINT"MOVE THE CURSOR TO THE SPACE BETWEEN TWO DOTS YOU" 2280 PRINT"WANT TO CONNECT. ONCE YOU HAVE DECIDED ON YOUR" 2290 PRINT"MOVE, PRESS AND THE COMPUTER WILL DRAW" 2300 PRINT"THE LINE BETWEEN THE TWO DOTS. WHEN YOU HAVE" 2310 PRINT"COMPLETED A SQUARE, THAT SQUARE IS YOURS AND YOU" 2320 PRINT"MAY TAKE ANOTHER TURN." 2330 PRINT:PRINT"THE GAME ENDS WHEN EITHER YOU OR THE COMPUTER HAVE" 2340 PRINT"COMPLETED 5 SQUARES." 2350 PRINT:PRINT:PRINT"Hit to start... "; 2360 RS$=INKEY$:IF RS$="" THEN RS=RS+1:GOTO 2360 2370 IF RS>32767 THEN RS=RS-32767:GOTO 2370 2380 RANDOMIZE RS:RETURN