'=========================================================================== ' Subject: PC BATTLE OF NUMBERS GAME Date: 12-23-98 (18:30) ' Author: The ABC Programmer Code: BEC ' Origin: voxel@edmc.net Packet: BASEC.ABC '=========================================================================== ' Converted to BASEC [DOS] by William Yu ' 5 '----------- PC BATTLE OF NUMBERS GAME ------------ 8 ' DIM C as integer, I as integer, M as integer, P as integer,_ T as integer, X as integer 10 CLS 20 'DEFINT C, I, M, P, T, X 30 RANDOMIZE 'VAL(RIGHT$(TIME$, 2)) 40 M = RND(4) + 5 50 T = RND(19) + 17 55 LOCATE 25, 25 60 PRINT CHR$(16); CHR$(16); CHR$(16); " THE BATTLE OF NUMBERS "; 70 PRINT CHR$(17); CHR$(17); CHR$(17); 75 LOCATE 1, 1 80 PRINT "THIS GAME PITS YOU AGAINST THE PC IN A TEST OF "; 90 PRINT "MATHMATICAL SKILL. TWO NUMBERS," 100 PRINT "ONE SEVERAL TIMES LARGER THAN THE OTHER,HAVE "; 110 PRINT "BEEN SELECTED AT RANDOM. BY TURNS" 120 PRINT "BOTH YOU AND THE COMPUTER SUBTRACT AN INTERGER "; 130 PRINT "BETWEEN 1 AND "; 140 COLOR 31, 0: PRINT M; : COLOR 7, 0: PRINT " FROM THE TOTAL" 150 PRINT "LISTED BELOW UNTIL ZERO IS LEFT. WHOEVER MUST "; 160 PRINT "MAKE THE FINAL SUBTRACTION IS THE" 170 PRINT "LOSER. UNLESS YOU EMPLOY A RATIONAL STRATEGY,"; 180 PRINT " THE COMPUTER WILL TROUNCE YOU" 190 PRINT "EVERY TIME, AND GLOAT ABOUT IT, TOO. "; 200 PRINT "THE FIRST TURN IS YOURS -- GOOD LUCK!" 210 PRINT CHR$(201); STRING$(28, 205); CHR$(203); 220 PRINT STRING$(20, 205); CHR$(203); STRING$(28, 205); CHR$(187); 230 PRINT CHR$(186); TAB(28); CHR$(186); TAB(8); 240 PRINT "TOTAL"; TAB(7); CHR$(186); TAB(28); CHR$(186); 250 PRINT CHR$(186); TAB(28); CHR$(199); 260 PRINT STRING$(20, 196); CHR$(182); TAB(28); CHR$(186); 270 FOR I = 10 TO 22 280 LOCATE I, 1 290 PRINT CHR$(186); TAB(28); CHR$(186); TAB(20); 300 PRINT CHR$(186);:LOCATE ,80:? CHR$(186); 310 NEXT I 315 PRINT CHR$(200); STRING$(28, 205); CHR$(202); 317 PRINT STRING$(20, 205); CHR$(202); STRING$(28, 205); CHR$(188); 320 PC$ = CHR$(19) + " PC WINS " + CHR$(19) 330 PLAYER$ = CHR$(19) + " YOU WIN " + CHR$(19) 340 LOCATE 10, 40: PRINT T 350 ' 355 '----------- MAIN STRATEGY LOOP ------------ 356 ' 360 FOR I = 10 TO 100 STEP 2 370 GOSUB 600 380 T = T - P: LOCATE I + 1, 40: PRINT T; 390 IF T = 0 THEN WIN$ = PC$: GOTO 480 400 C = T - ((M + 1) * INT((T - 1) / (M + 1)) + 1) 410 IF C = 0 THEN C = INT(1 + RND(M)) 420 IF T = 1 THEN C = 1 430 T = T - C 440 LOCATE I + 1, 58: PRINT "PC SUBTRACTS "; C; 450 LOCATE I + 2, 40: PRINT T; 460 IF T = 0 THEN WIN$ = PLAYER$: GOTO 480 470 NEXT I 475 ' 476 '--- ANNOUNCE WINNER, SOUND OFF, DISPLAY OPTIONS --- 477 ' 480 COLOR 0, 7: LOCATE 8, 31: PRINT STRING$(4, 32); WIN$; STRING$(5, 32) 482 FOR K = 1 TO 2 484 'FOR J = 3000 TO 400 STEP -300 486 'SOUND J, .5 488 NEXT K 490 COLOR 7, 0: LOCATE 25, 17 500 PRINT " >>> PRESS ANY KEY TO QUIT GAME <<< "; 520 530 X$ = UCASE$(INPUT$(1)) 570 580 CLS : LOCATE ,,1 : END 585 ' 586 '------------ PLAYER-INPUT SUBROUTINE ------------- 590 ' 600 X = 100 610 WHILE 1 620 LOCATE I, 7, 1: PRINT "YOU SUBTRACT? "; 625 P = VAL(INPUT$(1)): PRINT P: LOCATE , , 0 630 IF (P >= 1) AND (P <= M) AND (P <= T) THEN GOTO 690 640 IF M < T THEN X = M ELSE X = T END IF 650 LOCATE 25, 11: COLOR 15, 0 660 PRINT "IMPROPER INPUT. PLEASE ENTER AN INTERGER IN THE RANGE 1 -"; X; 670 COLOR 7, 0: LOCATE I, 7: PRINT STRING$(18, 32) 680 WEND 690 'IF X < 100 THEN KEY ON: KEY OFF 700 RETURN