Your Spectrum
Issue 15, June 1985 - Mastermind
Home Contents KwikPik


The listing shown here is the one printed in the magazine, which was full of errors. It wouldn't even run because of undefined and incorrectly defined variables, and it used an alternative character set which was also undefined, so most of the displays came out blank. The supposed corrections printed on page 15 of the July issue did little to rectify the situation. This may be why the article was attributed to a false name - although the author's real name is given in the listing. Some of the listing captions were wrong as well - I've corrected them.
A corrected version of this program is available on "ZIPi'T'ape",




MASTERMIND
The lights go down as you sink into the YS Mastermind chair - but the questions you answer are as tough as you want to make them. Chris Winterton has come up with a program that'll test you to the limits and make all your exam revision FUN!
where this program comes in. Type in all your questions and their answers or better still get someone else to type them in for you. Short questions and answers are best though you can go up to two lines if necessary. And remember your computer is very precise so you must answer the questions in exactly the same form as they were typed in initially - if you did it in lower case first time, do it that way all the time. You'll soon find out how best to use the program by having a go at the demo. Now I've started, so away you go and finish!
You may not have to be a mastermind to answer the questions but it's the best way of discovering just how flexible this program is.
 15 LET entry=20: LET swap=240: LET score=270: LET print=210: LET rand=330: LET present=370: LET wrong=500: LET replay=520: LET demo=630: LET display=890: LET end=940: LET menu=1120
Line 15 This line sets up the variables.
 30 POKE 23658,8: CLS : POKE 23607,249: PRINT INK 2; PAPER 7;v$: POKE 23607,60: LET f$="                                                                                                                                ": LET e$="then press ENTER"
 40 LET line=5: LET p$="How many questions do you wish  to enter?": GO SUB print: LET line=9: LET p$="Type in the number": GO SUB print: LET line=11: LET p$=e$: GO SUB print
 50 INPUT "Number of Questions (maximum 30) ";number: PRINT AT 5,0;f$;AT 8,0;f$
 60 DIM a$(number,64): DIM b$(number,64): DIM e(number): REM MASTER ARRAYS
 70 DIM q$(number,64): DIM r$(number,64): REM PRESENTATION ARRAYS
 80 FOR i=1 TO number
 90 LET line=4: LET p$=" Question "+STR$ i+" of "+STR$ number+" questions": GO SUB print
100 LET line=8: LET p$="Carefully type in your question": GO SUB print: LET line=9: LET p$=e$: GO SUB print
110 INPUT a$(i)
120 PRINT AT 8,0;f$: PRINT AT 8,0;a$(i)
130 LET line=12: LET p$="Press any letter if correct": GO SUB print: LET line=13: LET p$="Press ""X"" if wrong": GO SUB print
140 IF INKEY$<>"" THEN GO TO 140
150 LET i$=INKEY$: IF i$="" THEN GO TO 150
160 IF i$="x" OR i$="X" THEN PRINT AT 8,0;f$;f$: GO TO 100
170 PRINT AT 11,0;f$: LET line=12: LET p$="Please type in the answer": GO SUB print: LET line=14: LET p$=e$: GO SUB print: INPUT b$(i): PRINT AT 13,0;f$: PRINT AT 12,0;b$(i)
180 LET line=16: LET p$="Press any letter if correct": GO SUB print: LET line=17: LET p$="Press ""X"" if wrong": GO SUB print
190 IF INKEY$<>"" THEN GO TO 190
200 LET i$=INKEY$: IF i$="" THEN GO TO 200
210 IF i$="x" OR i$="X" THEN PRINT AT 14,0;f$: GO TO 170
220 LET q$(i)=a$(i): LET r$(i)=b$(i)
230 PRINT AT 8,0;f$;f$;f$: NEXT i: RETURN : REM END OF ENTRY
Lines 30-230 The 'Entry' subroutine, to accept your input.
Oh, groan! It's exam time again. But even worse than the exams is the revision beforehand - trying to cram the cranium with more information than it was designed to hold. Everyone's got their own way of revising for exams. Perhaps you follow the most popular method - put it all off till the night before and hope that natural ability or divine intervention will see you through. Or if that's a bit slap-dash, do you start at the beginning and plough through to the end and still find that you're faced with blank paper and a blank mind on the big day?
  Either way, you're probably not having much fun at the moment, what with working or worrying about not working. But now all that's gonna
change. This program lets you revise at your own pace and in your own way. And best of all, it won't be all slog any more. Even better, you don't just have to stick to chemical formula or French verbs. What about practising your pop knowledge or kicking your fave footie teams around. Even better you can now create your own Mastermind quiz questions to torment the whole family.

EDUCATABASE

All the information you could ever need can be stored on your Speccy - if only you were allowed to carry it into the examination room! So the problem is transferring all that info to your very own portable database, your brain. That's
cartoon



