1
0
mirror of https://github.com/rfivet/BCG101.git synced 2024-12-18 08:06:27 -05:00
BCG101/port/EVEN1.BAS

69 lines
2.0 KiB
QBasic

1 PRINT "GAME OF EVEN WINS - CYBERNETIC VERSION"\PRINT
2 PRINT "DO YOU WANT INSTRUCTIONS (YES OR NO)";\INPUT A$
3 IF A$="NO" THEN 20
4 PRINT\PRINT "THE GAME IS PLAYED AS FOLLOWS:"
5 PRINT "AT THE BEGINNING OF A GAME, A RANDOM NUMBER OF CHIPS ARE"
6 PRINT "PLACED ON THE BOARD. THE NUMBER OF CHIPS ALWAYS STARTS"
7 PRINT "AS AN ODD NUMBER. ON EACH TURN, A PLAYER MUST TAKE ONE,"
8 PRINT "TWO, THREE, OR FOUR CHIPS. THE WINNER IS THE PLAYER WHO"
9 PRINT "FINISHES WITH A TOTAL NUMBER OF CHIPS THAT IS EVEN."
10 PRINT "THE COMPUTER STARTS OUT KNOWING ONLY THE RULES OF THE"
11 PRINT "GAME. IT GRADUALLY LEARNS TO PLAY WELL. IT SHOULD BE"
12 PRINT "DIFFICULT TO BEAT THE COMPUTER TWENTY GAMES IN A ROW."
13 PRINT "TRY IT!!!"\PRINT
14 PRINT "TO QUIT AT ANY TIME, TYPE A '0' AS YOUR MOVE."\PRINT
20 DIM R(1,5)\RANDOMIZE
25 L=0\E=0
30 FOR I=0 TO 5
40 R(1,I)=4
50 R(0,I)=4
60 NEXT I
70 A=0\B=0
90 P=INT((13*RND(1)+9)/2)*2+1
100 IF P=1 THEN 530
110 PRINT "THERE ARE"P"CHIPS ON THE BOARD."
120 E1=E
130 L1=L
140 E=(A/2-INT(A/2))*2
150 L=INT((P/6-INT(P/6))*6+.5)
160 IF R(E,L)>=P THEN 320
170 M=R(E,L)
180 IF M<=0 THEN 370
190 P=P-M
200 IF M=1 THEN 510
210 PRINT "COMPUTER TAKES"M"CHIPS LEAVING"P" ...YOUR MOVE";
220 B=B+M
230 INPUT M
240 M=INT(M)
250 IF M<1 THEN 450
260 IF M>4 THEN 460
270 IF M>P THEN 460
280 IF M=P THEN 360
290 P=P-M
300 A=A+M
310 GOTO 100
320 IF P=1 THEN 550
330 PRINT "COMPUTER TAKES"P"CHIPS"
340 R(E,L)=P
350 B=B+P
360 IF B/2=INT(B/2) THEN 420
370 PRINT "GAME OVER ... YOU WIN!!"\PRINT
390 IF R(E,L)=1 THEN 480
400 R(E,L)=R(E,L)-1
410 GOTO 70
420 PRINT "GAME OVER ... I WIN!!!"\PRINT
430 GOTO 70
450 IF M=0 THEN 570
460 PRINT M"IS AN ILLEGAL MOVE ... YOUR MOVE";
470 GOTO 230
480 IF R(E1,L1)=1 THEN 70
490 R(E1,L1)=R(E1,L1)-1
500 GOTO 70
510 PRINT "COMPUTER TAKES 1 CHIP LEAVING"P" ... YOUR MOVE";
520 GOTO 220
530 PRINT "THERE IS 1 CHIP ON THE BOARD"
540 GOTO 120
550 PRINT "COMPUTER TAKES 1 CHIP"
560 GOTO 340
570 END