PROGRAM LISTING LISTNH 10 PRINT "DEPTH CHARGE GAME" \ PRINT 20 INPUT "DIMENSION OF SEARCH AREA";G \ PRINT 30 N=INT(LOG(G)/LOG(2))+1 \ RANDOMIZE 40 PRINT "YOU ARE CAPTAIN OF THE DESTROYER USS DIGITA." 50 PRINT "AN ENEMY SUB HAS BEEN CAUSING YOU TROUBLE. YOUR" 60 PRINT "MISSION IS TO DESTROY IT. YOU HAVE"N"SHOTS." 70 PRINT "SPECIFY DEPTH CHARGE EXPLOSION POINT WITH A" 80 PRINT "TRIO OF NUMBERS -- THE FIRST TWO ARE THE" 90 PRINT "SURFACE COORDINATES. THE THIRD IS THE DEPTH " 100 PRINT \ PRINT "GOOD LUCK !" \ PRINT 110 A=INT(G*RND) \ B=INT(G+RND) \C=INT(G*RND) 120 FOR D=1 TO N \ PRINT \ PRINT "TRIAL #"D, \ INPUT X,Y,Z 130 IF ABS(X-A)+ABS(Y-B)+ABS(Z-C)=0 HEN 100 140 GOSUB 500 \ PRINT \ NEXT D 200 PRINT \ PRINT "YOU HAVE BEEN TORPEDOED! ABANDON SHIP!" 210 PRINT "THE SUBMARINE WAS AT"A","B","C \ GOTO 400 300 PRINT \ PRINT "B O O M ! ! YOU FOUND IT IN"D"TRIES!" 400 PRINT \ PRINT \ INPUT "ANOTHER GAME (Y OR N)",A$ 410 IF A$="Y" THEN 100 420 PRINT "OK. HOPE YOU ENJOYED YOURSELF " \ GOTO 600 500 PRINT "SONAR REPORTS SHOT WAS "; 510 IF Y>B THEN PRINT "NORTH"; 520 IF Y<B THEN PRINT "SOUTH"; 530 IF X>A THEN PRINT "EAST"; 540 IF X<A THEN PRINT "WEST"; 550 IF Y<>B OR X<>A THEN PRINT " AND"' 560 IF Z>C THEN PRINT " TOO LOW." 570 IF Z<C THEN PRINT " TOO HIGH." 580 IF Z=C THEN PRINT " DEPTH OK." 590 RETURN 600 END *** SAMPLE RUN RUNNH DEPTH CHARGE GAME DIMENSION OF SEHRCH AREA? 10 YOU ARE CAPTAIN OF THE DESTROYER USS DIGITAL AN ENEMY SUB HAS BEEN CAUSING YOU TROUBLE. YOUR MISSION IS TO DESTROY IT. YOU HAVE 4 SHOTS. SPECIFY DEPTH CHARGE EXPLOSION POINT WITH A TRIO OF NUMBERS -- THE FIRST TWO ARE THE SURFACE COORDINATES; THE THIRD IS THE DEPTH. GOOD LUCK TRIAL # 1 ? 5,5,5 SONAR REPORTS SHOT WAS SOUTHEAST AND TOO HIGH. TRIAL # 2 ? 3,7,7 SONAR REPORTS SHOT WAS SOUTHEAST AND DEPTH OK. TRIAL # 3 ? 1,9,7 SONAR REPORTS SHOT WAS NORTHEAST AND DEPTH OK. TRIAL # 4 ? 0,8,7 SONAR REPORTS SHOT WAS SOUTHEAST AND DEPTH OK. B O O M ! ! YOU FOUND IT IN 4 TRIES! *** [image] "I gather it chose his wife for him." *** NOTONE -- A Challenge! Something to ponder-- Determine the BEST strategy for playing the following game. lf you think you have a good one, send it to Walter Koetke at Lexington High School, Lexington, Mass. 02173. lf requested, he'lI send you a punched paper tape of a program that plays the game reasonably well (not best). Tapes will only be sent to those submitting solutions with their request. The game NOTONE is played with two players and a pair of dice. There are ten rounds in the game - one round consisting of one turn for each player. Players add the score they attain on each round, and the player with the highest score after ten rounds is the winner. On each turn the player may roll the two dice from 1 to N times. lf Ti is the total of the dice on the ith roll, then the player's score for the turn is T1 + T2 +T3+... + TN. However, and here's the catch, if any Ti is equal to T1 then the turn is over and his score is 0 for that turn. After each roll that doesn't equal T1, the player can decide whether to roll again or stop and score the number of points already obtained. Creative Computing will print the best game submitted next issue. [image] (c) DATAMATION 252