JavaScript is required for this page.
##PASCAL,Roll balls down a pyramid of buckets, counting which bottom bucket each ball falls into. 10 REM REMARKABLE PROGRAM BY DAVE AHL 15 def fnround(v,d) = int(v * 10^d + 0.5)/10^d 20 print "PASCAL'S TRIANGLE":print :DIM B(11),Z(11) 30 INPUT "HOW MANY BALLS DO YOU WANT TO ROLL (MAX 5000)";M 40 INPUT "HOW MANY LEVELS (MAX 10)";K:print 50 K1=M/2^K 60 FOR I=1 TO 11: Z(I)=0: B(I)=0: NEXT: Z(1)=1 70 FOR I=1 TO K 80 Z2=1 90 FOR J=2 TO I+1 100 Z1=Z(J):Z(J)=Z2+Z(J):Z2=Z1 110 NEXT 120 NEXT 130 FOR N=1 TO M:T=0 140 FOR L=1 TO K 150 IF RND>.5 THEN T=T+1 160 NEXT 170 B(T+1)=B(T+1)+1 180 NEXT 190 print ,"NUMBER","OBSERVED" , "THEORETICAL" 200 print "POSITION","BALLS", "RATIO" , "RATIO":print 210 FOR L=1 TO K+1 220 print L,B(L),fnround(B(L)/K1,5), Z(L) 230 B(L)=0:NEXT:print : GOTO 30:END ##HORSES,Bet on a horse race. 10 DIM V(10),U(10),T(10),M(8),O(8),H(8),B(8),P(6) 15 def fnround(v,d) = int(v * 10^d + 0.5)/10^d 20 PRINT "HORSE RACE" 30 PRINT "EXAMPLE OF BET; 1,2,200,0 ." 40 PRINT : PRINT" SEVENTH - 1 MILE, 3 YR. OLDS POST 2:35" 50 PRINT 60 FOR I=1 TO 8 70 B(I)=I : GOSUB 820 80 READ O(I) : PRINT tab(18) O(I) ":1" 90 M(I)=(100+50*O(I)) / (O(I)+1) 100 NEXT 110 PRINT 120 PRINT"ENTER HORSE(1-8);TO WIN,PLACE,SHOW(1,2,3);AND THE WAGER." 130 PRINT "AND 0 FOR NO MORE BETTING OR 1 OR MORE BETTING." 140 LET S = 0 150 PRINT 160 LET S = S + 1 170 PRINT"BET NO. ";S; 180 INPUT T(S),U(S),V(S),Y1 190 LET T(S)=ABS(INT(T(S))) 200 IF T(S)>8 OR T(S)<1 THEN GOTO 230 210 LET U(S)=ABS(INT(U(S))) 220 IF U(S)>3 THEN GOTO 230 ELSE IF U(S)>0 THEN GOTO 250 230 PRINT"HORSE NO. OR WIN-PLACE-SHOW IN ERROR" : GOTO 170 240 IF V(S)<2 THEN GOTO 260 250 IF V(S)<=300 THEN GOTO 280 260 PRINT"BET MUST BE >$2 AND <$300, BET AGAIN"; 270 INPUT V(S) : GOTO 240 280 IF Y1 = 1 THEN GOTO 160 290 PRINT : PRINT" THEY'RE OFF AND RUNNING -" : PRINT 300 FOR I=1 TO 8:H(I)=0 :next 310 FOR K=1 TO 8 320 FOR J=1 TO 8:H(J)=H(J)+RND*M(J) :next 330 GOSUB 700 340 D = H(B(1)) 350 PRINT 360 GOSUB 970 370 GOSUB 780 380 input "Enter to continue...",II 390 NEXT 400 PRINT : PRINT : PRINT"$2 MUTUALS PAID:" 410 PRINT tab (13) "STRAIGHT" tab(25) "PLACE" tab(35) "SHOW" 415 PRINT tab (13) "--------" tab(25) "-----" tab(35) "----" 420 LET K = 0 430 FOR I = 1 TO 3 440 GOSUB 830 450 FOR J = I TO 3 460 L=2*I+J-3 470 LET P(L)=1.5+.01*INT((O(B(I))*4/(J*(J+1))+RND)*100) 480 PRINT TAB(5+10*J);fnround(P(L),2); 490 NEXT 500 PRINT 510 NEXT : rem I 520 PRINT : Q=0 530 FOR J=1 TO S 540 PRINT "BET NO. ";J 550 LET P=0 560 FOR I=1 TO 8:H(B(I))=I :next 570 IF U(J)< H(T(J)) THEN GOTO 610 580 P= .01*INT((V(J)*50)*P(U(J)+H(T(J))*2-3)) 590 PRINT "YOU COLLECT ";fnround(P,2);" ON "; 600 GOTO 640 610 IF H(T(J))>3 THEN GOTO 620 : PRINT "NEXT TIME, BUY A SHOW"; : GOTO 630 620 PRINT "TEAR UP YOUR"; 630 PRINT " TICKET ON "; 640 I=0 : B(0)=T(J) : GOSUB 830 : PRINT 650 Q=Q+P-V(J) 660 NEXT : rem J 670 IF Q<0 THEN GOTO 690 680 PRINT "YOUR TOTAL WINNINGS AMOUNT TO $";Q : END 690 PRINT "YOUR TOTAL LOSSES AMOUNT TO $";fnround(ABS(Q),2) : END 700 FOR I=8 TO 1 STEP -1 710 FOR J=2 TO I 720 ON SGN(H(B(J-1))-H(B(J)))+2 GOTO 740, 730, 750 730 IF RND>.5 THEN GOTO 750 740 Y1=B(J-1) : B(J-1)=B(J) : B(J)=Y1 750 NEXT : rem J 760 NEXT : rem I 770 RETURN 780 REM 790 PRINT "POS." tab(7) "HORSE" tab(18) "LENGTHS BEHIND" 800 PRINT "----" tab(7) "-----" tab(18) "--------------" 810 FOR I = 1 TO 8 820 PRINT I tab(5) 830 ON B(I) GOTO 910, 900, 890, 880, 870, 860, 850, 840 840 PRINT "COALTOWN "; : GOTO 920 850 PRINT "STYMIE "; : GOTO 920 860 PRINT "GALLANT FOX"; : GOTO 920 870 PRINT "SEABISCUIT "; : GOTO 920 880 PRINT "ASSAULT "; : GOTO 920 890 PRINT "WHIRLAWAY "; : GOTO 920 900 PRINT "CITATION "; : GOTO 920 910 PRINT "MAN O'WAR "; 920 IF K = 0 THEN GOTO 960 ELSE IF I > 1 THEN GOTO 940 930 PRINT : GOTO 950 940 PRINT tab(18) fnround(.1*INT(D-H(B(I))),4) 950 NEXT : rem I 960 RETURN 970 ON K GOTO 1000, 1010, 1020, 1030, 1040, 1050, 990, 980 980 PRINT " FINISH" : RETURN 990 PRINT " COMING DOWN THE STRETCH -" : RETURN 1000 PRINT " AS THEY BREAK FROM THE GATE -" : RETURN 1010 PRINT " AT THE 1/4 MILE POLE -" : RETURN 1020 PRINT " NEARING THE HALFWAY MARK -" : RETURN 1030 PRINT " MIDWAY IN THE RACE -" : RETURN 1040 PRINT " AT 5/8 OF A MILE -" : RETURN 1050 PRINT " ROUNDING THE TURN -" : RETURN 1060 DATA 3,4,5,8,9,11,20,30 1070 END ##Coin Flip,Count heads or tails on each fip of the coin. 10 for y = 1 to 10 20 let c = 0 30 for x = 1 to 50 40 let f = int(2*rnd) 50 if f = 1 then goto 90 60 print "T"; 70 goto 110 80 rem c counts the number of heads 90 let c = c+1 100 print "H"; 110 next : rem x 120 print 130 print "heads "; c; " out of 50 flips" 140 next : rem y 150 end ##BAGELS,A number guessing game. 5 PRINT TAB(33);"BAGELS":PRINT 10 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY":PRINT:PRINT 15 print "*** BAGLES NUMBER GUESSING GAME" 20 rem "*** ORIGINAL SOURCE UNKNOWN BUT SUSPECTED TO BE" 25 rem "*** LAWRENCE HALL OF SCIENCE, U.C. BERKELY 30 DIM A1(6),A(3),B(3) 40 Y=0:T=255 50 PRINT:PRINT:PRINT 70 INPUT "WOULD YOU LIKE THE RULES (0 for no)";A 90 IF A = 0 THEN goto 150 100 PRINT:PRINT "I AM THINKING OF A THREE-DIGIT NUMBER. TRY TO GUESS" 110 PRINT "MY NUMBER AND I WILL GIVE YOU CLUES AS FOLLOWS:" 120 PRINT " PICO - ONE DIGIT CORRECT BUT IN THE WRONG POSITION" 130 PRINT " FERMI - ONE DIGIT CORRECT AND IN THE RIGHT POSITION" 140 PRINT " BAGELS - NO DIGITS CORRECT" 150 FOR I=1 TO 3 160 A(I)=INT(10*RND) 165 IF I-1=0 THEN goto 200 170 FOR J=1 TO I-1 180 IF A(I)=A(J) THEN goto 160 190 NEXT : REM J 200 NEXT : REM I 210 PRINT:PRINT "O.K. I HAVE A NUMBER IN MIND." 220 FOR I=1 TO 20 230 PRINT "GUESS #";I, 240 INPUT A 245 IF 12 > A OR A > 987 THEN goto 630 250 FOR Z=3 TO 1 step -1:B(Z)= A mod 10: A = int (A / 10):NEXT : REM Z 320 IF B(1)=B(2) THEN goto 650 330 IF B(2)=B(3) THEN goto 650 340 IF B(3)=B(1) THEN goto 650 350 C=0:D=0 360 FOR J=1 TO 2 370 IF A(J)<>B(J+1) THEN goto 390 380 C=C+1 390 IF A(J+1)<>B(J) THEN goto 410 400 C=C+1 410 NEXT : REM J 420 IF A(1)<>B(3) THEN goto 440 430 C=C+1 440 IF A(3)<>B(1) THEN goto 460 450 C=C+1 460 FOR J=1 TO 3 470 IF A(J)<>B(J) THEN goto 490 480 D=D+1 490 NEXT : REM J 500 IF D=3 THEN goto 680 505 IF C=0 THEN goto 545 520 FOR J=1 TO C 530 PRINT "PICO "; 540 NEXT : REM J 545 IF D=0 THEN goto 580 550 FOR J=1 TO D 560 PRINT "FERMI "; 570 NEXT : REM J 580 IF C+D<>0 THEN goto 600 590 PRINT "BAGELS"; 600 PRINT 605 NEXT : REM I 610 PRINT "OH WELL." 615 PRINT "THAT'S TWNETY GUESSES. MY NUMBER WAS";100*A(1)+10*A(2)+A(3) 620 GOTO 700 630 PRINT "TRY GUESSING A THREE-DIGIT NUMBER.":GOTO 230 650 PRINT "OH, I FORGOT TO TELL YOU THAT THE NUMBER I HAVE IN MIND" 660 PRINT "HAS NO TWO DIGITS THE SAME.":GOTO 230 680 PRINT "YOU GOT IT!!!":PRINT 690 Y=Y+1 700 INPUT "PLAY AGAIN (0 for no)";A 720 IF A <> 0 THEN goto 150 730 IF Y=0 THEN goto 750 740 PRINT:PRINT "A ";Y;" POINT BAGELS BUFF!!" 750 PRINT "HOPE YOU HAD FUN. BYE." ##Buzzwd,Spice up your next report with these gems! 10 PRINT"THIS COMPUTER DEMONSTRATION IS A NEW AID FOR" 20 PRINT"PREPARING SPEECHES AND BRIEFINGS. IT'S A BUZZWORD" 30 PRINT"GENERATOR WHICH PROVIDES YOU WITH A SET OF 3 HIGHLY" 40 PRINT"ACCEPTABLE WORDS TO WORK INTO YOUR MATERIAL. THE WORDS" 50 PRINT"DON'T ACTUALLY MEAN ANYTHING, BUT THEY SOUND GREAT." 60 PRINT 70 PRINT"THE PROCEDURE:" 80 PRINT" THINK OF A NUMBER BETWEEN 1 AND 1000. " 90 PRINT" ENTER IT AFTER THE '?' YOUR" 100 PRINT" BUZZWORD WILL BE PRINTED OUT. " 110 PRINT" ENTERING 0 STOPS THIS PROGRAM." 120 INPUT "WHAT IS YOUR NUMBER (1 TO 1000):";N 130 IF N=0 THEN goto 510 140 PRINT:N=N-1 150 ON N MOD 10 + 1 GOSUB 210, 220, 230, 240, 250, 260, 270, 280, 290, 300 160 N=INT(N/10) 170 ON N MOD 10 + 1 GOSUB 310, 320, 330, 340, 350, 360, 370, 380, 390, 400 180 N=INT(N/10) 190 ON N MOD 10 + 1 GOSUB 410, 420, 430, 440, 450, 460, 470, 480, 490, 500 200 GOTO 120 210 PRINT" INTEGRATED";:RETURN 220 PRINT" TOTAL";:RETURN 230 PRINT" SYSTEMATIZED";:RETURN 240 PRINT" PARALLEL";:RETURN 250 PRINT" FUNCTIONAL";:RETURN 260 PRINT" RESPONSIVE";:RETURN 270 PRINT" OPTIMAL";:RETURN 280 PRINT" SYNCHRONIZED";:RETURN 290 PRINT" COMPATIBLE";:RETURN 300 PRINT" BALANCED";:RETURN 310 PRINT" MANAGEMENT";:RETURN 320 PRINT" ORGANIZATIONAL";:RETURN 330 PRINT" MONITORED";:RETURN 340 PRINT" RECIPROCAL";:RETURN 350 PRINT" DIGITAL";:RETURN 360 PRINT" LOGISTICAL";:RETURN 370 PRINT" TRANSITIONAL";:RETURN 380 PRINT" INCREMENTAL";:RETURN 390 PRINT" THIRD-GENERATION";:RETURN 400 PRINT" POLICY";:RETURN 410 PRINT" OPTIONS":RETURN 420 PRINT" FLEXIBILITY":RETURN 430 PRINT" CAPABILITY":RETURN 440 PRINT" MOBILITY":RETURN 450 PRINT" PROGRAMMING":RETURN 460 PRINT" CONCEPT":RETURN 470 PRINT" TIME-PHASE":RETURN 480 PRINT" PROJECTION":RETURN 490 PRINT" HARDWARE":RETURN 500 PRINT" CONTINGENCY":RETURN 510 PRINT "GOODBYE FOR NOW! " 520 PRINT:PRINT:PRINT 530 END ##BUG,Build a bug head to head with the computer. 10 cls:PRINT TAB(34);"BUG":PRINT 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT 40 REM 1 2 3 4 5 6 50 REM F,D, F,D F,D F,D F,D F,D 60 data 1,0, 1,1, 1,2, 2,3, 1,1, 6,1:FOR I=1 TO 6:READ F(I),D(I):TF=TF+F(I):NEXT 70 PRINT "THE GAME BUG IS LIKE THE GAME COOTI." 80 PRINT "I HOPE YOU ENJOY THIS GAME." 90 PRINT 100 INPUT "DO YOU WANT INSTRUCTIONS (0 for no)";Z 110 IF Z = 0 THEN GOTO 290 120 cls:PRINT " The object of BUG is to finish your Bug before I finish" 130 PRINT "mine. Each number stands for a part of the bug body." 140 PRINT "I will roll the die for you and tell you what the number" 150 PRINT "stands for, and if you can get the part I will give it" 160 PRINT "to you. The same will happen on my turn." 170 PRINT 180 PRINT " The numbers stand for parts as follows:":PRINT 190 PRINT "NUMBER","PART","NUMBER OF PART NEEDED" 200 PRINT "------","----","----------------------" 210 PRINT TAB(3);"1","BODY",TAB(38);"1" 220 PRINT TAB(3);"2","NECK",TAB(38);"1" 230 PRINT TAB(3);"3","HEAD",TAB(38);"1" 240 PRINT TAB(3);"4","FEELERS",TAB(38);"2" 250 PRINT TAB(3);"5","TAIL",TAB(38);"1" 260 PRINT TAB(3);"6","LEGS",TAB(38);"6" 270 PRINT 280 INPUT "Enter 'RETURN' to start the game:",Z 290 FOR I=1 TO 6:B(I,0)=0:B(I,1)=0:NEXT 300 GOSUB 500:GOTO 1400 500 REM#500 BUG PRINTING 510 cls:PRINT:PRINT "***** YOUR BUG *****"; 520 PRINT TAB(40) "***** MY BUG *****" 600 REM#600 FEELERS 610 FOR Q=1 TO 4 620 PRINT TAB(11):I=0:GOSUB 1900:PRINT TAB(50):I=1:GOSUB 1900 630 NEXT 900 REM#900 HEAD 910 FOR Q=1 TO 6 920 PRINT TAB(1):I=0:GOSUB 2300:PRINT TAB(40):I=1:GOSUB 2300 930 NEXT 1000 REM#1000 NECK 1010 FOR Q=1 TO 2 1020 PRINT TAB(1):I=0:GOSUB 2000:PRINT TAB(40):I=1:GOSUB 2000 1030 NEXT 1100 REM#1100 BODY 1110 FOR Q=1 TO 5 1120 PRINT TAB(1):I=0:GOSUB 2100:PRINT TAB(40):I=1:GOSUB 2100 1130 NEXT 1200 REM#1200 LEGS 1210 FOR Q=1 TO 2 1220 PRINT TAB(6):I=0:GOSUB 2400:PRINT TAB(45):I=1:GOSUB 2400 1230 NEXT 1240 PRINT TAB(1) 1250 RETURN 1400 REM#1400 GAME LOGIC 1410 PRINT TAB(1):INPUT "Hit 'Enter' to roll die: ";K 1420 IF K=-1234 THEN PRINT TAB(1):GOSUB 1540:INPUT "BODY PART TO ADD";K:K=(ABS(K)-1) MOD 6 + 1:GOTO 1440 1430 GOSUB 3100 1440 IF B(K,S)<>F(K) THEN GOTO 1470 ELSE GOSUB 1560: PRINT "ALREADY HAVE "; 1450 IF B(K,S)=1 THEN PRINT "A ";: GOSUB 3000 ELSE PRINT B(K,S);" ";:GOSUB 3000:PRINT "S "; 1460 GOTO 1510 1470 IF B(D(K),S)<>F(D(K)) THEN GOSUB 1560: PRINT "DON'T HAVE A ";:K=D(K):GOSUB 3000: GOTO 1510 1480 B(K,S)=B(K,S)+1:T(S)=T(S)+1:IF T(S)=TF THEN GOTO 1520 1490 GOSUB 500 :IF S=0 THEN PRINT "I NOW GIVE YOU A "; ELSE PRINT "I NOW GET A "; 1500 GOSUB 3000 1510 S=1-S: GOTO 1400 1520 GOSUB 500:GOSUB 1540: PRINT "BUG IS COMPLETE! BYE-BYE!" 1530 END 1540 IF S=0 THEN PRINT "YOUR "; ELSE PRINT "MY "; 1550 RETURN 1560 GOSUB 500:IF S=0 THEN PRINT "YOU "; ELSE PRINT "I "; 1570 RETURN 1900 REM#1900 FEELERS 1910 FOR J=1 TO B(4,I) 1920 IF I=0 THEN PRINT "A "; ELSE PRINT "F "; 1930 NEXT:RETURN 2000 REM#2000 NECK 2010 IF B(2,I)>0 THEN PRINT " N N"; 2020 RETURN 2100 REM#2100 BODY 2110 IF B(1,I)>0 THEN ON Q GOTO 2130, 2150, 2150, 2140, 2130 2120 RETURN 2130 PRINT " BBBBBBBBBBBB";: RETURN 2140 IF B(5,I)>0 THEN PRINT "TTTTTB B";:RETURN 2150 PRINT " B B";: RETURN 2300 REM#2300 HEAD 2310 IF B(3,I)>0 THEN ON Q GOTO 2330, 2340, 2350, 2340, 2360, 2330 2320 RETURN 2330 PRINT " HHHHHHH";:RETURN 2340 PRINT " H H";:RETURN 2350 PRINT " H O O H";:RETURN 2360 PRINT " H V H";:RETURN 2400 REM#2400 LEGS 2410 FOR J=1 TO B(6,I) 2420 PRINT " L"; 2430 NEXT 2440 RETURN 3000 REM#3000 BODY PART NAMES 3010 ON K GOTO 3020, 3030, 3040, 3050, 3060, 3070: RETURN 3020 PRINT "BODY";: RETURN 3030 PRINT "NECK";: RETURN 3040 PRINT "HEAD";: RETURN 3050 PRINT "FEELER";: RETURN 3060 PRINT "TAIL";: RETURN 3070 PRINT "LEG";: RETURN 3100 REM#3100 NO MORE THAN ONE CONSECUTIVE MISS 3110 K=INT(RND*6)+1: 3120 IF B(K,S)<>F(K) AND B(D(K),S)=F(D(K)) THEN M(S)=0:RETURN 3130 IF M(0)+M(1)>0 THEN GOTO 3110 3140 M(S)=M(S)+1 3150 RETURN ##Tank,Run for your life from all the crazy tanks! 10 rem *********************************************************************** 20 rem * * 30 rem * Tank game, based on my 1978 original [sam] * 40 rem * * 50 rem * Tank, sometimes referred to as "fox and hounds", consists of a * 60 rem * player piece pitted against a number of enemy pieces that advance * 70 rem * mindlessly in his direction. * 80 rem * * 90 rem *********************************************************************** 100 cls:print 110 print "******************************************************************************" 120 print 130 print "TANK GAME" 140 print 150 print "******************************************************************************" 160 print 170 print "You are playing against several tanks on a field. ""*"" marks the edges of the" 180 print "field, ""+"" mark enemy tanks, ""@"" marks your position, and ""#"" mark the" 190 print "position of tank traps. You can move in any direction on your turn, including" 200 print "the diagonals. After you move, each of the enemy tanks will also move, in your" 210 print "direction. If they hit you, you lose. If they hit a tank trap, they are out" 220 print "of the game. If all the enemy tanks die in this fashion, you win the game." 225 print:input "Enter to continue...",a 230 xlen = 15 : rem 30: rem estabish playing field demensions 240 ylen = 10 : rem 20 250 numtanks = int(xlen*ylen*0.05): rem find 2 of board as tanks 260 numtraps = int(xlen*ylen*0.07): rem find 10 of board as traps 270 dim board(xlen, ylen): rem playing field 280 rem establish playing field tolkens 290 space = 1: rem empty space 300 fence = 2: rem border 310 trap = 3: rem tank trap 320 tank = 4: rem enemy tank 330 tankm = 5: rem moved enemy tank 340 player = 6: rem player tank 350 rem set up the board 360 for x = 1 to xlen: for y = 1 to ylen: board(x, y) = space: next: next 370 for x = 1 to xlen: board(x, 1) = fence: next 380 for x = 1 to xlen: board(x, ylen) = fence: next 390 for y = 1 to ylen: board(1, y) = fence: next 400 for y = 1 to ylen: board(xlen, y) = fence: next 410 rem place tank traps at random 420 for c = 1 to numtraps 430 x = int(rnd*xlen+1): y = int(rnd*ylen+1): if board(x, y) <> space then goto 430 440 board(x, y) = trap 450 next 460 rem place enemy tanks at random 470 for c = 1 to numtanks 480 x = int(rnd*xlen+1): y = int(rnd*ylen+1): if board(x, y) <> space then goto 480 490 board(x, y) = tank 500 next 510 rem place player 520 x = int(rnd*xlen+1): y = int(rnd*ylen+1): if board(x, y) <> space then goto 520 530 board(x, y) = player: playerx = x: playery = y 540 rem print out board 550 cls 560 for y = 1 to ylen 570 for x = 1 to xlen: tankchar= board(x, y): gosub 1210: next 580 print 590 next 610 rem 620 rem player move 630 rem 640 print "8 1 2" 650 print "7 0 3" 660 print "6 5 4 Where 0 means stay put, 2 means up and right, etc." 680 cll:input "move: ", a 690 if (a < 0) or (a > 8) then goto 640 700 rem find potential new player location 710 pplayerx = playerx 720 pplayery = playery 730 if (a = 8) or (a = 1) or (a = 2) then pplayery = pplayery-1: rem move up 740 if (a = 6) or (a = 5) or (a = 4) then pplayery = pplayery+1: rem move down 750 if (a = 8) or (a = 7) or (a = 6) then pplayerx = pplayerx-1: rem move left 760 if (a = 2) or (a = 3) or (a = 4) then pplayerx = pplayerx+1: rem move right 770 rem check occupied 780 if (board(pplayerx, pplayery) <> space) and (board(pplayerx, pplayery) <> player) then goto 680 790 board(playerx, playery) = space: rem erase old position 800 playerx = pplayerx: rem set new position 810 playery = pplayery 820 board(playerx, playery) = player 830 rem 840 rem enemy move 850 rem 860 for x = 1 to xlen 870 for y = 1 to ylen 880 if board(x, y) <> tank then goto 1050 890 ptankx = x: rem find potential tank location 900 ptanky = y 910 if playerx < ptankx then ptankx = ptankx-1 920 if playerx > ptankx then ptankx = ptankx+1 930 if playery < ptanky then ptanky = ptanky-1 940 if playery > ptanky then ptanky = ptanky+1 950 if board(ptankx, ptanky) <> player then goto 1000 960 print "Killed by enemy tank !!!" 970 input "Play again (0 for no)? ", a 980 if a then goto 360 990 end 1000 if (board(ptankx, ptanky) <> space) and (board(ptankx, ptanky) <> trap) then goto 1050 1010 board(x, y) = space: rem erase old position 1020 rem tank is dead 1030 if board(ptankx, ptanky) = trap then goto 1050 1040 board(ptankx, ptanky) = tankm: rem place new 1050 next 1060 next 1070 rem now convert moved tanks to real tanks 1080 for x = 1 to xlen: for y = 1 to ylen 1090 if board(x, y) = tankm then board(x, y) = tank 1100 next : next 1110 rem count remaining tanks 1120 tanks = 0 1130 for x = 1 to xlen: for y = 1 to ylen 1140 if board(x, y) = tank then tanks = tanks+1 1150 next : next 1160 if tanks > 0 then goto 550: rem go print board 1170 print "You killed them all !!!" 1180 input "Play again (0 for no)? ", a 1190 if a then goto 360 1200 end 1210 on tankchar goto 1230, 1240, 1250, 1260, 1270, 1280 1220 return 1230 print " ";:return 1240 print "*";:return 1250 print "#";:return 1260 print "+";:return 1270 print "?";:return 1280 print "@";:return ##Train,TIME - SPEED DISTANCE EXERCISE 5 def fnround(v,d) = int(v * 10^d + 0.5)/10^d 10 cls:PRINT: PRINT TAB(33);"TRAIN":PRINT 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT: PRINT: PRINT 40 PRINT "TIME - SPEED DISTANCE EXERCISE": PRINT 50 C=INT(25*RND)+40 60 D=INT(15*RND)+5 70 T=INT(19*RND)+20 80 PRINT " A CAR TRAVELING ";C;" MPH CAN MAKE A CERTAIN TRIP IN" 90 PRINT D;" HOURS LESS THAN A TRAIN TRAVELING AT "; T;" MPH." 100 PRINT 110 PRINT "HOW LONG DOES THE TRIP TAKE BY CAR"; 120 INPUT A 130 V=fnround(D*T/(C-T),2) 140 E=INT(ABS((V-A)*100/A)+.5) 150 IF E>5 THEN goto 180 160 PRINT "GOOD! ANSWER WITHIN ";E;" PERCENT." 170 GOTO 190 180 PRINT "SORRY. YOU WERE OFF BY ";E;" PERCENT." 190 PRINT "CORRECT ANSWER IS ";V;" HOURS." 200 PRINT 210 PRINT "ANOTHER PROBLEM (0 for no)"; 220 INPUT A 230 IF A THEN GOTO 10 ##Taxman,Fight City Hall! Attempt to beat the Taxman by collecting a higher score! 100 gosub 1000 110 low=15:high=50 200 rem#200 Instructions 210 print "Taxman is played with a list of integers. You will get to choose how many are" 220 print "in the initial list, from " low " to " high ". After that, you get to pick one" 230 print "to be added to your score. I -- the Taxman -- will get all integers which are" 240 print "divisible by your number, or multiples of it. Game proceeds until all numbers" 250 print "are claimed. Winner is the player with the highest score." 260 print:print "Good luck!" 270 print 300 rem#300 Request size of list. 310 input "Starting number of integers in the list: ",N:N=int(N) 320 if N < low or high < N then print "Your choice must range from "; low; " to "; high; ".":goto 300 350 rem#350 Initialize game state. 360 US=0:CO=0:for I=1 to high : L(i)=1 : next 370 gosub 1000 380 print "Starting list -------": goto 450 400 rem#400 Print scores 410 gosub 1000:print "Taxman collects -----";:MK=1:gosub 1100 420 gosub 1300:if res=0 then goto 600: rem End of game check 430 print tab(1):print:print : print "Your score: " US tab(20) "Taxman Score: " CO 440 print: print "Updated list --------" 450 rem#450 Print the list 490 gosub 1400 500 rem#500 Ask for player's move 510 input "Please choose a number: ",A 520 if A < 1 or N < A then print "Please limit your input from 1 to " N;: goto 500 530 if L(A)=0 then print "You number must be in the list.": goto 500 540 MK=0:gosub 1100:if res then US=US+A: L(A)=0: goto 400 550 gosub 1000: print "Whoa! The number you want has no divisors or multiples still in the list!" 560 print "So, Taxman gets " A "!":CO=CO+A: L(A)=0 570 goto 420 600 rem#600 Compute final score 610 J=5:print:print "Taxman collects remainder of list..." 620 for i=1 to N 630 if L(i) then gosub 1200 640 next:print tab(1):print 650 if US > CO then print "You win with ";US;" to ";CO: goto 670 660 print "Too bad! Taxman wins ";CO;" to your ";US;"! Better luck next time!" 670 input "Play again? (0 for yes)",A 680 if a=0 then goto 300 1000 rem#1000 1010 cls: print tab(36) "Taxman":print:print:return 1100 rem#1100 Find divisors and multiples 1110 res=0:J=5 1120 for i=1 to int(N/2) 1130 if L(i) <> 0 and int(A / i) = A / i then if mk then gosub 1200 else res=1:return 1140 next 1150 for i=A * 2 to N step A 1160 if L(i) <> 0 then if mk then gosub 1200 else res=1:return 1170 next 1180 return 1200 rem#1200 Print computer's take. 1210 print tab(J) i; 1220 L(i)=0:CO=CO+i 1230 J=J+4 :if J > 60 then J=5 1240 return 1300 rem#1300 Check for more game play. 1310 MK=0 1320 for A=1 to N: if L(A) then gosub 1100 1330 next 1340 return 1400 rem#1400 Show the list 1410 J = 5 1420 for i=1 to N 1430 if L(i) then print tab(J) i; 1440 J= J+ 4:if J > 60 then J = 5 1450 next 1460 print tab(1):print 1470 return ##Amazing,Generates mazes. 5 cls 10 PRINT TAB(28); "AMAZING PROGRAM" 12 PRINT : PRINT 20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT : PRINT : PRINT 40 PRINT " THIS PROGRAM GENERATES MAZES OF DIMENSIONS YOU SPECIFY." 42 PRINT "EVERY MAZE IS DIFFERENT, AND HAS ONLY ONE WAY THROUGH. THE" 44 PRINT "MAZE APPEARS ON THE TERMINAL CRT SCREEN. IF YOU WANT A PRINTED" 46 PRINT "MAZE, RUN THE 'AMAZINGP' PROGRAM INSTEAD OF THIS ONE.": PRINT : PRINT 100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH (TWO NUMBERS SEPARATED BY A COMMA)"; H, V 101 IF H > 26 OR V > 10 THEN PRINT : PRINT "MAZE WILL NOT FIT ON SCREEN. MAXIMUM WIDTH IS 25;": PRINT "MAXIMUM LENGTH IS 10. TRY AGAIN.": PRINT : PRINT : GOTO 100 102 IF H <> 1 AND V <> 1 THEN GOTO 110 104 PRINT : PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN.": PRINT : PRINT : GOTO 100 110 DIM W(H, V), V(H, V) 120 PRINT 130 PRINT 140 PRINT 150 PRINT 160 Q = 0: Z = 0: X = INT(RND * H + 1) 165 FOR I = 1 TO H 170 IF I = X THEN PRINT ". "; ELSE PRINT ".--"; 180 NEXT 190 PRINT "." 195 C = 1: W(X, 1) = C: C = C + 1 200 R = X: S = 1: GOTO 260 210 IF R <> H THEN R = R + 1 :GOTO 250 220 IF S <> V THEN R = 1: S = S + 1 ELSE R = 1: S = 1 250 IF W(R, S) = 0 THEN GOTO 210 260 IF R - 1 = 0 THEN GOTO 530 265 IF W(R - 1, S) <> 0 THEN GOTO 530 270 IF S - 1 = 0 THEN GOTO 390 280 IF W(R, S - 1) <> 0 THEN GOTO 390 290 IF R = H THEN GOTO 330 300 IF W(R + 1, S) <> 0 THEN GOTO 330 310 X = INT(RND * 3 + 1) 320 ON X GOTO 790, 820, 860 330 IF S <> V THEN GOTO 340 334 IF Z = 1 THEN GOTO 370 338 Q = 1: GOTO 350 340 IF W(R, S + 1) <> 0 THEN GOTO 370 350 X = INT(RND * 3 + 1) 360 ON X GOTO 790, 820, 910 370 X = INT(RND * 2 + 1) 380 ON X GOTO 790, 820 390 IF R = H THEN GOTO 470 400 IF W(R + 1, S) <> 0 THEN GOTO 470 405 IF S <> V THEN GOTO 420 410 IF Z = 1 THEN GOTO 450 415 Q = 1: GOTO 430 420 IF W(R, S + 1) <> 0 THEN GOTO 450 430 X = INT(RND * 3 + 1) 440 ON X GOTO 790, 860, 910 450 X = INT(RND * 2 + 1) 460 ON X GOTO 790, 860 470 IF S <> V THEN GOTO 490 480 IF Z = 1 THEN GOTO 520 485 Q = 1: GOTO 500 490 IF W(R, S + 1) <> 0 THEN GOTO 520 500 X = INT(RND * 2 + 1) 510 ON X GOTO 790, 910 520 GOTO 790 530 IF S - 1 = 0 THEN GOTO 670 540 IF W(R, S - 1) <> 0 THEN GOTO 670 545 IF R = H THEN GOTO 610 547 IF W(R + 1, S) <> 0 THEN GOTO 610 550 IF S <> V THEN GOTO 560 552 IF Z = 1 THEN GOTO 590 554 Q = 1: GOTO 570 560 IF W(R, S + 1) <> 0 THEN GOTO 590 570 X = INT(RND * 3 + 1) 580 ON X GOTO 820, 860, 910 590 X = INT(RND * 2 + 1) 600 ON X GOTO 820, 860 610 IF S <> V THEN GOTO 630 620 IF Z = 1 THEN GOTO 660 625 Q = 1: GOTO 640 630 IF W(R, S + 1) <> 0 THEN GOTO 660 640 X = INT(RND * 2 + 1) 650 ON X GOTO 820, 910 660 GOTO 820 670 IF R = H THEN GOTO 740 680 IF W(R + 1, S) <> 0 THEN GOTO 740 685 IF S <> V THEN GOTO 700 690 IF Z = 1 THEN GOTO 730 695 Q = 1: GOTO 830 700 IF W(R, S + 1) <> 0 THEN GOTO 730 710 X = INT(RND * 2 + 1) 720 ON X GOTO 860, 910 730 GOTO 860 740 IF S <> V THEN GOTO 760 750 IF Z = 1 THEN GOTO 780 755 Q = 1: GOTO 770 760 IF W(R, S + 1) <> 0 THEN GOTO 780 770 GOTO 910 780 GOTO 1000 790 W(R - 1, S) = C 800 C = C + 1: V(R - 1, S) = 2: R = R - 1 810 IF C = H * V + 1 THEN GOTO 1010 815 Q = 0: GOTO 260 820 W(R, S - 1) = C 830 C = C + 1 840 V(R, S - 1) = 1: S = S - 1: IF C = H * V + 1 THEN GOTO 1010 850 Q = 0: GOTO 260 860 W(R + 1, S) = C 870 C = C + 1: IF V(R, S) = 0 THEN GOTO 880 875 V(R, S) = 3: GOTO 890 880 V(R, S) = 2 890 R = R + 1 900 IF C = H * V + 1 THEN GOTO 1010 905 GOTO 530 910 IF Q = 1 THEN GOTO 960 920 W(R, S + 1) = C: C = C + 1: IF V(R, S) = 0 THEN GOTO 940 930 V(R, S) = 3: GOTO 950 940 V(R, S) = 1 950 S = S + 1: IF C = H * V + 1 THEN GOTO 1010 955 GOTO 260 960 Z = 1 970 IF V(R, S) = 0 THEN GOTO 980 975 V(R, S) = 3: Q = 0: GOTO 1000 980 V(R, S) = 1: Q = 0: R = 1: S = 1: GOTO 250 1000 GOTO 210 1010 FOR J = 1 TO V 1011 PRINT "I"; 1012 FOR I = 1 TO H 1013 IF V(I, J) < 2 THEN GOTO 1030 1020 PRINT " "; 1021 GOTO 1040 1030 PRINT " I"; 1040 NEXT 1041 PRINT 1043 FOR I = 1 TO H 1045 IF V(I, J) = 0 THEN GOTO 1060 1050 IF V(I, J) = 2 THEN GOTO 1060 1051 PRINT ": "; 1052 GOTO 1070 1060 PRINT ":--"; 1070 NEXT 1071 PRINT "." 1072 NEXT 1073 PRINT : INPUT "Enter to continue...", a ##Change,Compute change in standard denominations for purchases up to $100 10 CLS:PRINT TAB(33);"CHANGE":PRINT 20 def fnround(v,d) = int(v * 10^d + 0.5)/10^d 30 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 40 PRINT:PRINT:PRINT 50 PRINT "I, YOUR FRIENDLY MICROCOMPUTER, WILL DETERMINE" 60 PRINT "THE CORRECT CHANGE FOR ITEMS COSTING UP TO $100." 70 PRINT:PRINT 80 PRINT "COST OF ITEM";:INPUT A:PRINT "AMOUNT OF PAYMENT";:INPUT P 90 C=P-A:M=C:IF C<>0 THEN GOTO 120 100 PRINT "CORRECT AMOUNT, THANK YOU." 110 GOTO 350 120 IF C>0 THEN GOTO 150 130 PRINT "SORRY, YOU HAVE SHORT-CHANGED ME $";A-P 140 GOTO 80 150 PRINT "YOUR CHANGE, $";fnround(C,2) 160 D=INT(C/10) 170 IF D<>0 THEN PRINT D;" TEN DOLLAR BILL(S)" 180 C=M-(D*10): E=INT(C/5) 190 IF E<>0 THEN PRINT E;" FIVE DOLLARS BILL(S)" 200 C=M-(D*10+E*5):F=INT(C) 210 IF F<>0 THEN PRINT F;" ONE DOLLAR BILL(S)" 220 C=M-(D*10+E*5+F): C=C*100 230 N=C: G=INT(C/50) 240 IF G<>0 THEN PRINT G;" ONE HALF DOLLAR(S)" 250 C=N-(G*50): H=INT(C/25) 260 IF H<>0 THEN PRINT H;" QUARTER(S)" 270 C=N-(G*50+H*25):I=INT(C/10) 280 IF I<>0 THEN PRINT I;" DIME(S)" 290 C=N-(G*50+H*25+I*10):J=INT(C/5) 300 IF J<>0 THEN PRINT J;" NICKEL(S)" 310 C=N-(G*50+H*25+I*10+J*5): K=INT(C+.5) 320 IF K<>0 THEN PRINT K;" PENNY(S)" 330 PRINT "THANK YOU, COME AGAIN." 340 PRINT:PRINT 350 INPUT "AGAIN? (0 for Yes)";ANS:PRINT 360 IF ANS=0 THEN GOTO 80 ##Checkers,Play the board game of Checkers against the computer. 10 CLS:PRINT TAB(32); "CHECKERS": PRINT 20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT : PRINT : PRINT 40 PRINT "THIS IS THE GAME OF CHECKERS. THE COMPUTER IS X," 50 PRINT "AND YOU ARE O. THE COMPUTER WILL MOVE FIRST." 60 PRINT "SQUARES ARE REFERRED TO BY A COORDINATE SYSTEM." 70 PRINT 80 PRINT "(0,0) IS THE LOWER LEFT CORNER" 90 PRINT "(0,7) IS THE UPPER LEFT CORNER" 100 PRINT "(7,0) IS THE LOWER RIGHT CORNER" 110 PRINT "(7,7) IS THE UPPER RIGHT CORNER" 120 PRINT 130 PRINT "THE COMPUTER WILL TYPE '+TO' WHEN YOU HAVE ANOTHER" 140 PRINT "JUMP. TYPE TWO NEGATIVE NUMBERS IF YOU CANNOT JUMP." 150 PRINT : PRINT : PRINT 160 INPUT "ENTER 'RETURN' TO START THE GAME."; XX 170 CLS: DIM R(4), S(7, 7) 180 G = -1: R(0) = -99 190 DATA 1,0,1,0,0,0,-1,0,0,1,0,0,0,-1,0,-1,15 200 FOR X = 0 TO 7: FOR Y = 0 TO 7 210 READ j: IF j = 15 THEN RESTORE: READ j 220 S(X, Y) = j 230 NEXT Y, X 240 FOR X = 0 TO 7: FOR Y = 0 TO 7: IF S(X, Y) > -1 THEN 270 250 IF S(X, Y) = -1 THEN FOR a = -1 TO 1 STEP 2: B = G: GOSUB 280: NEXT a 260 IF S(X, Y) = -2 THEN FOR a = -1 TO 1 STEP 2: FOR B = -1 TO 1 STEP 2: GOSUB 280: NEXT B, a 270 NEXT Y, X: GOTO 440 280 U = X + a: V = Y + B: IF U < 0 OR U > 7 OR V < 0 OR V > 7 THEN 330 290 IF S(U, V) = 0 THEN GOSUB 340: GOTO 330 300 IF S(U, V) < 0 THEN 330 310 U = U + a: V = V + B: IF U < 0 OR V < 0 OR U > 7 OR V > 7 THEN 330 320 IF S(U, V) = 0 THEN GOSUB 340 330 RETURN 340 IF V = 0 AND S(X, Y) = -1 THEN Q = Q + 2 350 IF ABS(Y - V) = 2 THEN Q = Q + 5 360 IF Y = 7 THEN Q = Q - 2 370 IF U = 0 OR U = 7 THEN Q = Q + 1 380 FOR C = -1 TO 1 STEP 2: IF U + C < 0 OR U + C > 7 OR V + G < 0 THEN 420 390 IF S(U + C, V + G) < 0 THEN Q = Q + 1: GOTO 420 400 IF U - C < 0 OR U - C > 7 OR V - G > 7 THEN 420 410 IF S(U + C, V + G) > 0 AND (S(U - C, V - G) = 0 OR (U - C = X AND V - G = Y)) THEN Q = Q - 2 420 NEXT C: IF Q > R(0) THEN R(0) = Q: R(1) = X: R(2) = Y: R(3) = U: R(4) = V 430 Q = 0: RETURN 440 IF R(0) = -99 THEN 870 450 CLS:PRINT "FROM ("; R(1) "," R(2); ") TO ("; R(3)"," R(4); ")"; : R(0) = -99 460 IF R(4) = 0 THEN S(R(1), R(2)) = -2 470 S(R(3), R(4)) = S(R(1), R(2)) 480 S(R(1), R(2)) = 0: IF ABS(R(1) - R(3)) <> 2 THEN 570 490 S((R(1) + R(3)) / 2, (R(2) + R(4)) / 2) = 0 500 X = R(3): Y = R(4): IF S(X, Y) = -1 THEN B = -2: FOR a = -2 TO 2 STEP 4: GOSUB 540: NEXT a 510 IF S(X, Y) = -2 THEN FOR a = -2 TO 2 STEP 4: FOR B = -2 TO 2 STEP 4: GOSUB 540: NEXT B, a 520 IF R(0) <> -99 THEN PRINT "TO"; R(3); R(4); : R(0) = -99: GOTO 460 530 GOTO 570 540 U = X + a: V = Y + B: IF U < 0 OR U > 7 OR V < 0 OR V > 7 THEN 560 550 IF S(U, V) = 0 AND S(X + a / 2, Y + B / 2) > 0 THEN GOSUB 340 560 RETURN 570 PRINT : PRINT "(0,7)" TAB(45) "(7,7)" 580 PRINT : FOR Y = 7 TO 0 STEP -1: PRINT Y")";: FOR X = 0 TO 7: PRINT TAB(5 * X + 8); 590 IF S(X, Y) = 0 THEN PRINT "."; 600 IF S(X, Y) = 1 THEN PRINT "O"; 610 IF S(X, Y) = -1 THEN PRINT "X"; 620 IF S(X, Y) = -2 THEN PRINT "X*"; 630 IF S(X, Y) = 2 THEN PRINT "O*"; 640 NEXT X: PRINT " ": PRINT : NEXT Y: PRINT "(0,0)"; 650 FOR X=0 TO 7: PRINT TAB(5 * X + 7);"(";X;:NEXT X: PRINT TAB(45) "(7,0)" 660 FOR L = 0 TO 7 670 FOR M = 0 TO 7 680 IF S(L, M) = 1 OR S(L, M) = 2 THEN Z = 1 690 IF S(L, M) = -1 OR S(L, M) = -2 THEN T = 1 700 NEXT M 710 NEXT L 720 IF Z <> 1 THEN 880 730 IF T <> 1 THEN 870 740 Z = 0: T = 0 750 INPUT "FROM"; E, H: X = E: Y = H: IF S(X, Y) <= 0 THEN 750 760 INPUT "TO"; a, B: X = a: Y = B 770 IF S(X, Y) = 0 AND ABS(a - E) <= 2 AND ABS(a - E) = ABS(B - H) THEN 790 780 GOTO 760 790 I = 46 800 S(a, B) = S(E, H): S(E, H) = 0: IF ABS(E - a) <> 2 THEN 850 810 S((E + a) / 2, (H + B) / 2) = 0 820 INPUT "+TO"; A1, B1: IF A1 < 0 THEN 850 830 IF S(A1, B1) <> 0 OR ABS(A1 - a) <> 2 OR ABS(B1 - B) <> 2 THEN 820 840 E = a: H = B: a = A1: B = B1: I = I + 15: GOTO 800 850 IF B = 7 THEN S(a, B) = 2 860 GOTO 240 870 PRINT : PRINT "YOU WIN.": END 880 PRINT : PRINT "I WIN." ##Hexapawn,A simple but classic board game where you move pawns against the computer. 10 CLS:PRINT TAB(32);"HEXAPAWN":PRINT 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT 40 REM HEXAPAWN: INTERPRETATION OF HEXAPAWN GAME AS PRESENTED IN 50 REM MARTIN GARDNER'S "THE UNEXPECTED HANGING AND OTHER MATHEMATIC- 60 REM AL DIVERSIONS", CHAPTER EIGHT: A MATCHBOX GAME-LEARNING MACHINE 70 REM ORIGINAL VERSION FOR H-P TIMESHARE SYSTEM BY R.A. KAAPKE 5/5/76 80 REM INSTRUCTIONS BY JEFF DALTON 90 REM CONVERSION TO MITS BASIC BY STEVE NORTH 100 DIM B(19,9),M(19,4),S(9): REM P$(3) 110 W=0: L=0 120 DEF FNR(X)=-3*(X=1)-(X=3)-4*(X=6)-6*(X=4)-7*(X=9)-9*(X=7)+FNS(X) 130 DEF FNS(X)=-X*(X=2 OR X=5 OR X=8) 140 DEF FNM(Y)=Y-INT(Y/10)*10 150 REM P$="X.O" 160 FOR I=1 TO 19: FOR J=1 TO 9: READ B(I,J): NEXT J: NEXT I 170 FOR I=1 TO 19: FOR J=1 TO 4: READ M(I,J): NEXT J: NEXT I 180 GOSUB 2000 190 X=0: Y=0 200 S(4)=0: S(5)=0: S(6)=0 210 S(1)=-1: S(2)=-1: S(3)=-1 220 S(7)=1: S(8)=1: S(9)=1 230 GOSUB 1370 240 PRINT "YOUR MOVE"; 250 INPUT M1,M2 260 IF M1=INT(M1)AND M2=INT(M2)AND M1>0 AND M1<10 AND M2>0 AND M2<10 THEN 290 270 PRINT "ILLEGAL CO-ORDINATES." 280 GOTO 240 290 IF M2>M1 OR S(M1)<>1 OR S(M2)=1 THEN 350 320 IF (M1=7 AND M2=3) OR (M1=6 AND M2=4) THEN 350 330 IF M2-M1=-3 AND S(M2)=0 THEN 370 340 IF (M2-M1=-4 OR M2-M1=-2) AND S(M2)=-1 THEN 370 350 PRINT "ILLEGAL MOVE.": GOTO 240 370 S(M1)=0 380 S(M2)=1 390 GOSUB 1370 400 IF S(1)=1 OR S(2)=1 OR S(3)=1 THEN 1130 410 FOR I=1 TO 9 420 IF S(I)=-1 THEN 450 430 NEXT I 440 GOTO 1130 450 FOR I=1 TO 9 460 IF S(I)<>-1 THEN 550 470 IF S(I+3)=0 THEN 570 480 IF FNR(I)=I THEN 540 490 IF I>3 THEN 520 500 IF S(5)=1 THEN 570 510 GOTO 550 520 IF S(8)=1 THEN 570 530 GOTO 550 540 IF S(I+2)=1 OR S(I+4)=1 THEN 570 550 NEXT I 560 GOTO 1130 570 FOR I=1 TO 19 580 FOR J=1 TO 3 590 FOR K=3 TO 1 STEP -1 600 T((J-1)*3+K)=B(I,(J-1)*3+4-K) 610 NEXT K 620 NEXT J 630 FOR J=1 TO 9 640 IF S(J)<>B(I,J) THEN 680 650 NEXT J 660 R=0 670 GOTO 770 680 FOR J=1 TO 9 690 IF S(J)<>T(J) THEN 730 700 NEXT J 710 R=1 720 GOTO 770 730 NEXT I 740 REM EMBER THE TERMINATION OF THIS LOOP IS IMPOSSIBLE 750 PRINT "ILLEGAL BOARD PATTERN." 760 STOP 770 X=I 780 FOR I=1 TO 4 790 IF M(X,I)<>0 THEN 830 800 NEXT I 810 PRINT "I RESIGN." 820 GOTO 1130 830 Y=INT(RND*4+1) 840 IF M(X,Y)=0 THEN 830 850 IF R<>0 THEN 900 860 PRINT "I MOVE FROM ";INT(M(X,Y)/10);" TO ";FNM(M(X,Y)) 870 S(INT(M(X,Y)/10))=0 880 S(FNM(M(X,Y)))=-1 890 GOTO 940 900 PRINT "I MOVE FROM ";FNR(INT(M(X,Y)/10));" TO "; 910 PRINT FNR(FNM(M(X,Y))) 920 S(FNR(INT(M(X,Y)/10)))=0 930 S(FNR(FNM(M(X,Y))))=-1 940 GOSUB 1370 950 IF S(7)=-1 OR S(8)=-1 OR S(9)=-1 THEN 1190 960 FOR I=1 TO 9 970 IF S(I)=1 THEN 1000 980 NEXT I 990 GOTO 1190 1000 FOR I=1 TO 9 1010 IF S(I)<>1 THEN 1100 1020 IF S(I-3)=0 THEN 240 1030 IF FNR(I)=I THEN 1090 1040 IF I<7 THEN 1070 1050 IF S(5)=-1 THEN 240 1060 GOTO 1100 1070 IF S(2)=-1 THEN 240 1080 GOTO 1100 1090 IF S(I-2)=-1 OR S(I-4)=-1 THEN 240 1100 NEXT I 1110 PRINT "YOU CAN'T MOVE, SO "; 1120 GOTO 1190 1130 PRINT "YOU WIN." 1140 M(X,Y)=0 1150 L=L+1 1160 IF L+W=1 AND W=1 THEN PRINT "I WIN THE FIRST GAME." ELSE IF L+W=1 AND L=1 THEN PRINT "YOU WIN THE FIRST GAME." ELSE PRINT "I HAVE WON ";W;" AND YOU ";L;" OUT OF ";L+W;" GAMES." 1170 PRINT 1180 GOTO 190 1190 PRINT "I WIN." 1200 W=W+1 1210 GOTO 1160 1220 DATA -1,-1,-1,1,0,0,0,1,1,-1,-1,-1,0,1,0,1,0,1 1230 DATA -1,0,-1,-1,1,0,0,0,1,0,-1,-1,1,-1,0,0,0,1 1240 DATA -1,0,-1,1,1,0,0,1,0,-1,-1,0,1,0,1,0,0,1 1250 DATA 0,-1,-1,0,-1,1,1,0,0,0,-1,-1,-1,1,1,1,0,0 1260 DATA -1,0,-1,-1,0,1,0,1,0,0,-1,-1,0,1,0,0,0,1 1270 DATA 0,-1,-1,0,1,0,1,0,0,-1,0,-1,1,0,0,0,0,1 1280 DATA 0,0,-1,-1,-1,1,0,0,0,-1,0,0,1,1,1,0,0,0 1290 DATA 0,-1,0,-1,1,1,0,0,0,-1,0,0,-1,-1,1,0,0,0 1300 DATA 0,0,-1,-1,1,0,0,0,0,0,-1,0,1,-1,0,0,0,0 1310 DATA -1,0,0,-1,1,0,0,0,0 1320 DATA 24,25,36,0,14,15,36,0,15,35,36,47,36,58,59,0 1330 DATA 15,35,36,0,24,25,26,0,26,57,58,0 1340 DATA 26,35,0,0,47,48,0,0,35,36,0,0,35,36,0,0 1350 DATA 36,0,0,0,47,58,0,0,15,0,0,0 1360 DATA 26,47,0,0,47,58,0,0,35,36,47,0,28,58,0,0,15,47,0,0 1370 PRINT:REM #1000 1380 FOR I=1 TO 3:PRINT TAB(3):FOR J=1 TO 3:PRINT (I-1)*3+J;:NEXT:PRINT TAB(10) 1390 FOR J=1 TO 3 1400 ON S((I-1)*3+J)+2 GOSUB 1460, 1470, 1480 1410 NEXT J 1420 PRINT 1430 NEXT I 1440 PRINT 1450 RETURN 1460 PRINT "X";:RETURN 1470 PRINT ".";:RETURN 1480 PRINT "O";:RETURN 2000 PRINT: PRINT "THIS PROGRAM PLAYS THE GAME OF HEXAPAWN.":REM#2000 2010 PRINT "HEXAPAWN IS PLAYED WITH CHESS PAWNS ON A 3 BY 3 BOARD." 2020 PRINT "THE PAWNS ARE MOVED AS IN CHESS - ONE SPACE FORWARD TO" 2030 PRINT "AN EMPTY SPACE OR ONE SPACE FORWARD AND DIAGONALLY TO" 2040 PRINT "CAPTURE AN OPPOSING MAN. ON THE BOARD, YOUR PAWNS" 2050 PRINT "ARE 'O', THE COMPUTER'S PAWNS ARE 'X', AND EMPTY " 2060 PRINT "SQUARES ARE '.'. TO ENTER A MOVE, TYPE THE NUMBER OF" 2070 PRINT "THE SQUARE YOU ARE MOVING FROM, FOLLOWED BY THE NUMBER" 2080 PRINT "OF THE SQUARE YOU WILL MOVE TO. THE NUMBERS MUST BE" 2090 PRINT "SEPERATED BY A COMMA.": PRINT:INPUT "ENTER TO CONTINUE";A 2100 PRINT "THE COMPUTER STARTS A SERIES OF GAMES KNOWING ONLY WHEN" 2110 PRINT "THE GAME IS WON (A DRAW IS IMPOSSIBLE) AND HOW TO MOVE." 2120 PRINT "IT HAS NO STRATEGY AT FIRST AND JUST MOVES RANDOMLY." 2130 PRINT "HOWEVER, IT LEARNS FROM EACH GAME. THUS, WINNING BECOMES" 2140 PRINT "MORE AND MORE DIFFICULT. ALSO, TO HELP OFFSET YOUR" 2150 PRINT "INITIAL ADVANTAGE, YOU WILL NOT BE TOLD HOW TO WIN THE" 2160 PRINT "GAME BUT MUST LEARN THIS BY PLAYING.":PRINT:INPUT "ENTER TO CONTINUE";A 2170 PRINT: PRINT "THE NUMBERING OF THE BOARD IS AS FOLLOWS:" 2180 PRINT TAB(10);"123": PRINT TAB(10);"456": PRINT TAB(10);"789" 2190 PRINT: PRINT "FOR EXAMPLE, TO MOVE YOUR RIGHTMOST PAWN FORWARD," 2200 PRINT "YOU WOULD TYPE 9,6 IN RESPONSE TO THE QUESTION" 2210 PRINT "'YOUR MOVE ?'. SINCE I'M A GOOD SPORT, YOU'LL ALWAYS" 2220 PRINT "GO FIRST.": PRINT 2230 RETURN 2240 END ##Hamurabi,Govern ancient Sumeria. 10 CLS:PRINT TAB(32);"HAMURABI":PRINT 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT 40 PRINT "TRY YOUR HAND AT GOVERNING ANCIENT SUMERIA" 50 PRINT "FOR A TEN-YEAR TERM OF OFFICE.":PRINT 60 def fnround(v,d) = int(v * 10^d + 0.5)/10^d 70 D1=0: P1=0 80 Z=0: P=95:S=2800: H=3000: E=H-S 90 Y=3: A=H/Y: I=5: Q=1 100 D=0 110 PRINT:PRINT:PRINT "HAMURABI: I BEG TO REPORT TO YOU,": Z=Z+1 120 PRINT "IN YEAR ";Z;","; 130 IF D=0 THEN PRINT " NO PEOPLE STARVED AND "; 140 IF D=1 THEN PRINT "1 PERSON STARVED AND "; 150 IF D>1 THEN PRINT D;" PEOPLE STARVED AND "; 160 IF I=0 THEN PRINT "NONE CAME TO THE CITY." 170 IF I=1 THEN PRINT "1 CAME TO THE CITY." 180 IF I>1 THEN PRINT I;" CAME TO THE CITY." 190 P=P+I 200 IF Q>0 THEN 230 210 P=INT(P/2) 220 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED." 230 PRINT "SO THE POPULATION IS NOW ";P;"." 240 PRINT "THE CITY NOW OWNS ";:V=A:GOSUB 2000:PRINT " ACRES." 250 IF Y=0 THEN PRINT "THE HARVEST DID NOT YIELD ANY GRAIN." 260 IF Y=1 THEN PRINT "YOU HARVESTED 1 BUSHEL PER ACRE." 270 IF Y>1 THEN PRINT "YOU HARVESTED ";Y;" BUSHELS PER ACRE." 280 IF E=0 THEN PRINT "THE RATS DID NOT EAT ANY GRAIN." 290 IF E=1 THEN PRINT "THE RATS ATE 1 BUSHEL." 300 IF E>1 THEN PRINT "THE RATS ATE ";E;" BUSHELS." 310 PRINT "YOU NOW HAVE ";:V=S:GOSUB 2000:PRINT " BUSHELS IN STORE.":PRINT 320 IF Z=11 THEN 1080 330 C=INT(10*RND): Y=C+17 340 PRINT "LAND IS TRADING AT ";FNROUND(Y,2);" BUSHELS PER ACRE." 350 PRINT "HOW MANY ACRES DO YOU WISH TO BUY"; 360 INPUT Q: IF Q<0 THEN 1050 370 IF Y*Q<=S THEN 400 380 GOSUB 980 390 GOTO 350 400 IF Q=0 THEN 430 410 A=A+Q: S=S-Y*Q: C=0 420 GOTO 490 430 PRINT "HOW MANY ACRES DO YOU WISH TO SELL"; 440 INPUT Q: IF Q<0 THEN 1050 450 IF Q
C/2 THEN 810 790 REM *** RATS ARE RUNNING WILD!! 800 E=INT(S/C) 810 S=S-E+H 820 GOSUB 1030 830 REM *** LET'S HAVE SOME BABIES 840 I=INT(C*(20*A+S)/P/100+1) 850 REM *** HOW MANY PEOPLE HAD FULL TUMMIES? 860 C=INT(Q/20) 870 REM *** HORROS, A 15% CHANCE OF PLAGUE 880 Q=INT(10*(2*RND-.3)) 890 IF P
.45*P THEN 940 920 P1=((Z-1)*P1+D*100/P)/Z 930 P=C: D1=D1+D: GOTO 110 940 PRINT: PRINT "YOU STARVED ";D;" PEOPLE IN ONE YEAR!!!" 950 PRINT "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY" 960 PRINT "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE" 970 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!": GOTO 1280 980 PRINT "HAMURABI: THINK AGAIN. YOU HAVE ONLY" 990 V=S:GOSUB 2000:PRINT " BUSHELS OF GRAIN. NOW THEN," 1000 RETURN 1010 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY ";:V=A:GOSUB 2000:PRINT A;" ACRES. NOW THEN," 1020 RETURN 1030 C=INT(RND*5)+1 1040 RETURN 1050 PRINT: PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH." 1060 PRINT "GET YOURSELF ANOTHER STEWARD!!!!!" 1070 GOTO 1280 1080 PRINT "IN YOUR 10-YEAR TERM OF OFFICE, ";FNROUND(P1,2);" PERCENT OF THE" 1090 PRINT "POPULATION STARVED PER YEAR ON THE AVERAGE, I.E. A TOTAL OF" 1100 PRINT D1;" PEOPLE DIED!!": L=A/P 1110 PRINT "YOU STARTED WITH 10 ACRES PER PERSON AND ENDED WITH" 1120 PRINT L;" ACRES PER PERSON.": PRINT 1130 IF P1>33 THEN 950 1140 IF L<7 THEN 950 1150 IF P1>10 THEN 1210 1160 IF L<9 THEN 1210 1170 IF P1>3 THEN 1240 1180 IF L<10 THEN 1240 1190 PRINT "A FANTASTIC PERFORMANCE!!! CHARLEMANGE, DISRAELI, AND" 1200 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!":GOTO 1280 1210 PRINT "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV." 1220 PRINT "THE PEOPLE (REMIANING) FIND YOU AN UNPLEASANT RULER, AND," 1230 PRINT "FRANKLY, HATE YOUR GUTS!!":GOTO 1280 1240 PRINT "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT" 1250 PRINT "REALLY WASN'T TOO BAD AT ALL. ";INT(P*.8*RND);" PEOPLE" 1260 PRINT "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE OUR" 1270 PRINT "TRIVIAL PROBLEMS." 1280 REM 1290 PRINT "SO LONG FOR NOW.": PRINT:END 2000 rem#2000 FORMAT NUMBER WITH COMMAS OUT TO TWO DECIMAL PLACES 2010 FF=0:V=fnround(V,2):IF V<0 THEN PRINT "-"; 2020 V=ABS(V):FOR J=8 TO -2 STEP -1:FD=INT(V/10^J) MOD 10 2030 IF FD OR J=1 OR FF THEN FF=1: PRINT FD; 2040 IF (J=6 OR J=3) AND FF THEN PRINT ","; 2050 IF J=0 THEN FF=1: PRINT "."; 2060 NEXT 2070 RETURN ##BATTLE,Sink the enemy fleet by decoding a secret message! 5 PRINT TAB(33);"BATTLE" 7 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 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 REM DIM F(6,6),H(6,6),A(4)
0 THEN 90 130 M=0 140 ON D GOTO 150,340,550,740 150 B(1)=B 160 B(2)=7: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 IF B(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)=0:A(3)=0:B(2)=0: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 IF A(1)>A(2) AND A(1)>A(3) THEN Z1=A(1) 462 IF A(2)>A(1) AND A(2)>A(3) THEN Z1=A(2) 464 IF A(3)>A(1) AND A(3)>A(2) THEN Z1=A(3) 470 IF B(1)>B(2) AND B(1)>B(3) THEN Z2=B(1) 474 IF B(2)>B(1) AND B(2)>B(3) THEN Z2=B(2) 476 IF B(3)>B(1) AND B(3)>B(2) THEN Z2=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)=7: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 IF A(1)
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)=7:A(3)=7 770 B(2)=0: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 IF A(1)
B(2) AND B(1)>B(3) THEN Z2=B(1) 882 IF B(2)>B(1) AND B(2)>B(3) THEN Z2=B(2) 884 IF B(3)>B(1) AND B(3)>B(2) THEN Z2=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 DECODED:" 1040 PRINT 1050 FOR I=1 TO 6 1051 FOR J=1 TO 6 1052 H(I,J)=F(J,I) 1053 NEXT J 1054 NEXT I 1060 FOR I=1 TO 6 1061 FOR J=1 TO 6 1062 PRINT H(I,J); 1063 NEXT J 1064 PRINT 1065 NEXT I 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 FOR I=1 TO 6 1111 FOR J=1 TO 6 1112 H(I,J)=0 1113 NEXT J 1114 NEXT I 1120 FOR I=1 TO 3 1121 L(I)=0 1122 NEXT I 1130 C(1)=2:C(2)=2 1140 C(3)=1:C(4)=1 1150 C(5)=0:C(6)=0 1160 S=0: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 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 ##GEOWAR,Five enemy installations must be destroyed! 10 REM *** GEOWAR 20 REM *** WRITTEN BY GARY LORENC, IDEA BY KENNETH JANOWIAK 30 REM *** ST. PATRICK HS, 5900 W. BELMONT AVE, CHICAGO, ILL 40 REM *** UPDATED TO BASIC-PLUS BY DAVE AHL, DIGITAL PDP-11/45 GROUP 50 PRINT"DO YOU WANT A DESCRIPTION OF THE GAME?" 60 gosub 1820:IF aa=0 THEN 380 70 PRINT 80 PRINT" THE FIRST QUADRANT OF A REGULAR COORDINATE GRAPH WILL" 90 PRINT"SERVE AS THE BATTLEFIELD. FIVE ENEMY INSTALLATIONS ARE LOCATED " 100 PRINT"WITHIN A 30 BY 30 UNIT AREA. NO TARGET IS INSIDE THE 10 BY 10 " 110 PRINT"UNIT AREA ADJACENT TO THE ORIGIN, AS THIS IS THE LOCATION OF OUR " 120 PRINT"BASE. WHEN THE MACHINE ASKS FOR THE DEGREE OF THE SHOT, RESPOND " 130 PRINT"WITH A NUMBER BETWEEN 1 AND 90." 150 PRINT 160 PRINT TAB(51),"SCARE**********" 170 PRINT" 1. A DIRECT HIT IS A HIT WITHIN 1 DEGREE OF"; 180 PRINT TAB(51),"* *" 190 PRINT" THE TARGET.",TAB(51),"* HIT****** *" 200 PRINT" 2. A HIT MUST PASS BETWEEN THE FIRST SET OF"; 210 PRINT TAB(51),"* * * *" 220 PRINT" INTEGRAL POINTS NW AND SE OF THE TARGET."; 230 PRINT TAB(51),"* * D * *" 240 PRINT" 3. A SCARE MUST PASS BETWEEN THE NEXT SET OF"; 250 PRINT TAB(51),"* * * *" 260 PRINT" INTEGRAL POINTS NW AND SE OF THE TARGET,"; 270 PRINT TAB(51),"* ******HIT *" 280 PRINT" AND CAUSES THE ENEMY TO RELOCATE A "; 290 PRINT TAB(51),"* *" 300 PRINT" MAXIMUM OF 1 UNIT IN ANY DIRECTION."; 310 PRINT TAB(51),"**********SCARE" 320 PRINT:print "Enter to Continue;":input "", aa 330 PRINT 340 PRINT" MISSILES HAVE INFINITE RANGE AND MAY HIT MORE THAN ONE TARGET." 350 PRINT"A MISSILE THAT NEARLY MISSES AN INSTALLATION (A SCARE) " 360 PRINT"WILL BE IMMEDIATELY SHOT DOWN. ANY HITS BEFORE THIS TIME WILL " 370 PRINT"NOT BE COUNTED UNLESS A DIRECT HIT WAS MADE." 380 PRINT 390 PRINT 400 PRINT"READY TO GO?" 410 gosub 1820:IF aa=0 THEN 1800 420 PRINT"GOOD LUCK!" 430 PRINT 440 DIM C(10),H(20),D(10),S(20),F(5) 450 DEF FNV(V1)=INT((180/3.14159)*ATN(V1)+.5) 460 X=250 470 X1=RND 480 G2=0 490 S2=0 500 D2=0 510 H2=0 520 FOR K=1 TO 10 530 GOSUB 1450 540 IF INT(K/2)<>K/2 THEN 610 550 IF C(K-1)>10 THEN 610 560 IF C(K)>10 THEN 610 570 FOR L=K-1 TO K 580 GOSUB 1450 590 NEXT L 600 GOTO 540 610 NEXT K 620 S=0 630 FOR L=1 TO 5 640 D(L)=FNV(C(2*L)/C(2*L-1)) 650 NEXT L 660 A=2 670 L1=10 680 T5=5 690 D5=0 700 H5=0 710 GOSUB 1380 720 PRINT 730 PRINT"ENTER DEGREE OF SHOT "; 740 D1=0 750 H1=0 760 FOR Q=1 TO 5 770 F(Q)=20 780 NEXT Q 790 INPUT D 800 IF D>=90 THEN 720 810 IF D<0 THEN 1670 ELSE IF D=0 THEN 192 820 S=S+1 830 FOR A=2 TO 10 STEP 2 840 IF D>S(A) THEN 940 850 IF D
H(A) THEN 960 870 IF D
D(A/2)+1 THEN 920 890 IF D
0 THEN 1090 970 GOSUB 1290 980 GOTO 720 990 IF D1+H1<>0 THEN 1030 1000 IF T5=1 THEN 1500 1010 PRINT"NO LUCK -- TRY AGAIN." 1020 GOTO 720 1030 IF D1>0 THEN 1090 1040 IF H1>1 THEN 1070 1050 PRINT"**CONGRATULATIONS** A HIT." 1060 GOTO 1150 1070 PRINT"**CONGRATULATIONS** ";H1;" HITS." 1080 GOTO 1150 1090 PRINT"****BULLS EYE**** "; 1100 IF D1>1 THEN 1140 1110 IF H1>0 THEN 1140 1120 PRINT" A DIRECT HIT!" 1130 GOTO 1150 1140 PRINT D1+H1;" HITS -- A DIRECT HIT ON ";D1;" OF THEM!" 1150 T5=T5-(D1+H1) 1160 D5=D5+D1 1170 H5=H5+H1 1180 IF T5=0 THEN 1580 1190 FOR J= 1 TO H1+D1 1200 Z=F(J) 1210 D(Z/2)=0 1220 H(Z)=0 1230 H(Z-1)=0 1240 S(Z)=0 1250 S(Z-1)=0 1260 NEXT J 1270 PRINT 5-T5;" DOWN -- ";T5;" TO GO." 1280 GOTO 720 1290 PRINT"A NEAR HIT. ENEMY HAS RELOCATED." 1300 FOR R=1 TO 2 1310 X2=INT(RND*100) 1320 IF ABS(C(A-(R-1))-X2)>1 THEN 1310 1330 IF C(A-(R-1))<=2 THEN 1310 1340 C(A-(R-1))=X2 1350 NEXT R 1360 D(A/2)=FNV(C(A)/C(A-1)) 1370 L1=A 1380 FOR I=A TO L1 STEP 2 1390 H(I-1)=FNV((C(I)-1)/(C(I-1)+1)) 1400 H(I)=FNV((C(I)+1)/(C(I-1)-1)) 1410 S(I-1)=FNV((C(I)-2)/(C(I-1)+2)) 1420 S(I)=FNV((C(I)+2)/(C(I-1)-2)) 1430 NEXT I 1440 RETURN 1450 R=INT(RND*100) 1460 IF R>30 THEN 1450 1470 IF R<3 THEN 1450 1480 C(K)=R 1490 RETURN 1500 FOR Z1=1 TO 5 1510 IF D(Z1)>1 THEN 1530 1520 NEXT Z1 1530 IF D
=N2 THEN 340 310 A1=A1+1 320 PRINT "THE COMPUTER WINS!!! YOU HAVE ";B1;" AND THE COMPUTER HAS ";A1;"." 330 GOTO 390 340 IF N1=N2 THEN 380 350 B1=B1+1 360 PRINT "YOU WIN. YOU HAVE ";B1;" AND THE COMPUTER HAS ";A1;"." 370 GOTO 390 380 PRINT "TIE. NO SCORE CHANGE." 390 IF L(P+1)=0 THEN 420 400 PRINT "ARE YOU DONE?" 410 gosub 680:if aa=1 then 460 else 220 420 PRINT 430 PRINT 440 PRINT "WE HAVE RUN OUT OF CARDS. FINAL SCORE: YOU: ";B1; 450 PRINT " THE COMPUTER: ";A1:PRINT 460 PRINT "THANKS FOR PLAYING. IT WAS FUN." 470 PRINT:end 480 on int((CC-1)/4)+1 gosub 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670 490 on (CC-1) mod 4 +1 goto 510, 520, 530, 540 500 return 510 print " of Spades";:return 520 print " of Hearts";:return 530 print " of Clubs";:return 540 print " of Diamonds";:return 550 print "Two";:return 560 print "Three";:return 570 print "Four";:return 580 print "Five";:return 590 print "Six";:return 600 print "Seven";:return 610 print "Eight";:return 620 print "Nine";:return 630 print "Ten";:return 640 print "Jack";:return 650 print "Queen";:return 660 print "King";:return 670 print "Ace";:return 680 input "Please enter 0 for No, 1 for Yes",AA 690 if aa = 0 or aa = 1 then return 700 goto 680 ##CHOMP,Avoid taking the poison cookie on a 10 by 10 grid. 10 CLS:PRINT TAB(33);"CHOMP":PRINT 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT 40 DIM A(10,10) 50 REM *** THE GAME OF CHOMP *** COPYRIGHT PCC 1973 *** 60 PRINT 70 PRINT "THIS IS THE GAME OF CHOMP (SCIENTIFIC AMERICAN, JAN 1973)":PRINT 80 PRINT "DO YOU WANT THE RULES?" 90 gosub 1020 100 IF AA=0 THEN 270 110 F=1 120 R=5 130 C=7 140 PRINT "CHOMP is for one or more players -- Humans only." 150 PRINT "Here's how a board looks (this one is 5 by 7):" 160 GOSUB 500 170 PRINT "The board is a big cookie - R rows high and C columns" 180 PRINT "wide. You input R and C at the start. In the upper left" 190 PRINT "corner of the cookie is a poison square (P). The one who" 200 PRINT "chomps the poison square loses. To take a chomp, type the" 210 PRINT "row and column of one of the squares on the cookie." 220 PRINT "All of the squares below and to the right of that square" 230 PRINT "(including that square, too) disappear -- CHOMP!!" 240 PRINT "No fair chomping squares that have already been chomped," 250 PRINT "or that are outside the original dimensions of the cookie." 260 PRINT 270 PRINT:PRINT "HERE WE GO..." 280 REM 290 F=0 300 FOR I=1 TO 10 310 FOR J=1 TO 10 320 A(I,J)=0 330 NEXT J 340 NEXT I 350 PRINT 360 PRINT "HOW MANY PLAYERS"; 370 INPUT P 380 I1=0 390 PRINT "HOW MANY ROWS"; 400 INPUT R 410 IF R <= 9 THEN 440 420 PRINT "TOO MANY ROWS (9 IS MAXIMUM). NOW, "; 430 GOTO 390 440 PRINT "HOW MANY COLUMNS"; 450 INPUT C 460 IF C <= 9 THEN 490 470 PRINT "TOO MANY COLUMNS (9 IS MAXIMUM). NOW, "; 480 GOTO 440 490 PRINT 500 FOR I=1 TO R 510 FOR J=1 TO C 520 A(I,J)=1 530 NEXT J 540 NEXT I 550 A(1,1)=-1 560 REM PRINT THE BOARD 570 PRINT 580 PRINT TAB(7);"1 2 3 4 5 6 7 8 9" 590 FOR I=1 TO R 600 PRINT I;TAB(7); 610 FOR J=1 TO C 620 IF A(I,J)=-1 THEN 660 630 IF A(I,J)=0 THEN 680 640 PRINT "* "; 650 GOTO 670 660 PRINT "P "; 670 NEXT J 680 PRINT 690 NEXT I 700 PRINT 710 IF F=0 THEN 730 720 RETURN 730 REM GET CHOMPS FOR EACH PLAYER IN TURN 740 LET I1=I1+1 750 LET P1=I1-INT(I1/P)*P 760 IF P1 <> 0 THEN 780 770 P1=P 780 PRINT "PLAYER ";P1:PRINT "--------" 790 PRINT "COORDINATES OF CHOMP (ROW,COLUMN)"; 800 INPUT R1,C1 810 IF R1<1 THEN 880 820 IF R1>R THEN 880 830 IF C1<1 THEN 880 840 IF C1>C THEN 880 850 IF A(R1,C1)=0 THEN 880 860 IF A(R1,C1)=-1 THEN 970 870 GOTO 900 880 PRINT "NO FAIR. YOU'RE TRYING TO CHOMP ON EMPTY SPACE!" 890 GOTO 780 900 FOR I=R1 TO R 910 FOR J=C1 TO C 920 A(I,J)=0 930 NEXT J 940 NEXT I 950 GOTO 570 960 REM END OF GAME DETECTED IN LINE 900 970 PRINT:PRINT "YOU LOSE, PLAYER ";P1;"." 980 PRINT 990 PRINT "ANOTHER GAME?" 1000 gosub 1020 1010 IF AA=1 THEN 270 ELSE PRINT:PRINT:end 1020 input "Please enter 0 for No, 1 for Yes",AA 1030 if aa = 0 or aa = 1 then return 1040 goto 1020
Visitor #
These classic computer games have been written and published by
James Larson
Programmer/Analyst Consultant
http://www.dst-corp.com/james
E-mail address
In God We Trust...