Mystery Box - Peter J.Simmons (Your Spectrum-No.13-Page 61) [NOTE: This program has unresolved bugs in it. See notes at end of file. JimG] If you're a guru of logical deduction, then you'll have probably played this game before; it's better known as Blackbox. If such pastimes have managed to elude you then settle down for your first lesson in cultural awareness! Mystery Box is one of those games that takes quite a while to get the grip of but, once mastered, is highly compulsive. The basic idea behind the game is that you can shoot lasers into the box and, by carefully noting where they reappear, you have to deduce the position of the pegs in the box. A laser can either bounce off the corner of a peg, be reflected back to the same position it started from or be totally absorbed in a head-on collision. The aim of this highly complex game is to find the pegs in the fewest number of laser shots. In the YS office this game kept us going for quite a while and we managed to get the score down to 96 over the five rounds you have to play. You can choose whether the Speccy will hide four or five pegs and, from our experience, beginners would be best to start on the four peg option. And, now, on to the play itself ... You move the laser around the outside of the box on-screen using the '9' key; when you want to fire the laser, press the zero key. If you think you've found one of the pegs, press the 'O' key and use the cursor controls to guide a graphics question mark around the screen until it's flashing over the position you think the peg is in. Once positioned, press the 'P' key and the marker will be placed. If, at any time, you think you've made an error in your judgement, you place the peg by the same process, but this time press the 'U' key to remove the marker. When you think you've got all the hidden pegs out in the open, press the '1' key and the computer will tell you if you got them all in the right position and update your score. Once you've completed all five rounds, the Spectrum will report your overall score and ask if you'd like to indulge in another game. Press the 'Y' key if you're feeling brave ... Lines 1-20 Set up the user-defined graphics. Lines 25-55 Initialise the variables and screen attributes. Line 55 calls the 'instruction' subroutine. Lines 60-80 Set up the 'round number' and score variables, and then call the subroutine to print the score and controls. Lines 90-110 Draw the game 'box'. Lines 120-125 Call the subroutine to position the pegs randomly in the box. Lines 130-150 Read the keyboard and act upon the keypresses. Lines 155-210 Move the laser around the box. Lines 255-290 Fire the laser. Lines 260-290 call routines to check the movement of the shots. Lines 300-390 Check the movement of each laser shot, fired from the top of the box. Lines 400-490 Check the movement of each laser shot, fired from the right of the box. Lines 500-590 Check the movement of each laser shot, fired from the bottom of the box. Lines 600-690 Check the movement of each laser shot, fired from the left of the box. Lines 810-850 Swap the values of variables 'b' and 'c'. Variables 'w1', 's1', 'n1' and 'e1' represent directions West, South, North and East in relation to the box. Lines 900-990 Position a peg in the box, by moving a flashing question mark '?' around the screen using the cursor control keys. Looking at lines 960-980, key 'I' returns you to the game screen, key 'P' positions a peg on-screen, and key 'U' removes a peg. Lines 1000-1070 Set the peg positions in the box. Line 1030 checks to make sure that two pegs don't occupy the same place. Lines 1110-1340 Update and print the score. Lines 1110-1140 deal with the shot absorption, lines 1210-1230 deal with any reflection of the laser shot, and lines 1300-1340 deal with the laser shot being deflected in the box. Lines 1400-1440 Check the position of the pegs. Lines 1445-1460 Make sure all the pegs are in the correct positions once you've pressed the '1' key to say you have completed each round. Lines 1470-1510 If any pegs are in the wrong position, this routine indicates which pegs were positioned incorrectly and the place they should have been. Line 1510 increments the score. Lines 1520-1535 Print the current score and return after a keypress for the next round. Lines 2000-2070 Draw the main screen controls and score details. Line 2010 checks to see if five rounds have been played. Lines 2080-2090 Print details of how to position a peg on-screen. Lines 2100-2150 Print the end of the game score. If you've scored the lowest score so far, your score will be printed up on-screen for you to view with pride. Lines 2200-2240 Print up the first page of on-screen instructions. Lines 2250-2300 Print up the second page of on-screen instructions. Lines 2310-2340 Print up the third page of on-screen instructions. Line 2320 asks the player how many pegs are to be hidden in the box. ------------------------------------------------------------------------------ TYPE: Boardgame COMMENT: This info file was typed by Jim Grimwood Downloaded from: Desert Island Disks -- http://www.image.dk/~frankie/ Maintained by: Michael Bruhn -- frankie@image.dk ------------------------------------------------------------------------------ There was a supposed correction for this program printed in issue 17, but unfortunately the correction isn't as much help as it might be ... The one useful bit in the 'correction' is that it points out that lines 582 and 585 were missing from the original listing (these should have been at the bottom left of page 62, and it's just a typical sort of thing they do in magazines - to miss off a couple of lines at the bottom of a page). So, the program "MysteryBox" in the attached file includes the correction to line 2080 and the missing lines 582 and 585, but no other changes. I did try out the other correction lines, but even after double checking that they were exactly as printed they messed up things even more. Either the writer didn't check them very thoroughly or (more likely) the corrections were printed incorrectly in the magazine. Instead of fixing the peg placement routine the corrections as printed cause any black square to be reversed, and any reversed square to get a peg put on it, so going around the box to position a peg you eventually end up with pegs all over the place. I couldn't even enter the correction lines exactly as printed, as one of them had a blatant syntax error in it anyway. Line 1300 originally read: 1300 IF def>9 THEN LET def=9 and the 'correction' was: 1300 IF def>9 THEN LET def>0: LET i=i-1: IF i=4 THEN LET i=6 I changed the "def>0" to be "def=9". This is to get around the problem that when the marker digit reached 9 all subsequent rays are marked with a 9, so to tell them apart he's changing the ink colour between 5 and 6. (He put in a LET i=6 at line 105 to initialise it.) The main problem the 'correction' was trying to correct was because the author used embedded control codes in the original listing, which they couldn't very well reproduce in the magazine, so the peg postioning cursor erases things it passes over. I think that the correction is almost OK, but either some lines are missing or have been messed up in the printing. The program "MysteryBox" in the attached file is the best we can do for now without debugging the correction, as this is basically the complete original listing. It's quite playable as long as you avoid going over an existing peg when you're positioning a new one. Here's the 'correction' as printed in Your Spectrum issue 17 (remember lines 582 and 585 are already included in "MysteryBox") - note that the "B" charac- ters are graphic mode Bs: 105 LET i=6 582 IF e1 OR w1 THEN GO TO 800 585 LET c=c-1: IF c>7 THEN GO TO 510 907 IF ATTR (u,v)=56 THEN LET a$="B": PRINT AT u,v; PAPER 7; INK 0; INVERSE 1;a$: GO TO 915 911 IF a$="B" THEN PRINT AT u,v; PAPER 7; INK 0; INVERSE 1;a$ 947 IF ATTR (u,v)=56 THEN LET a$="B" 950 PRINT AT u,v; PAPER 0; INK 7; INVERSE 1;"?" 959 IF INKEY$="i" AND a$="B" THEN PRINT AT u,v; PAPER 7; INK 0; INVERSE 1;a$: GO SUB 2060: RETURN 970 IF INKEY$="p" THEN PRINT AT u,v; PAPER 7; INK 0; INVERSE 1;"B": GO SUB 2060: RETURN 1300 IF def>9 THEN LET def=9: LET i=i-1: IF i=4 THEN LET i=6 1310 PRINT PAPER 0; INK i; AT j,k;def 1320 IF w1 OR e1 THEN PRINT PAPER 0; INK i; AT a,(9*w1)+(20*e1);def 1330 IF n1 OR s1 THEN PRINT PAPER 0; INK i; AT (5*n1)+(16*s1),b;def 1430 IF ATTR (y(f),x(f))<>56 THEN LET wr=wr+1