1
0
mirror of https://github.com/rfivet/BCG101.git synced 2024-12-24 19:16:48 -05:00
BCG101/dec/QUEEN.BAS

168 lines
4.2 KiB
QBasic
Raw Normal View History

2024-05-25 23:06:03 -04:00
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