home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug177.arc
/
MIND.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
7KB
|
172 lines
1000 DEFINT J,K,L
1010 DIM A$(26),G$(26),ME$(26)
1020 GOSUB 2040 '*** PRINT THE HEADER
1030 PRINT"IF YOU WANT INSTRUCTIONS PRESS Y (FOR YES)"
1040 PRINT"IF YOU WANT TO PLAY PRESS ANY OTHER KEY"
1050 A$=INKEY$:IF A$ = "" GOTO 1050
1060 IF A$="Y" OR A$="y" THEN GOSUB 2120
1070 GOSUB 2040 '*** PRINT THE HEADER
1080 INPUT "KEY A SECRET WORD AND HIT RETURN";IN$
1090 IF IN$ = "" GOTO 1070
1100 L = LEN(IN$)
1110 'MOVE THE SCREEN IN CASE ITS MOVED OVER
1120 IF L>15 THEN PRINT CHR$(27)+"S"+CHR$(32)+CHR$(32);
1130 IF L>15 THEN PRINT " 15 LETTERS MAXIMUM":GOTO 1030
1140 FOR J = 1 TO L
1150 A$(J) = MID$(IN$,J,1)
1160 IF A$(J)=" " THEN PRINT " ONE WORD ONLY PLEASE":GOTO 1030
1170 IF ASC(A$(J)) <65 OR ASC(A$(J)) > 90 THEN PRINT " A-Z ONLY IN CAPS PLEASE":GOTO 1030
1180 NEXT
1190 INPUT "HOW MANY GUESSES FOR YOUR OPPONENT";GL
1200 IF GL <1 OR GL >99 THEN PRINT" BETWEEN 1 AND 99 PLEASE":GOTO 1190
1210 INPUT "HOW MANY SECONDS FOR EACH GUESS";BEEP
1220 IF BEEP >0 AND BEEP < 30 THEN PRINT " MINIMUM OF 30 PLEASE":GOTO 1210
1230 IF BEEP <> 0 THEN BEEP = INT(BEEP/10)
1240 IF BEEP = 0 THEN BEEP = 1E+10 'SET COUNT HIGH
1250 PRINT "NOW WRITE ANY CLUES OR HIT RETURN"
1260 LINE INPUT CL$
1270 X = GL
1280 'END OF INPUT. NOW GO FOR GUESS
1290 GOSUB 2040
1300 PRINT"YOU HAVE TO GUESS A";L;"LETTER WORD"
1310 PRINT"YOU HAVE";GL;"GUESSES"
1320 IF BEEP > 1E+06 GOTO 1350
1330 PRINT "YOU HAVE";BEEP*10;"SECONDS FOR EACH GUESS
1340 PRINT"IF COUNTER REACHES 10 YOU LOSE A TURN"
1350 IF CL$ = "" GOTO 1370
1360 PRINT "YOUR CLUE IS: ";CL$
1370 FOR J=1 TO L
1380 A$(J) = MID$(IN$,J,1)
1390 NEXT
1400 PRINT
1410 PRINT X;
1420 PRINT CHR$(&H1B)+CHR$(&H29);
1430 PRINT TAB(6)L;"LETTERS ";
1440 PRINT CHR$(&H1B)+CHR$(&H28);
1450 ME$=""
1460 'G LOOP IS NUMBER OF BEEPS BEFORE NEXT LINE
1470 'H LOOP IS TIME BETWEEN BEEPS
1480 IF BEEP > 1E+09 GOTO 1510
1490 FOR G = 0 TO 9
1500 POKE -3700,G+48
1510 FOR H = 1 TO BEEP*200
1520 A$=INKEY$:IF A$ = "" GOTO 1580
1530 IF LEN(ME$) >0 AND A$=CHR$(8) THEN ME$=LEFT$(ME$,(LEN(ME$)-1)):PRINT A$;:GOTO 1580
1540 IF ASC(A$) < 65 OR ASC(A$) > 90 GOTO 1580
1550 PRINT A$;
1560 ME$ = ME$+A$
1570 IF LEN(ME$) = L GOTO 1620
1580 NEXT H
1590 PRINT CHR$(7);
1600 NEXT G
1610 GOTO 1890
1620 IF LEFT$(ME$,2) = "QQ" GOTO 1950
1630 '*** NOW SPLIT IN$ INTO ELEMENTS
1640 FOR J=1 TO L
1650 G$(J) = MID$(ME$,J,1)
1660 NEXT
1670 '*** NOW WORD = A$(1-5) AND GUESS = G$(1-5)
1680 '*** NOW WORD = A$(1-L) AND GUESS = G$(1-L)
1690 TALLY = 0
1700 T = 22 + LEN(ME$)
1710 FOR J=1 TO L
1720 IF A$(J) <> G$(J) GOTO 1780
1730 TALLY = TALLY+1 'HERE IF A MATCH
1740 PRINT TAB(T)"X";
1750 T=T+1 'MOVE THE TAB COLUMN
1760 G$(J)="&&" 'MAKE SURE NOT MATCH FOR ZEROS
1770 A$(J)="%%" 'MAKE SURE NO MATCH FOR ZEROS
1780 NEXT
1790 IF TALLY = L GOTO 1930 'ALL DONE
1800 '*** THE LOOP FOR ZEROS
1810 FOR J=1 TO L
1820 FOR K=1 TO L
1830 IF A$(J) <> G$(K) GOTO 1870
1840 PRINT TAB(T)"O";
1850 T=T+1
1860 A$(J) = "^^":G$(K) = "@@"
1870 NEXT K
1880 NEXT J
1890 X=X-1
1900 IF X=0 GOTO 1950
1910 IF X=1 THEN PRINT:PRINT " ONE MORE GUESS";
1920 GOTO 1370
1930 PRINT:PRINT:PRINT"YOU FOUND THE SOLUTION"
1940 GOTO 1990
1950 PRINT:PRINT:PRINT"TOO BAD"
1960 PRINT CHR$(7);
1970 PRINT"THE WORD WAS ";IN$
1980 PRINT:PRINT
1990 PRINT "HIT ANY KEY TO GO AGAIN"
2000 PRINT "OR PRESS Q TO QUIT
2010 A$ = INKEY$:IF A$ = "" GOTO 2010
2020 IF A$ = "Q" THEN STOP
2030 GOTO 1070
2040 PRINT CHR$(26)
2050 PRINT"**********************************************"
2060 PRINT"* *"
2070 PRINT"* MASTERMIND *"
2080 PRINT"* *"
2090 PRINT"**********************************************"
2100 PRINT
2110 RETURN
2120 PRINT CHR$(26)
2130 PRINT"INSTRUCTIONS:
2140 PRINT
2150 PRINT"1 TYPE A SECRET WORD WITH A MAXIMUM OF 15
2160 PRINT" LETTERS. IT MUST BE IN CAPS.
2170 PRINT"--------------------------------------------------
2180 PRINT"2 TYPE THE NUMBER OF GUESSES YOU WANT YOUR
2190 PRINT" OPPONENT TO HAVE. MUST BE 1 TO 99.
2200 PRINT"--------------------------------------------------
2210 PRINT"3 TYPE IN THE TIME ALLOWED FOR EACH GUESS.
2220 PRINT" THE MINIMUM TIME IS 30 SECONDS.
2230 PRINT" NOTE: IF YOU WANT YOUR OPPONENT TO HAVE
2240 PRINT" UNLIMITED TIME ENTER NOTHING, JUST HIT
2250 PRINT" THE RETURN KEY.
2260 PRINT"--------------------------------------------------
2270 PRINT"4 FINALLY, ENTER A CLUE. IF YOU DO NOT WANT
2280 PRINT" TO GIVE A CLUE SIMPLY HIT RETURN.
2290 PRINT"--------------------------------------------------
2300 PRINT" AFTER THOSE FOUR STEPS THE SCREEN WILL
2310 PRINT" CLEAR AND ITS YOUR OPPONENTS TURN.
2320 PRINT:PRINT:PRINT"HIT ANY KEY FOR MORE INSTRUCTIONS
2330 A$=INKEY$:IF A$ = "" GOTO 2330
2340 PRINT CHR$(26)
2350 PRINT"INSTRUCTIONS FOR OPPONENTS:
2360 PRINT
2370 PRINT"1 YOU WILL BE TOLD HOW MANY LETTERS ARE
2380 PRINT" IN THE WORD AND HOW MANY GUESSES YOU HAVE
2390 PRINT" REMAINING.
2400 PRINT"-------------------------------------------------
2410 PRINT"2 IF YOUR OPPONENT HAS GIVEN YOU A TIME LIMIT
2420 PRINT" FOR EACH GUESS YOU WILL BE TOLD.
2430 PRINT" IF THERE IS A LIMIT THE ALARM WILL BEEP
2440 PRINT" 10 TIMES WITH A COUNTER SHOWING AT THE
2450 PRINT" BOTTOM LEFT. IF THE COUNTER REACHES 10
2460 PRINT" YOU LOSE A TURN
2470 PRINT"--------------------------------------------------
2480 PRINT"3 IF THERE IS A CLUE YOU WILL BE TOLD
2490 PRINT:PRINT:PRINT"HIT ANY KEY FOR MORE INSTRUCTIONS
2500 A$=INKEY$:IF A$ = "" GOTO 2500
2510 PRINT CHR$(26)
2520 PRINT"SCORING
2530 PRINT
2540 PRINT"1 AN OPPONENT CAN KEY ONLY CAPITAL LETTERS.
2550 PRINT" THE COMPUTER BEGINS CALCULATING WHEN THE
2560 PRINT" REQUIRED NUMBER OF LETTERS HAVE BEEN KEYED.
2570 PRINT" AN OPPONENT MAY BACK SPACE AND OVERTYPE
2580 PRINT" LETTERS IF NEEDED.
2590 PRINT" PRESS QQQQQ ETC TO QUIT AT ANY TIME
2600 PRINT"--------------------------------------------------
2610 PRINT"2 THE COMPUTER SCORES AS FOLLOWS:
2620 PRINT" X FOR A CORRECT LETTER IN CORRECT POSITION
2630 PRINT" O FOR A CORRECT LETTER IN WRONG POSITION
2640 PRINT:PRINT:PRINT"HIT ANY KEY TO START THE GAME
2650 A$=INKEY$:IF A$="" GOTO 2650
2660 RETURN
2670 STOP 'IN CASE WE GET HERE WHICH WE CANNOT
HIT ANY KEY TO START THE GAME
2650 A$=INKEY$:IF A$="" GOTO 2650
2660 RETURN
2670 STOP 'IN CASE WE GET HERE WHICH WE C