mirror of
https://github.com/rfivet/BCG101.git
synced 2024-11-18 02:17:00 -05:00
Add BATTLE and QUEEN.
This commit is contained in:
parent
fe2a3365e4
commit
3c630a0919
163
dec/BATTLE.BAS
Normal file
163
dec/BATTLE.BAS
Normal file
@ -0,0 +1,163 @@
|
||||
10 REM -- BATTLE WRITTEN BY RAY WESTERGARD 10/70
|
||||
20 REM COPYRIGHT 1971 BY THE REGENTS OF THE UNIV. OF CALIF.
|
||||
30 REM PRODUCED AT THE LAWRENCE HALL OF SCIENCE, BERKELEY
|
||||
40 DIM F[6,6],H[6,6],A[4],B[4],C[6],L[3]
|
||||
50 MAT F=ZER
|
||||
60 FOR I=1 TO 3
|
||||
70 N=4-I
|
||||
80 FOR J=1 TO 2
|
||||
90 A=INT(6*RND(0)+1)
|
||||
100 B=INT(6*RND(0)+1)
|
||||
110 D=INT(4*RND(0)+1)
|
||||
120 IF F[A,B]>0 THEN 90
|
||||
130 M=0
|
||||
140 GOTO D OF 150,340,550,740
|
||||
150 B[1]=B
|
||||
160 B[2]=B[3]=7
|
||||
170 FOR K=1 TO N
|
||||
180 IF M>1 THEN 240
|
||||
190 IF B[K]=6 THEN 230
|
||||
200 IF F[A,B[K]+1]>0 THEN 230
|
||||
210 B[K+1]=B[K]+1
|
||||
220 GOTO 280
|
||||
230 M=2
|
||||
240 Z=((B[1] MIN B[2]) MIN B[3])
|
||||
250 IF Z=1 THEN 90
|
||||
260 IF F[A,Z-1]>0 THEN 90
|
||||
270 B[K+1]=Z-1
|
||||
280 NEXT K
|
||||
290 F[A,B]=9-2*I-J
|
||||
300 FOR K=1 TO N
|
||||
310 F[A,B[K+1]]=F[A,B]
|
||||
320 NEXT K
|
||||
330 GOTO 990
|
||||
340 A[1]=A
|
||||
350 B[1]=B
|
||||
360 A[2]=A[3]=B[2]=B[3]=0
|
||||
370 FOR K=1 TO N
|
||||
380 IF M>1 THEN 460
|
||||
390 IF A[K]=1 OR B[K]=1 THEN 450
|
||||
400 IF F[A[K]-1,B[K]-1]>0 THEN 450
|
||||
410 IF F[A[K]-1,B[K]]>0 AND F[A[K]-1,B[K]]=F[A[K],B[K]-1] THEN 450
|
||||
420 A[K+1]=A[K]-1
|
||||
430 B[K+1]=B[K]-1
|
||||
440 GOTO 530
|
||||
450 M=2
|
||||
460 Z1=((A[1] MAX A[2]) MAX A[3])
|
||||
470 Z2=((B[1] MAX B[2]) MAX B[3])
|
||||
480 IF Z1=6 OR Z2=6 THEN 90
|
||||
490 IF F[Z1+1,Z2+1]>0 THEN 90
|
||||
500 IF F[Z1,Z2+1]>0 AND F[Z1,Z2+1]=F[Z1+1,Z2] THEN 90
|
||||
510 A[K+1]=Z1+1
|
||||
520 B[K+1]=Z2+1
|
||||
530 NEXT K
|
||||
540 GOTO 950
|
||||
550 A[1]=A
|
||||
560 A[2]=A[3]=7
|
||||
570 FOR K=1 TO N
|
||||
580 IF M>1 THEN 640
|
||||
590 IF A[K]=6 THEN 630
|
||||
600 IF F[A[K]+1,B]>0 THEN 630
|
||||
610 A[K+1]=A[K]+1
|
||||
620 GOTO 680
|
||||
630 M=2
|
||||
640 Z=((A[1] MIN A[2]) MIN A[3])
|
||||
650 IF Z=1 THEN 90
|
||||
660 IF F[Z-1,B]>0 THEN 90
|
||||
670 A[K+1]=Z-1
|
||||
680 NEXT K
|
||||
690 F[A,B]=9-2*I-J
|
||||
700 FOR K=1 TO N
|
||||
710 F[A[K+1],B]=F[A,B]
|
||||
720 NEXT K
|
||||
730 GOTO 990
|
||||
740 A[1]=A
|
||||
750 B[1]=B
|
||||
760 A[2]=A[3]=7
|
||||
770 B[2]=B[3]=0
|
||||
780 FOR K=1 TO N
|
||||
790 IF M>1 THEN 870
|
||||
800 IF A[K]=6 OR B[K]=1 THEN 860
|
||||
810 IF F[A[K]+1,B[K]-1]>0 THEN 860
|
||||
820 IF F[A[K]+1,B[K]]>0 AND F[A[K]+1,B[K]]=F[A[K],B[K]-1] THEN 860
|
||||
830 A[K+1]=A[K]+1
|
||||
840 B[K+1]=B[K]-1
|
||||
850 GOTO 940
|
||||
860 M=2
|
||||
870 Z1=((A[1] MIN A[2]) MIN A[3])
|
||||
880 Z2=((B[1] MAX B[2]) MAX B[3])
|
||||
890 IF Z1=1 OR Z2=6 THEN 90
|
||||
900 IF F[Z1-1,Z2+1]>0 THEN 90
|
||||
910 IF F[Z1,Z2+1]>0 AND F[Z1,Z2+1]=F[Z1-1,Z2] THEN 90
|
||||
920 A[K+1]=Z1-1
|
||||
930 B[K+1]=Z2+1
|
||||
940 NEXT K
|
||||
950 F[A,B]=9-2*I-J
|
||||
960 FOR K=1 TO N
|
||||
970 F[A[K+1],B[K+1]]=F[A,B]
|
||||
980 NEXT K
|
||||
990 NEXT J
|
||||
1000 NEXT I
|
||||
1010 PRINT
|
||||
1020 PRINT "THE FOLLOWING CODE OF THE BAD GUYS' FLEET DISPOSITION"
|
||||
1030 PRINT "HAS BEEN CAPTURED BUT NOT DE-CODED:"
|
||||
1040 PRINT
|
||||
1050 MAT H=TRN(F)
|
||||
1060 MAT PRINT H;
|
||||
1070 PRINT
|
||||
1080 PRINT "DE-CODE IT AND USE IT IF YOU CAN"
|
||||
1090 PRINT "BUT KEEP THE DE-CODING METHOD A SECRET."
|
||||
1100 PRINT
|
||||
1110 MAT H=ZER
|
||||
1120 MAT L=ZER
|
||||
1130 C[1]=C[2]=2
|
||||
1140 C[3]=C[4]=1
|
||||
1150 C[5]=C[6]=0
|
||||
1160 S=H=0
|
||||
1170 PRINT "START GAME"
|
||||
1180 INPUT X,Y
|
||||
1190 IF X<1 OR X>6 OR INT(X)#ABS(X) THEN 1210
|
||||
1200 IF Y>0 AND Y<7 AND INT(Y)=ABS(Y) THEN 1230
|
||||
1210 PRINT "INVALID INPUT. TRY AGAIN."
|
||||
1220 GOTO 1180
|
||||
1230 R=7-Y
|
||||
1240 C=X
|
||||
1250 IF F[R,C]>0 THEN 1290
|
||||
1260 S=S+1
|
||||
1270 PRINT "SPLASH! TRY AGAIN."
|
||||
1280 GOTO 1180
|
||||
1290 IF C[F[R,C]]<4 THEN 1340
|
||||
1300 PRINT "THERE USED TO BE A SHIP AT THAT POINT, BUT YOU SUNK IT."
|
||||
1310 PRINT "SPLASH! TRY AGAIN."
|
||||
1320 S=S+1
|
||||
1330 GOTO 1180
|
||||
1340 IF H[R,C]>0 THEN 1420
|
||||
1350 H=H+1
|
||||
1360 H[R,C]=F[R,C]
|
||||
1370 PRINT "A DIRECT HIT ON SHIP NUMBER";F[R,C]
|
||||
1380 C[F[R,C]]=C[F[R,C]]+1
|
||||
1390 IF C[F[R,C]] >= 4 THEN 1470
|
||||
1400 PRINT "TRY AGAIN."
|
||||
1410 GOTO 1180
|
||||
1420 PRINT "YOU HAVE ALREADY PUT A HOLE IN SHIP NUMBER";F[R,C];
|
||||
1430 PRINT "AT THAT POINT."
|
||||
1440 PRINT "SPLASH! TRY AGAIN."
|
||||
1450 S=S+1
|
||||
1460 GOTO 1180
|
||||
1470 L[INT((F[R,C]-1)/2)+1]=L[INT((F[R,C]-1)/2)+1]+1
|
||||
1480 PRINT "AND YOU SUNK IT. HURRAH FOR THE GOOD GUYS."
|
||||
1490 PRINT "SO FAR THE BAD GUYS HAVE LOST"
|
||||
1500 PRINT L[1];"DESTROYER(S), ";L[2];"CRUISER(S), AND ";
|
||||
1510 PRINT L[3];"AIRCRAFT CARRIER(S)."
|
||||
1520 PRINT "YOUR CURRENT SPLASH/HIT RATIO IS";S/H
|
||||
1530 IF (L[1]+L[2]+L[3])<6 THEN 1180
|
||||
1540 PRINT
|
||||
1550 PRINT "YOU HAVE TOTALLY WIPED OUT THE BAD GUYS' FLEET"
|
||||
1560 PRINT "WITH A FINAL SPLASH/HIT RATIO OF";S/H
|
||||
1570 IF S/H>0 THEN 1590
|
||||
1580 PRINT "CONGRATULATIONS -- A DIRECT HIT EVERY TIME."
|
||||
1590 PRINT
|
||||
1600 PRINT "*******************"
|
||||
1610 PRINT
|
||||
1620 GOTO 50
|
||||
1630 END
|
167
dec/QUEEN.BAS
Normal file
167
dec/QUEEN.BAS
Normal file
@ -0,0 +1,167 @@
|
||||
1 REM PLAYS QUEEN GAME.
|
||||
2 PRINT "DO YOU WISH INSTRUCTIONS";
|
||||
9 RANDOMIZE
|
||||
10 DIM S(64)
|
||||
11 FOR I = 1 TO 64
|
||||
12 READ S(I)
|
||||
13 NEXT I
|
||||
14 DATA 81, 71, 61, 51, 41, 31, 21, 11
|
||||
15 DATA 92, 82, 72, 62, 52, 42, 32, 22
|
||||
16 DATA 103, 93, 83, 73, 63, 53, 43, 33
|
||||
17 DATA 114, 104, 94, 84, 74, 64, 54, 44
|
||||
18 DATA 125, 115, 105, 95, 85, 75, 65, 55
|
||||
19 DATA 136, 126, 116, 106, 96, 86, 76, 66
|
||||
20 DATA 147, 137, 127, 117, 107, 97, 87, 77
|
||||
21 DATA 158, 148, 138, 128, 118, 108, 98, 88
|
||||
22 INPUT W$
|
||||
23 IF W$="NO" THEN 30
|
||||
24 IF W$="YES" THEN 28
|
||||
25 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
|
||||
26 GOTO 22
|
||||
28 GOSUB 5000
|
||||
29 GO TO 100
|
||||
30 GOSUB 5150
|
||||
90 REM ERROR CHECKS.
|
||||
100 PRINT "WHERE WOULD YOU LIKE TO START";
|
||||
110 INPUT M1
|
||||
115 IF M1 = 0 THEN 232
|
||||
120 LET T1 = INT(M1/10)
|
||||
130 LET U1 = M1 - 10*T1
|
||||
140 IF U1 = 1 THEN 200
|
||||
150 IF U1 = T1 THEN 200
|
||||
160 PRINT "PLEASE READ THE DIRECTIONS AGAIN."
|
||||
165 PRINT "YOU HAVE BEGUN ILLEGALLY."
|
||||
170 PRINT
|
||||
180 GO TO 100
|
||||
200 GO SUB 2000
|
||||
210 PRINT "MACHINE MOVES TO SQUARE"M
|
||||
215 IF M = 158 THEN 3400
|
||||
220 PRINT "WHAT IS YOUR MOVE";
|
||||
230 INPUT M1
|
||||
231 IF M1 <> 0 THEN 239
|
||||
232 PRINT
|
||||
233 PRINT "IT LOOKS LIKE I HAVE WON BY FORFEIT."
|
||||
234 PRINT
|
||||
235 GO TO 4000
|
||||
239 IF M1 <= M THEN 3200
|
||||
240 LET T1 = INT(M1/10)
|
||||
250 LET U1 = M1 - 10*T1
|
||||
260 LET P = U1 - U
|
||||
270 IF P <> 0 THEN 300
|
||||
280 LET L = T1 - T
|
||||
290 IF L <= 0 THEN 3200
|
||||
295 GO TO 200
|
||||
300 IF T1 - T <> P THEN 320
|
||||
310 GO TO 200
|
||||
320 IF T1 - T <> 2*P THEN 3200
|
||||
330 GO TO 200
|
||||
1990 REM LOCATE MOVE FOR MACHINE.
|
||||
2000 IF M1 = 41 THEN 2180
|
||||
2010 IF M1 = 44 THEN 2180
|
||||
2020 IF M1 = 73 THEN 2180
|
||||
2030 IF M1 = 75 THEN 2180
|
||||
2040 IF M1 = 126 THEN 2180
|
||||
2050 IF M1 = 127 THEN 2180
|
||||
2060 IF M1 = 158 THEN 3300
|
||||
2065 LET C = 0
|
||||
2070 FOR K = 7 TO 1 STEP -1
|
||||
2080 LET U=U1
|
||||
2090 LET T = T1 + K
|
||||
2100 GO SUB 3500
|
||||
2105 IF C = 1 THEN 2160
|
||||
2110 LET U = U + K
|
||||
2120 GO SUB 3500
|
||||
2125 IF C = 1 THEN 2160
|
||||
2130 LET T = T + K
|
||||
2140 GO SUB 3500
|
||||
2145 IF C = 1 THEN 2160
|
||||
2150 NEXT K
|
||||
2155 GO TO 2180
|
||||
2160 LET C=0
|
||||
2170 RETURN
|
||||
2180 GO SUB 3000
|
||||
2190 RETURN
|
||||
2990 REM RANDOM MOVE.
|
||||
3000 LET Z=RND
|
||||
3010 IF Z > .6 THEN 3110
|
||||
3020 IF Z > .3 THEN 3070
|
||||
3030 LET U = U1
|
||||
3040 LET T = T1 + 1
|
||||
3050 LET M = 10*T + U
|
||||
3060 RETURN
|
||||
3070 LET U = U1 + 1
|
||||
3080 LET T = T1 + 2
|
||||
3090 LET M = 10*T + U
|
||||
3100 RETURN
|
||||
3110 LET U = U1 + 1
|
||||
3120 LET T = T1 + 1
|
||||
3130 LET M = 10*T + U
|
||||
3140 RETURN
|
||||
3190 REM ILLEGAL MOVE MESSAGE.
|
||||
3200 PRINT
|
||||
3210 PRINT "Y O U C H E A T . . . TRY AGAIN";
|
||||
3220 GO TO 230
|
||||
3290 REM PLAYER WINS.
|
||||
3300 PRINT
|
||||
3310 PRINT "C O N G R A T U L A T I O N S . . ."
|
||||
3320 PRINT
|
||||
3330 PRINT "YOU HAVE WON--VERY WELL PLAYED."
|
||||
3340 PRINT "IT LOOKS LIKE I HAVE MET MY MATCH."
|
||||
3350 PRINT "THANKS FOR PLAYING---I CAN'T WIN ALL THE TIME."
|
||||
3360 PRINT
|
||||
3370 GO TO 4000
|
||||
3390 REM MACHINE WINS.
|
||||
3400 PRINT
|
||||
3410 PRINT "NICE TRY, BUT IT LOOKS LIKE I HAVE WON."
|
||||
3420 PRINT "THANKS FOR PLAYING."
|
||||
3430 PRINT
|
||||
3440 GO TO 4000
|
||||
3490 REM TEST FOR MACHINE MOVE.
|
||||
3500 LET M = 10*T + U
|
||||
3510 IF M = 158 THEN 3570
|
||||
3520 IF M = 127 THEN 3570
|
||||
3530 IF M = 126 THEN 3570
|
||||
3540 IF M = 75 THEN 3570
|
||||
3550 IF M = 73 THEN 3570
|
||||
3560 RETURN
|
||||
3570 LET C = 1
|
||||
3580 GO TO 3560
|
||||
3990 REM ANOTHER GAME?
|
||||
4000 PRINT "ANYONE ELSE CARE TO TRY";
|
||||
4020 INPUT Q$
|
||||
4030 PRINT
|
||||
4040 IF Q$="YES" THEN100
|
||||
4042 IF Q$="NO" THEN 4050
|
||||
4045 PRINT "INCORRECT ANSWER. PLEASE TYPE 'YES' OR 'NO'";
|
||||
4046 GOTO 4020
|
||||
4050 PRINT "OK - - THANKS AGAIN."
|
||||
4060 STOP
|
||||
4990 REM DIRECTIONS, ETC. . .
|
||||
5000 PRINT "WE ARE GOING TO PLAY A GAME BASED ON ONE OF THE CHESS MOVES."
|
||||
5010 PRINT "OUR QUEEN WILL BE ABLE TO MOVE ONLY TO THE LEFT,"
|
||||
5020 PRINT "DOWN, AND DIAGONALLY DOWN TO THE LEFT."
|
||||
5030 PRINT
|
||||
5040 PRINT "THE OBJECT OF THE GAME IS TO PLACE THE QUEEN IN THE"
|
||||
5050 PRINT "LOWER LEFT-HAND SQUARE BY ALTERNATING MOVES BETWEEN"
|
||||
5060 PRINT "YOU AND THE MACHINE/ THE FIRST ONE TO PLACE THE QUEEN"
|
||||
5070 PRINT "THERE, WINS."
|
||||
5080 PRINT
|
||||
5090 PRINT "YOU GO FIRST AND PLACE THE QUEEN IN ANY ONE OF THE"
|
||||
5100 PRINT "SQUARES ON THE TOP ROW OR RIGHT-HAND COLUMN."
|
||||
5110 PRINT "THAT WILL BE YOUR FIRST MOVE."
|
||||
5120 PRINT "WE WILL THEN ALTERNATE MOVES."
|
||||
5130 PRINT "YOU MAY FORFEIT AT ANY TIME BY TYPING '0' AS YOUR MOVE."
|
||||
5140 PRINT "BE SURE TO PUSH THE 'RETURN' KEY AFTER EACH RESPONSE."
|
||||
5150 PRINT
|
||||
5160 FOR A = 0 TO 7
|
||||
5170 FOR B = 1 TO 8
|
||||
5180 LET I = 8*A + B
|
||||
5190 PRINT S(I);
|
||||
5200 NEXT B
|
||||
5210 PRINT
|
||||
5220 PRINT
|
||||
5225 PRINT
|
||||
5230 NEXT A
|
||||
5240 PRINT
|
||||
5250 RETURN
|
||||
99999 END
|
Loading…
Reference in New Issue
Block a user