MASTERMIND


250 IF q$(1)=a$(1) THEN FOR i=1 TO number: LET r$(i)=a$(i): LET q$(i)=b$(i): NEXT i: LET line=21: LET p$="All changed: Press C": GO SUB print: RETURN
260 FOR i=1 TO number: LET q$(i)=a$(i): LET r$(i)=b$(i): NEXT i: LET line=21: LET p$="All changed: Press C": GO SUB print: RETURN : REM END OF SWAP
Lines 250-260 The 'Swap' subroutine.
280 IF t$=u$ THEN LET total=total+1: LET line=20: LET p$=" That's right!": GO SUB print: RETURN
290 IF flag=99 AND t$<>u$ THEN LET g(i)=1: GO SUB wrong: RETURN : REM SCORE ENDS
300 IF t$<>u$ THEN LET e(i)=1: GO SUB wrong: RETURN : REM SCORE ENDS
Lines 280-300 The 'Score' subroutine works out your score.
320 POKE 23607,249: FOR p=1 TO LEN p$: PRINT AT line,1;p$( TO p): BEEP .005,12: NEXT p: POKE 23607,60: RETURN
Line 320 The 'Print' subroutine.
340 RANDOMIZE : DIM f(number): DIM a(number): FOR i=1 TO number: LET a(i)=i: NEXT i
350 LET c=number: FOR j=1 TO number: LET x=INT (RND*c+1): LET f(j)=a(x): LET a(x)=a(c): LET c=c-1
360 NEXT j: RETURN : REM Array f holds random order of numbers.RAND ENDS
Lines 340-360 The 'Rand' (randomise) subroutine.
380 POKE 23658,8: LET flag=0: LET total=0: DIM e(number): CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: GO SUB rand: FOR i=1 TO number: LET current=f(i)
390 LET line=5: LET p$="Question "+STR$ i+" of "+STR$ number: GO SUB print
400 PRINT AT 7,0;q$(current)
410 LET line=10: LET p$="Type in your answer": GO SUB print: LET line=11: LET p$="then press ENTER": GO SUB print: INPUT t$
420 LET t$=t$+"  ": LET u$=r$(current, TO LEN t$): GO SUB score
430 CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: NEXT i
440 IF total<number THEN LET line=5: LET p$="You scored "+STR$ total: GO SUB print: LET line=7: LET p$="You had "+STR$ (number-total)+" wrong": GO SUB print: LET line=9: LET p$="If you wish to try the wrong    ones again press ""X""            or press any letter": GO SUB print
450 IF total=number THEN LET line=5: LET p$="You scored "+STR$ total: GO SUB print: LET line=7: LET p$="Very well done": GO SUB print: LET line=9: LET p$="Press any letter to continue": GO SUB print: PAUSE 0: RETURN
460 IF INKEY$<>"" THEN GO TO 460
470 LET i$=INKEY$: IF i$="" THEN GO TO 470
480 IF i$="x" OR i$="X" THEN GO TO replay
490 RETURN : REM PRESENT ENDS
510 PRINT AT 10,0;f$: LET line=10: LET p$="Sorry that's wrong": GO SUB print: LET line=11: LET p$="Correct reply =": GO SUB print: PRINT AT 13,0;r$(current): LET line=20: LET p$="Press any letter to continue": GO SUB print: PAUSE 0: RETURN : REM WRONG ENDS
Line 510 The 'Wrong' subroutine that tells you when you've answered a question incorrectly.
530 LET h=0: LET flag=99: LET total=0: DIM g(number): CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: FOR i=1 TO number: LET current=f(i)
540 IF e(i)=0 THEN NEXT i
550 LET h=h+1: LET line=5: LET p$="REPLAY": GO SUB print
560 PRINT AT 7,0;q$(current)
570 LET line=10: LET p$="Type in your answer": GO SUB print: LET line=11: LET p$="then press ENTER": GO SUB print: INPUT t$
580 LET t$=t$+"  ": LET u$=r$(current, TO LEN t$): GO SUB score
590 CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: NEXT i
600 LET line=5: LET p$="YOU SCORED "+STR$ total: GO SUB print: LET line=7: LET p$="You had "+STR$ (h-total)+" wrong": GO SUB print: LET line=9: LET p$="Press any letter to continue": GO SUB print
610 PAUSE 0
620 RETURN : REM REPLAY ENDS
Lines 530-620 The 'Replay' subroutine that gives you another crack at a question when you've got it wrong.
640 DATA "LONDON", "UNITED KINGDOM", "PARIS", "FRANCE", "LISBON", "PORTUGAL", "CAIRO", "EGYPT", "BUENOS AIRES", "ARGENTINA", "STOCKHOLM", "SWEDEN", "AMSTERDAM", "HOLLAND", "COPENHAGEN", "DENMARK", "MADRID", "SPAIN", "WARSAW", "POLAND"
650 CLS : POKE 23607,249: PRINT v$: POKE 23607,60: LET line=5: LET p$="DEMONSTRATION": GO SUB print: LET line=7: LET p$="You will be shown the names of": GO SUB print: LET line=9: LET p$="ten capital cities": GO SUB print: LET line=11: LET p$="Try to name their countries": GO SUB print: LET line=20: LET p$="Press any letter when ready": GO SUB print
660 PAUSE 0
670 RESTORE 640: LET number=10: DIM a$(10,32): DIM b$(10,32): DIM q$(10,32): DIM r$(10,32): FOR i=1 TO 10: READ o$,n$: LET a$(i)=o$: LET b$(i)=n$: LET q$(i)=a$(i): LET r$(i)=b$(i): NEXT i
680 POKE 23658,8: GO SUB present: RETURN : REM DEMO ENDS
Lines 640-680 The 'Demo' subroutine.
900 FOR i=1 TO number: CLS : POKE 23607,249: PRINT v$: POKE 23607,60: LET line=5: LET p$="Question "+STR$ i: GO SUB print: PRINT : PRINT q$(i)
910 LET line=10: LET p$=" Answer "+STR$ i: GO SUB print
920 PRINT : PRINT r$(i)
930 LET line=20: LET p$="Press any letter for next": GO SUB print: PAUSE 0: NEXT i: RETURN : REM DISPLAY ENDS
Lines 900-930 The 'Display' subroutine.
950 CLS : LET line=5: LET p$="Copyright": GO SUB print: LET line=6: LET p$="1985 Chris Somerville": GO SUB print: LET line=7: LET p$="Presented in ""Your Spectrum""": GO SUB print
960 LET line=12: LET p$="Press any letter to clear": GO SUB print: LET line=13: LET p$="Press X to restart": GO SUB print: LET line=14: LET p$="Press C to copy on tape": GO SUB print
970 IF INKEY$<>"" THEN GO TO 970
980 LET i$=INKEY$: IF i$="" THEN GO TO 980
990 IF i$="X" THEN GO TO menu
1000 IF i$="C" THEN GO TO 1020
1010 STOP
1020 CLS : PRINT '" You can make a copy of this     tape complete with any          questions that you have         entered.                        However, you will need to type  ""CLEAR 63999"" before you load   the new tape you have made."
1030 PRINT '" Press any letter when you       are ready to record": PAUSE 0: CLS : PRINT AT 10,0;" Type in a name for your tape    then press ENTER": INPUT "NOT MORE THAN 9 LETTERS";i$
1040 PRINT #1;AT 0,0;"    Is Interface 1 attached?         Press Y(yes) or N(no)"
1050 IF INKEY$<>"" THEN GO TO 1050
1060 LET j$=INKEY$: IF j$="" THEN GO TO 1060
1070 LET auto=23736: IF j$="y" OR j$="Y" THEN LET auto=23794
1090 SAVE i$ LINE 1100: POKE auto,181: SAVE "c"CODE 64000,746: GO TO menu
1100 LOAD "c"CODE 64000: GO TO menu
1110 STOP
Lines 950-1110 The 'end-the-game' routine.
1130 POKE 23658,8: PAPER 6: INK 0: BORDER 4: CLS : POKE 23609,35: LET v$="                                                                       HOME TUTOR PROGRAM                                                                       ": POKE 23607,249: PRINT v$: POKE 23607,60
1140 PRINT '
1150 PRINT '" To enter questions     Press B"
1160 PRINT '" To test yourself       Press C"
1170 PRINT '" To swap over           Press D  (ie:Questions become Answers)"
1180 PRINT '" For demonstration      Press E"
1190 PRINT '" To list the questions  Press F  (to learn them)"
1200 PRINT '" To finish              Press G"
1210 IF INKEY$<>"" THEN GO TO 1210
1220 LET i$=INKEY$: IF i$="" THEN GO TO 1220
1230 IF CODE i$<66 OR CODE i$>71 THEN GO TO 1210
1240 IF i$="G" THEN GO TO 940
1250 GO SUB (display AND i$="F")+(demo AND i$="E")+(entry AND i$="B")+(present AND i$="C")+(swap AND i$="D")
1260 IF i$="D" THEN GO TO 1220
1270 GO TO 1120
1280 STOP
1290 SAVE "h" LINE 1320: POKE 23736,181
1300 SAVE "c"CODE 64000,746
1310 STOP
1320 PRINT AT 20,0;
1330 LOAD "c"CODE 64000
1340 PAPER 2: INK 7: CLS : FOR i=0 TO 21: PRINT AT i,7;"STOP THE TAPE": BEEP .1,30: NEXT i
1350 GO TO menu
Lines 1130-1350 The main menu subroutine menu.
Home Contents KwikPik