10 PRINT CHR$(26);"                  BATTLESHIP"
20 PRINT "                 by Ray Gordon"
30 PRINT "              Copyright (C)  1979"
40 PRINT "             ALL RIGHTS RESERVED"
50 PRINT : PRINT : PRINT
60 PRINT "  You have 50 attempts to sink 5 ships:"
70 PRINT "        1 aircraft carrier (5)"
80 PRINT "        1 battleship (4)"
90 PRINT "        2 destroyers (3)"
100 PRINT "        1 tin can (2)"
110 PRINT
120 PRINT " Do not fire until instructed to enter locations."
130 PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT
140 PRINT "        Push SPACE BAR to go on.";
150 LET Z$=INKEY$
160 IF Z$="" THEN 150
170 PRINT CHR$(26):PRINT:PRINT
180 PRINT "                 BATTLESHIP"
190 PRINT
200 PRINT "        1  2  3  4  5  6  7  8  9  0  1  2"
210 DIM A(12,12): DIM C(12,12)
220 DIM B(12,12): DIM D(12,12)
230 FOR I=1 TO 12
240   FOR J=1 TO 12
250     LET A(I,J)=ASC("*")
260     LET B(I,J)=ASC("*")
270   NEXT J
280 NEXT I
290 FOR I=1 TO 12
300 PRINT TAB(6);CHR$(64+I);"  ";
310   FOR J=1 TO 12
320 PRINT CHR$(A(I,J));"  ";
330   NEXT J
340   PRINT
350 NEXT I
360 LET X=INT(RND*12+1)
370 LET Y=INT(RND*7+1)
380 LET Z=INT(RND*2+1)
390 IF Z=1 THEN 440
400 FOR I=1 TO 5
410   LET B(X,Y+I)=45
420 NEXT I
430 GOTO 470
440 FOR I=1 TO 5
450   LET B(Y+I,X)=45
460 NEXT I
470 LET V=INT(RND*12+1)
480 LET W=INT(RND*7+1)
490 IF Z=1 THEN 560
500 IF X>6 AND W>X-5 THEN 480
510 IF X<=6 AND W<=X THEN 480
520 FOR I=1 TO 4
530   LET B(W+I,V)=45
540 NEXT I
550 GOTO 610
560 IF X>6 AND W>X-4 THEN 480
570 IF X<=6 AND W<=X THEN 480
580 FOR I=1 TO 4
590   LET B(V,W+I)=45
600 NEXT I
610 LET R=INT(RND*12+1)
620 LET S=INT(RND*9+1)
630 LET T=INT(RND*2)
640 IF T=1 THEN 690
650 FOR I=1 TO 3
660   LET C(R,S+I)=45
670 NEXT I
680 GOTO 720
690 FOR I=1 TO 3
700   LET C(S+I,R)=45
710 NEXT I
720 FOR I=1 TO 12
730   FOR J=1 TO 12
740     IF B(I,J)=C(I,J) THEN  EXIT 810
750   NEXT J
760 NEXT I
770 IF T=1 THEN 820
780 FOR I=1 TO 3
790   LET B(R,S+I)=C(R,S+I)
800 NEXT I
810 GOTO 850
820 FOR I=1 TO 3
830   LET B(S+I,R)=C(S+I,R)
840 NEXT I
850 LET D=D+1
860 FOR I=1 TO 12
870   FOR J=1 TO 12
880     LET C(I,J)=0
890   NEXT J
900 NEXT I
910 IF D<2 THEN 610
920 LET O=INT(RND*12+1)
930 LET P=INT(RND*10+1)
940 LET Q=INT(RND*2+1)
950 IF Q=1 THEN 1000
960 FOR I=1 TO 2
970   LET D(O,P+I)=45
980 NEXT I
990 GOTO 1030
1000 FOR I=1 TO 2
1010   LET D(P+I,O)=45
1020 NEXT I
1030 FOR I=1 TO 12
1040   FOR J=1 TO 12
1050     IF B(I,J)=D(I,J) THEN  EXIT 1120
1060   NEXT J
1070 NEXT I
1080 IF Q=1 THEN 1130
1090 FOR I=1 TO 2
1100   LET B(O,P+I)=45
1110 NEXT I
1120 GOTO 1230
1130 FOR I=1 TO 2
1140   LET B(P+I,O)=45
1150 NEXT I
1160 GOTO 1230
1170 FOR I=1 TO 12
1180   FOR J=1 TO 12
1190     LET D(I,J)=0
1200   NEXT J
1210 NEXT I
1220 GOTO 920
1230 PRINT:INPUT "TYPE IN A LETTER: ",M$
1240 INPUT "NOW TYPE A NUMBER: ",N
1250 LET M=ASC(M$)-64
1260 IF B(M,N)=45 THEN 1310
1270 IF A(M,N)=88 THEN 1230
1280 IF A(M,N)=79 THEN 1230
1290 LET A(M,N)=79
1300 GOTO 1320
1310 LET A(M,N)=88
1320 PRINT CHR$(26);
1330 PRINT "TRY NUMBER: ";H+2
1340 PRINT:PRINT
1350 PRINT "                 BATTLESHIP"
1360 PRINT:PRINT
1370 PRINT "        1  2  3  4  5  6  7  8  9  0  1  2"
1380 FOR I=1 TO 12
1390   PRINT TAB(6);CHR$(64+I);"  ";
1400   FOR J=1 TO 12
1410     PRINT CHR$(A(I,J));"  ";
1420   NEXT J
1430   PRINT
1440 NEXT I
1450 FOR I=1 TO 12
1460   FOR J=1 TO 12
1470     IF A(I,J)=88 THEN  LET L=L+1
1480   NEXT J
1490 NEXT I
1500 IF L=17 THEN  PRINT "YOU WON": END
1510 LET L=0: LET H=H+1
1520 IF H=48 THEN  GOTO 1540
1530 GOTO 1230
1540 PRINT CHR$(26)
1550 PRINT TAB(6);"1  2  3  4  5  6  7  8  9  0  1  2"
1560 FOR I=1 TO 12
1570   FOR J=1 TO 12
1580 IF B(I,J)<>45 THEN 1600
1590 IF A(I,J)=42 THEN LET A(I,J)=45
1600   NEXT J
1610 NEXT I
1620 FOR I=1 TO 12
1630   PRINT TAB(12);CHR$(64+I);"  ";
1640   FOR J=1 TO 12
1650     PRINT CHR$(A(I,J));"  ";
1660   NEXT J
1670   PRINT
1680 NEXT I
1690 END
1700 PRINT CHR$(26)
1710 PRINT TAB(12);"1  2  3  4  5  6  7  8  9  0  1  2"
1720 FOR I=1 TO 12
1730   PRINT TAB(12);CHR(64+I);"  ";
1740   FOR J=1 TO 12
1750     PRINT CHR(B(I,J));"  ";
1760   NEXT J
1770   PRINT
1780 NEXT I
1790 RETURN
HR(64+I);"  ";
1740   FOR J=1 TO 12
1750     PRINT CHR(B(I,J));"  ";
1760   NEXT