Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0065/bt.bas
There are 2 other files named bt.bas in the archive. Click here to see a list.
00010'THIS PROGRAM WAS WRITTEN BY DAVID DYER AT IMMACULATE HEART
00020'COLLEGE     COMPLETED 10/71   REVISION 5/72 (REV 12/73 ED MASON)
00030 DIM A(9,19),B(7,1)
00040 FOR E=0TO 7
00050 FORF=0TO1
00060READB(E,F)
00070NEXT F
00080 NEXT E
00090 DATA 8,2,8,3,8,4,8,5,7,6,7,7,6,8,6,9
00100 PRINT "THIS IS THE BATTLESHIP GAME. IF YOU NEED HELP, TYPE 'YES'"
00110 INPUT A$
00120 IF A$<>"YES"THEN 420
00130 PRINT
00140 PRINT
00150 PRINT"BATTLESHIP IS PLAYED ON A 10X10 MATRIX. YOU HAVE 8 SHIPS TO"
00160 PRINT"PLACE ANYWHERE ON THE MATRIX. THE SHIPS MUST BE IN EITHER A"
00165 PRINT"HORIZONTAL OR VERTICAL STRAIGHT LINE"
00170 PRINT"AND MUST OCCUPY THE NUMBER OF SQUARES INDICATED BELOW."
00180 PRINT" TWO SUBMARINES","2 SQUARES EACH"
00190 PRINT" TWO DESTROYERS","2 SQUARES EACH"
00200 PRINT" TWO BATTLESHIPS","3 SQUARES EACH"
00210 PRINT" TWO AIRCRAFT CARRIERS","4 SQUARES EACH"
00220 PRINT
00230 PRINT "TO SINK A SHIP, YOU MUST HIT EVERY SQUARE OCCUPIED BY THAT SHIP."
00240 PRINT
00250 PRINT"INPUT COORDINATES AS WHOLE NUMBERS. FOR EXAMPLE: 159 FOR 15,9"
00260 PRINT
00270 PRINT"***HINTS***"
00290 PRINT
00300 PRINT"IT WILL BE TO YOUR ADVANTAGE TO  SPACE YOUR SHIPS SO THAT"
00310 PRINT"NONE WILL BE FOUND WHILE TRYING TO SINK ANOTHER SHIP"
00320 PRINT"HOWEVER, YOU SHOULD NOT ASSUME THAT YOUR OPPONENT WILL DO THIS."
00330 PRINT
00340 PRINT"THE MORE METHODICAL YOUR SEARCH IS, THE BETTER YOUR CHANCES."
00350 PRINT"YOU SHOULD USE THE MATRICES PRINTED OUT TO KEEP TRACK OF"
00360 PRINT"YOUR SHOTS AND HITS.  YOU MAY WASTE SHOTS IF YOU ARE NOT"
00370 PRINT"CAREFUL.  WASTED SHOTS ARE THOSE PLACED IN POSITIONS"
00380 PRINT"ALREADY SHOT AT OR SHOTS WHICH ARE OUT OF THE MATRIX"
00390 PRINT"(POSITON .LT. 100 OR POSITION .GT. 199)"
00400 PRINT
00410 PRINT"TO GET AN ACCOUNTING OF SHOTS AND HITS AT ANY TIME, ENTER -1"
00420 PRINT
00430RANDOMIZE
00440 FOR M=0 TO 19
00450 FOR N=0 TO 9
00460 LET A(N,M)=1
00470 NEXT N
00480 NEXT M
00490 LET M1=0
00500 LET M2=9
00510 GOSUB 3230
00520FORN=1TO5
00530PRINT
00540NEXTN
00550 FOR X=7 TO 0 STEP -1
00560LETP=INT(RND(0)*B(X,0))
00570LETQ=INT(RND(0)*10)
00580IFRND(0)>.5THEN2520
00590FORY=1TO (10-B(X,0))
00600LETF=P+Y-1
00610 IF A(F,Q) >1 THEN 560
00620 LET E=Q+1
00630 IF E>9 THEN 650
00640 IF A(F,E)>1 THEN 560
00650 LET E=Q-1
00660  IF E<0 THEN680
00670 IF A(F,E)>1 THEN 560
00680 NEXTY
00690FORY=1TO(10-B(X,0))
00700 LETF=P+Y-1
00710LETA(F,Q)=B(X,1)*A(F,Q)
00720NEXTY
00730 NEXT X
00740PRINT"INPUT THE ENDPOINTS OF YOUR SHIPS AS YOU ARE ASKED FOR THEM"
00750 FOR M=2 TO 9
00760 IF M<4 THEN 950
00770 IF M<6 THEN 970
00780 IF M<8 THEN 990
00790 PRINT"AIRCRAFT CARRIER";
00800 INPUT N,P
00810 IF N<100 THEN1010
00820 IF N>199 THEN 1010
00830 LET N1=INT(N/10)
00840 LET N=INT(N-10*N1)
00850 IF P<100 THEN 1010
00860 IF P>199 THEN 1010
00870 LET P1=INT(P/10)
00880 LET P=INT(P-P1*10)
00890 LET Y=M-2
00900 IF SQR((N-P)^2+(N1-P1)^2)<>9-B(Y,0) THEN 1010
00910 GOTO 1030
00920 IF X=0 THEN 740
00930 LET X=X-1
00940GOTO 560
00950 PRINT"SUBMARINE";
00960 GOTO800
00970 PRINT "DESTROYER";
00980 GOTO 800
00990 PRINT "BATTLESHIP";
01000 GOTO 800
01010 PRINT "ILLEGAL ENTRY, TRY AGAIN"
01020 GOTO760
01030 IF P>N THEN 2680
01040LET Y=1
01050 IF P1>N1 THEN 2700
01060LET Z=1
01070 FOR Q=P TO N STEP Y
01080 FOR F=P1 TO N1 STEP Z
01090 IF A(Q,F)>1THEN 1010
01100 NEXT F
01110 NEXT Q
01120 FOR Q=P TO N STEP Y
01130 FOR F=P1TON1 STEP Z
01140 LET A(Q,F)=M
01150 NEXT F
01160 NEXT Q
01170 NEXT M
01180 PRINT
01190 PRINT"HERE IS YOUR FLEET'S CONFIGURATION"
01200 PRINT
01205 PRINT "           # = OCEAN"
01210 LET M1=10
01220 LET M2=19
01225 M4=-1
01230 GOSUB 3230
01240 LET Q=1
01250 PRINT"YOU HAVE 5 SHOTS"
01270 FOR X=1 TO 5
01280 PRINT"SHOT #"X;
01290 INPUT N
01300 IF N=-1 THEN 2720
01310 LET N= N-100
01320 IF N<0 THEN 1370
01330 IF N>99 THEN 1370
01340 LET E=0
01350 GOSUB 1390
01370 NEXT X
01380 GOTO 1840
01390 LET P=INT(N/10)
01400 LET N=INT(N-P*10)
01410 IF E=10 THEN 2110
01420 LET A(N,P)=-1*ABS(A(N,P))
01430 IF ABS( A(N,P))>1 THEN 1500
01440 PRINT"MISS"
01450 IF E=0 THEN 1490
01460 IF Q=-2 THEN 2000
01470 IF Q=1 THEN 1490
01480 GOSUB 2290
01490 RETURN
01500 PRINT CHR$(7);CHR$(7);"HIT"
01510 IF E=0 THEN 1630
01520 IF Q<>1 THEN 1590
01530 LET B(4,0)=ABS(A(N,P))
01540 LET B(2,0)=P*10+N
01550 LET B(3,0)=ABS(A(N,P))
01560 LET Q=-1
01570 GOSUB 2290
01580 IF Q=-1 THEN 1610
01590IF ABS(A(N,P))<>B(3,0)THEN 1610
01600 LET Q=-2
01610 LET M=ABS(A(N,P))-2
01620 LET B(M,1)=-1*ABS(B(M,1))
01630 FOR Y=E TO E+9
01640 FOR M=0 TO9
01650 IF A(M,Y)=ABS(A(N,P)) THEN 1490
01660 NEXT M
01670 NEXT Y
01680 PRINT CHR$(7);CHR$(7); "SUNK"
01690 IF E=0 THEN 1780
01700 LET M=ABS(A(N,P))-2
01710 LET B(M,1)=ABS(B(M,1))
01720 LET M=B(4,0)-2
01730 IF B(4,0)<>B(M,1) THEN 2000
01740 FOR M=0 TO 7
01750 IF B(M,1)<0 THEN 2170
01760  NEXT M
01770 LET Q=1
01780  FOR M=0 TO 9
01790 FOR  Y=E TO E+9
01800 IF A(M,Y)>1 THEN 1490
01810 NEXT Y
01820 NEXT M
01830 GOTO 2340
01840 LET E=10
01860 PRINT"I HAVE 5 SHOTS "
01870 FOR X=1 TO 5
01880 IF Q>0 THEN 2040
01890 LETB(1,0)=B(1,0)+P1
01900 LET N=B(1,0)
01910 GOSUB 1390
01920 NEXT X
01940 GOTO1250
01950 IF Q=-2 THEN 2010
01960 IF Q=1 THEN 1980
01970 GOSUB 2290
01980 LET X=X-1
01990 GOTO 1490
02000 LET X=X+1
02010 LET P1=-1*P1
02020 LET B(1,0)=B(2,0)
02030 GOTO 1980
02040 LET M=INT(RND(0)*5)*2
02050LET N=INT(RND(0)*10)+10
02060 LET Y=(-1)^N
02070 IF Y>0 THEN 2090
02080 LET M=M-Y
02090 LET N=M+N*10
02100 GOTO 1910
02110  IF P*10+N<100 THEN 1950
02120 IF P*10+N>199 THEN 1950
02130 IF A(N,P)<1 THEN 1950
02150 PRINT "MY SHOT #"X;P*10+N
02160 GOTO 1420
02170 LET B(3,0)=B(M,1)
02180 FOR Y=E TO E+9
02190 FOR M=0 TO 9
02200 IF A(M,Y)=B(3,0) THEN 2250
02210 NEXT M
02220 NEXT Y
02230 LET Q=1
02240 GOTO 1880
02250 LET B(2,0)=Y*10+M
02260 LET Q=-1
02270 GOSUB 2290
02280 GOTO 1490
02290 LET P1=INT(RND(0)*2)*9+1
02300 LET B(1,0)=B(2,0)
02310 IF RND(0)>.5 THEN 2330
02320 LET P1=-1*P1
02330 RETURN
02340 FOR X=1 TO 6
02350 PRINT CHR$(7)
02360 NEXT X
02370 IF E=0 THEN 2500
02380 PRINT"I ";
02390 PRINT"WIN"
02400 PRINT "MY POSITION WAS"
02410 LET M1=0
02420 LET M2=9
02430 LET M4=-1
02440 GOSUB 3400
02450 LET M1=10
02460 LET M2=19
02470 PRINT"YOUR BOARD POSITION WAS"
02480 GOSUB 3400
02490 STOP
02500 PRINT "YOU ";
02510 GOTO 2390
02520FORY=1TO(10-B(X,0))
02530LETF=P+Y-1
02540IFA(Q,F)>1THEN560
02550 LET E=Q+1
02560 IF E>9 THEN 2580
02570 IF A(E,F)>1 THEN 560
02580 LET E=Q-1
02590 IF E<0 THEN 2610
02600 IF A(E,F)>1 THEN 560
02610 NEXT Y
02620FORY=1TO(10-B(X,0))
02630LETF=P+Y-1
02640LETA(Q,F)=B(X,1)*A(Q,F)
02650NEXTY
02660 GOTO 920
02670GOTO560
02680 LET Y=-1
02690GOTO 1050
02700LET Z = -1
02710GOTO 1070
02720 PRINT
02730 PRINT"ENTER YOUR OPTION, OR 'HELP' FOR HELP";
02740 INPUT A$
02750 IF A$<>"HELP" THEN 2870
02760 PRINT
02770 PRINT
02780 PRINT"OPTION","FUNCTION"
02790 PRINT
02800 PRINT"END","RETURNS TO MAIN PROGRAM"
02810 PRINT"G","A GENERAL TABULATION OF RELATIVE POSITIONS"
02820 PRINT"MINE","PRINTS A COPY OF YOUR BOARD WITH SHOTS MARKED"
02830 PRINT"YOURS","PRINTS MY BOARD WITH YOUR HITS AND SHOTS MARKED"
02840 PRINT
02850 PRINT
02860 GOTO 2730
02870 IF A$="END" THEN 1280
02880 IF A$<>"MINE" THEN 2950
02890 LET M4=1
02900 LET M1=10
02910 LET M2=19
02920 PRINT"HERE IS YOUR BOARD WITH THE HITS AND SHOTS MARKED"
02930 GOSUB 3400
02940 GOTO 2730
02950 IF A$<>"YOURS" THEN 3020
02960 LET M4=0
02970 LET M1=0
02980 LET M2=9
02990 PRINT"HERE IS MY BOARD WITH YOUR SHOTS AND HITS MARKED"
03000 GOSUB 3400
03010 GOTO 2730
03020 IF A$<>"G" THEN 2730
03030 LET M1=10
03040 LET M2=19
03050 GOSUB 3150
03060 PRINT"ON YOUR FLEET,";M4;"HITS OF POSSIBLE 22 HITS"
03070 PRINT
03080 LET M1=0
03090 LET M2=9
03100 GOSUB 3150
03110 PRINT"ON MY FLEET,"M4;"HITS OF POSSIBLE 22 HITS"
03120 PRINT
03130 PRINT
03140 GOTO 2730
03150 LET M4=0
03160 FOR M=M1 TO M2
03170 FOR N=0 TO 9
03180 IF A(N,M)>-2 THEN 3200
03190 LET M4=M4+1
03200 NEXT N
03210 NEXT M
03220 RETURN
03230 PRINT
03240 PRINT
03250 PRINT"    ";
03260 FOR M=0 TO 9
03270 PRINT M;
03280 NEXT M
03290 FOR M=M1 TO M2
03310 PRINT
03320 PRINT M+10-M1;
03330 FOR N= 0 TO 9
03340 GOSUB 5000
03345 PRINT S$;
03350 NEXT N
03360 NEXT M
03370 PRINT
03380 PRINT
03390 RETURN
03400 PRINT
03410 PRINT "# = OCEAN; * = A SHOT; H = A HIT"
03420 PRINT
03430 PRINT "    ";
03432 FOR M=0 TO 9
03434 PRINT M;
03436 NEXT M
03440 FOR M=M1 TO M2
03450 PRINT
03455 PRINT M+10-M1;
03460 FOR N=0 TO 9
03470 GOSUB 5000
03480 PRINT S$;
03560 NEXT N
03570 NEXT M
03580 PRINT
03590 PRINT
03600 RETURN
05000 IF A(N,M)<-1 GO TO 5200
05010 IF A(N,M)=-1 GO TO 5220
05015 IF M4=0 THEN 5240
05020 IF A(N,M)=1 GO TO 5240
05030 IF A(N,M)=2 GO TO 5260
05040 IF A(N,M)=3 GO TO 5280
05050 IF A(N,M)=4 GO TO 5300
05060 IF A(N,M)=5 GO TO 5320
05070 IF A(N,M)=6 GO TO 5340
05080 IF A(N,M)=7 GO TO 5360
05100 IF A(N,M)=8 GO TO 5380
05110 IF A(N,M)=9 GO TO 5400
05120 S$=" ? "
05130 RETURN
05200 S$=" H "
05210 RETURN
05220 S$=" * "
05230 RETURN
05240 S$=" # "
05250 RETURN
05260 S$=" S1"
05270 RETURN
05280 S$=" S2"
05290 RETURN
05300 S$=" D1"
05310 RETURN
05320 S$=" D2"
05330 RETURN
05340 S$=" B1"
05350 RETURN
05360 S$=" B2"
05370 RETURN
05380 S$=" A1"
05390 RETURN
05400 S$=" A2"
05410 RETURN
99999 END
*U*$=x