Sink the computer’s battleships.
Appears on
Gallery
Source Code
49 GO TO 900 50 LET B=100/8: LET B=INT (T/B): BORDER B: CLS : PRINT " YOU CPU": PRINT " 1 1": PRINT " 1234567890 1234567890" 52 FOR K=1 TO 10: PRINT CHR$ (K+64);E$(K,1 TO 10);" ";CHR$ (K+10+64); INK 1;D$(K,1 TO 10) 54 NEXT K: RETURN 70 LET V=1: LET DR=D(DS,1): LET DC=D(DS,2) 72 IF R+DR*(I-1)>10 OR R+DR*(I-1)<1 OR C+DC*(I-1)>10 OR C+DC*(I-1)<1 THEN LET V=0: RETURN 74 FOR J=1 TO I: IF VAL V$<>32 THEN LET V=0: GO SUB 80: RETURN 76 IF V$(2)="C" THEN LET C$(R,C)=CHR$ I: LET L$(I,1)=CHR$ 0: LET L$(I,J+1)=CHR$ 0 78 IF V$(2)="Y" THEN LET Y$(R,C)=CHR$ I: LET E$(R,C)=A$(I,1) 79 LET R=R+DR: LET C=C+DC: NEXT J: RETURN 80 IF J=1 THEN RETURN 82 FOR K=J-1 TO 1 STEP -1: LET R=R-DR: LET C=C-DC 84 IF V$(2)="C" THEN LET C$(R,C)=" ": LET L$(I,1)=CHR$ 0: LET L$(I,K+1)=CHR$ 0 86 IF V$(2)="Y" THEN LET Y$(R,C)=" ": LET E$(R,C)="\a" 88 NEXT K: RETURN 900 DIM C$(10,10): DIM Y$(10,10): DIM D$(10,10): DIM E$(10,10): DIM Z$(10,10): DIM D(8,2) 905 DATA "0","1","0","-1","1","0","-1","0","+1","-1","-1","1","+1","+1","-1","-1" 910 FOR I=1 TO 8: READ V$: LET D(I,1)=VAL V$: READ V$: LET D(I,2)=VAL V$: NEXT I 915 DATA "255","129","129","129","129","129","129","255" 920 FOR I=0 TO 7: READ V$: POKE USR "\a"+I,VAL V$: NEXT I 925 FOR I=1 TO 10: FOR J=1 TO 10: LET D$(I,J)="\a": LET E$(I,J)="\a": NEXT J: NEXT I 930 DIM A$(5,10): FOR I=1 TO 5: READ A$(I): NEXT I 935 DATA "PT-BOAT","SUBMARINE","DESTROYER","BATTLESHIP","CARRIER" 940 DIM L$(5,6) 1000 LET T=1: LET V$="CODE C$(R,C)": FOR I=1 TO 5 1005 LET DS=INT (RND*8)+1 1010 LET S=INT (RND*100)+1: LET R=INT ((S-1)/10)+1: LET C=S-(R-1)*10: IF I=1 THEN LET C$(R,C)=CHR$ I: LET L$(I,1)=CHR$ 0: LET L$(I,2)=CHR$ 0: GO TO 1020 1015 GO SUB 70: IF NOT V THEN GO TO 1005 1020 NEXT I 1050 FOR I=1 TO 5 1055 GO SUB 50: PRINT AT 13,0;"ENTER POSITION OF ";A$(I): INPUT V$ 1060 IF NOT LEN V$ THEN GO TO 1055 1062 IF LEN V$<2 OR LEN V$>3 THEN GO TO 1055 1065 LET R=CODE V$(1)-64: LET C=VAL V$(2 TO ): IF I=1 THEN LET Y$(R,C)=CHR$ I: LET E$(R,C)=A$(I,1): GO TO 1090 1066 PRINT AT R+2,C; FLASH 1;"\a"; 1070 PRINT AT 14,0;"ENTER DIRECTION FOR ";TAB 0;A$(I): PRINT "846";TAB 0;"2*1";TAB 0;"537": INPUT V$ 1075 IF NOT LEN V$ THEN GO TO 1070 1077 PRINT V$: IF LEN V$>1 OR V$>"8" OR V$<"1" THEN GO TO 1070 1080 LET DS=VAL V$ 1085 LET V$="CODE Y$(R,C)": GO SUB 70: IF NOT V THEN BEEP 2,-5: GO TO 1055 1090 NEXT I 1400 LET M$="START THE GAME" 1405 LET RHC=0: LET RHY=0: LET SC=0: LET SY=0 1410 PRINT "HOW SMART IS MR. COMPUTER?";TAB 0;"0=IGNORANT, 10=GENIUS": INPUT CINT: IF CINT<0 OR CINT>10 THEN CLS : GO TO 1410 1415 LET CINT=CINT/10: LET CREM=0 1500 IF RHC=15 OR RHY=15 THEN GO TO 2400 1501 GO SUB 50: PRINT "ENTER YOUR GUESS": PRINT AT 20,0;M$: PRINT TAB 4;SY/T;TAB 17;SC/T: LET M$=" ": INPUT V$ 1505 IF NOT LEN V$ THEN GO TO 1500 1507 IF V$(1)<"K" OR V$(1)>"T" OR LEN V$<2 THEN GO TO 1500 1509 IF VAL V$(2 TO )<1 OR VAL V$(2 TO )>10 THEN GO TO 1500 1510 LET R=CODE V$(1)-CODE "J": LET C=VAL V$(2 TO ) 1515 IF CODE C$(R,C)>5 THEN LET D$(R,C)="\::": GO TO 2000 1516 IF D$(R,C)>="A" AND D$(R,C)<="Z" THEN GO TO 2000 1520 LET RHY=RHY+1: BEEP .5,43: LET D$(R,C)="X": LET M$="YOU GOT 'EM; TRY AGAIN": LET SY=SY+100-T 1525 LET L=CODE C$(R,C): LET M=CODE (L$(L,1))+1: LET L$(L,1)=CHR$ M: LET L$(L,M+1)=CHR$ ((R-1)*10+C) 1530 IF M=L THEN FOR I=1 TO M: LET V=CODE (L$(L,I+1)): LET R=INT ((V-1)/10)+1: LET C=V-(R-1)*10: LET D$(R,C)=A$(L,1): NEXT I 1535 GO TO 1500 2000 LET K=INT (RND*100)+1: IF RND<CINT AND CREM<>0 THEN LET K=CREM: LET R=INT ((K-1)/10)+1: LET C=K-(R-1)*10: LET R=R-1*(R>1): LET C=C-1*(C>1): FOR I=R TO 10: FOR J=C TO 10: GO TO 2015 2005 FOR I=INT (RND*10)+1 TO 10: IF RND>=.5 THEN FOR I=10 TO INT (RND*10)+1 STEP -1 2010 FOR J=INT (RND*10)+1 TO 10: IF RND>=.5 THEN FOR J=10 TO INT (RND*10)+1 STEP -1 2015 IF Z$(I,J)=" " THEN GO TO 2100 2016 IF RND>CINT THEN GO TO 2100 2020 IF CODE Y$(I,J)>5 THEN GO TO 2100 2025 FOR L=1 TO 8 2026 LET RR=I+D(L,1): LET CC=J+D(L,2): IF RR>10 OR RR<1 OR CC<1 OR CC>10 THEN GO TO 2050 2030 LET K=(RR-1)*10+CC 2035 IF Z$(RR,CC)=" " THEN GO TO 2200 2050 NEXT L 2055 LET K=INT (RND*100)+1 2100 NEXT J 2150 NEXT I 2200 LET R=INT ((K-1)/10)+1: LET C=K-(R-1)*10: IF Z$(R,C)<>" " THEN LET CREM=0: LET K=INT (RND*100)+1: GO TO 2200 2205 IF CODE Y$(R,C)>5 THEN LET E$(R,C)="\::": LET Z$(R,C)="\::": GO TO 2250 2210 LET Z$(R,C)="\::": LET CREM=K: LET RHC=RHC+1: LET E$(R,C)=CHR$ (CODE Y$(R,C)+47): LET SC=SC+100-T: BEEP .5,10: LET M$="HE GOTCHA!!!": GO TO 2000 2250 LET T=T+1: GO TO 1500 2400 FOR I=1 TO 10: FOR J=1 TO 10 2401 IF C$(I,J)<>" " AND D$(I,J)=" " THEN LET D$(I,J)=CHR$ (CODE (A$(CODE C$(I,J),1))+32) 2402 NEXT J: NEXT I 2405 GO SUB 50: PRINT AT 19,0;"YOU=";SY/T+T*(RHY=15);"(";SY;")";TAB 0;"CPU=";SC/T+T*(RHC=15);"(";SC;")": IF RHC=15 THEN PRINT "MR. COMPUTER SANK YOUR NAVY!": COPY : STOP 2500 PRINT "YOU SANK THE COMPUTER.": COPY : STOP