Several sample fixes/improvements by Alan Ratliff
**In "Simple Pong" I eliminated the problem of the bouncing ball erasing the bottom wall of the field, created a means of scoring points (when the ball gets past a paddle and hits the "back wall", the other player scores a point -- one point each time the ball gets past the paddle, so that multiple impacts that typically occur don't count a point each), and allowed the possibility of equiangular bouncing off the paddles, instead of always just bouncing straight back along the same trajectory.
Also, this game isn't really suited for "paddle"-type control on this platform, as there is typically just one mouse for that purpose, not practical for two players. However, with key-control, the comments cited a problem of needing to be able to handle multiple keystrokes. As it was, when one player pressed a directional key, their paddle would start moving and not stop until it hit its upper/lower limit. It would stop, though, if a non-operational key were pressed, or one of the other player's keys. This latter meant that one player hitting a key to move their paddle would stop the other player's paddle from moving, which was where the real problem occurred. Underlying this was the fact all movement was controlled by the single last key pressed. I changed it by introducing variables to control the movement of each paddle which would be set by the appropriate keystrokes. I also added a specific key for each player to stop their paddle's motion, as well as duplicate directional keys so that each player's key group would be suitable for either the left or right hand: with either hand they could press "down" with the index finger, "stop" with the middle finger, and "up" with the fourth finger.
***With "Hangman", I did the usual random-seeding, avoided the initial-keystroke-termination problem, and simplified the word-choosing algorithm, and set it to go through all words in a difficulty-group, then continue by choosing among the 9 words in that group least-recently used. I also incorporated level-change options in the new-game menu, and I greatly reduced the code for the circle-drawing routine (while still utilizing principles of geometry), and re-organized the parts-drawing routines so the "smiley face" routine could be simplified.
***Next is the "Door Detector" game program. Its problems were subtle ones, principally that it would occasionally crash with an "Illegal quantity error in line 320". This concerned the value of "G" that was assigned as COLOR. This crash was quirky, as the program maintained the value of G between 0 and 15 in some places, but not others, while supposedly the value given to COLOR is not "Illegal" unless it's outside the byte-range 0-255; within that range the value merely has its lower nybble isolated to serve as the COLOR value. I put in a tweak to print the value of G to be used in line 320, and upon a crash it was shown as 50. I'm not sure why it occurred this way, but I figured that a way to be safe would be to just *always* ensure that G is kept in the range 0 to 15.
The program also had the "standard" problem that it didn't seed the random-number generator, so it always played an identical "game sequence" every time, instead of different permutaions as you'd normally expect with "random numbers".
Another "subtle" shortcoming I noticed concerned the fact that in successive "rooms" within a game, the "Death Zone" is an incrementally "thick" border region around the room, and in any given room the "exit" could be randomly placed right next to the "Death Zone's" edge, and as the player would start the next room where the previous room's exit was, a next-to-Death-Zone exit would mean the player would start the next room IN the Death Zone (its innermost layer). As it happened, in the one game-sequence that occurred, the final room's exit in the first game was along the Death Zone's edge, but as it was the FINAL room anyway, the next-room starting location was not an issue. I figured, though, that with the game properly randomized, the issue COULD come up, so I now use line 50 (commented in 40) to bump the player out of the Death Zone if they're starting a room within the Zone.
***With "Columns" there was the usual lack of random seeding, and again a rather drab color scheme for the lower number of colors. I also reduced the maximum number of colors by one, so that it would never use both of the indistinguishable grays. Also a comment on line 2840 mentioned a "Future animated splash screen", so I created one.
***The primary problem with "Chase" was lack of random seeding, so it always played the same sequence of games, which would wear out quickly. There were also a few duplicate line numbers I eliminated. The game presentation could also be improved by simply VTABbing up to display each new board layout over the old one, rather than scrolling up for new diagrams. Also, I documented in the instructions how a player should expect to encounter impossible situations frequently, and just move on when that happens; and I generally streamlined the code considerably, including cleaning up messy text displays.
***With "Gaussian distribution 2D", trying an example resulted in an "Illegal quantity in line 160". This was caused by the hires X coordinate just exceeding the maximum 279, apparently due to imprecise calculations. Reducing the designated maximum (assigned to 'w') in line 30 to a value of 278 seems to clear this up. I also reduced the maximum Y a bit so the diagram would not butt against the text on screen-line 21. In addition, there were a few (i.e. redundant) explicit expressions of the value of PI, all then multiplied by 2 to obtain 2PI; I replaced these with one derivation of PI/4 via ATN(1), multiplied by 8 to obtain 2PI, and stored it in variable 'p2' (for "PI * 2").
***With "Original Series Enterprise" I created a much more accurate depiction of said entity. To be honest, it really isn't Gil Keidar's anymore, it's mine...
***Finally, with "Prime Factors", the old version, in a number of cases, did not produce the correct results. I have fixed that problem. I also replaced its series of like multiplications (e.g. 2x2x2x2x2x2) with a base^exponent exprression (2^6).
2024-02-19 19:03:15 +00:00
|
|
|
100 REM ***HANGMAN**
|
|
|
|
120 REM BY MIKE GLEASON, 1986, 2011
|
|
|
|
130 REM MODIFIED BY ALAN RATLIFF, 2020
|
|
|
|
140 REM
|
|
|
|
160 REM ==WELCOME SCREEN==
|
|
|
|
180 TEXT : PR#0 : HOME :SW = PEEK (33):ES$ = "": GG = 1: DD = 0.040: JY = 0
|
|
|
|
188 DD = 0.0010 : SND = 0: REM Hack to work in the JavaScript emulator
|
|
|
|
|
|
|
|
380 VTAB 12:I = SW / 2 - 6: HTAB I: PRINT "_ _ _ _ _ _ _";
|
|
|
|
400 GOSUB 13800 : REM INIT SOUND
|
|
|
|
420 D = 1: GOSUB 800: HTAB I + 8: PRINT "M";
|
|
|
|
440 D = 1: GOSUB 800: HTAB I + 4: PRINT "N";: HTAB I + 12: PRINT "N";
|
|
|
|
460 D = 1: GOSUB 800: HTAB I + 6: PRINT "G";
|
|
|
|
480 D = 1: GOSUB 800: HTAB I + 2: PRINT "A";: HTAB I + 10: PRINT "A";
|
|
|
|
500 D = 1: GOSUB 800: HTAB I + 0: PRINT "H";
|
|
|
|
520 D = 2: GOSUB 800: HTAB I + 0: FLASH : PRINT "H A N G M A N": NORMAL : PRINT
|
|
|
|
540 D = 2: GOSUB 800
|
|
|
|
560 A$ = "(C) 1986, 2011 by Mike Gleason"
|
|
|
|
580 I = SW / 2 - LEN (A$) / 2
|
|
|
|
600 HTAB I: PRINT A$;
|
|
|
|
620 A$ = "Loading, please wait..."
|
|
|
|
640 I = SW / 2 - ( LEN (A$) - 3) / 2
|
|
|
|
660 VTAB 23: HTAB I: PRINT A$;: JY=1
|
|
|
|
680 GOTO 1100
|
|
|
|
|
|
|
|
800 REM ==DELAY SUBROUTINE==
|
|
|
|
820 REM Unfortunately, I don't know of a way to make this delay constant
|
|
|
|
840 REM across CPU speeds. For example, in an emulator, this code may
|
|
|
|
860 REM run too fast. You can try changing DD to modulate the speed.
|
|
|
|
880 IF PEEK (49152) > 127 THEN 940: REM SKIP DELAY UPON KEYBOARD INPUT
|
|
|
|
900 D = D - DD: IF D > 0 THEN 880
|
|
|
|
920 GOTO 980
|
|
|
|
940 A$ = CHR$ ( PEEK (49152) - 128)
|
|
|
|
960 IF JY=1 THEN POKE 49168,0
|
|
|
|
980 RETURN
|
|
|
|
|
|
|
|
1100 REM ==INITIALIZE PROGRAM==
|
|
|
|
1160 GOSUB 13200: REM LOAD WORDS
|
|
|
|
1180 GOSUB 2500: REM SETUP SCREEN
|
|
|
|
1200 PRINT "Shall I be [e]asy, "
|
|
|
|
1220 PRINT " [m]edium, "
|
|
|
|
1240 PRINT " or [h]ard on you? ";
|
|
|
|
1260 POKE 49168,0: REM CLEAR KEYBD BUFFER
|
|
|
|
1280 GOSUB 1800
|
|
|
|
1300 IF A$ = "E" THEN EZ = 1: GOTO 1400
|
|
|
|
1320 IF A$ = "M" THEN EZ = 2: GOTO 1400
|
|
|
|
1340 IF A$ = "H" THEN EZ = 3: GOTO 1400
|
|
|
|
1360 PRINT : GOTO 1200
|
|
|
|
|
|
|
|
1400 REM ==GAME LOOP==
|
|
|
|
1420 HOME:VTAB 24
|
|
|
|
1440 CHEET = 0
|
|
|
|
1460 PRINT : GOSUB 2100
|
|
|
|
1470 D = 53909/((EZ=2)*13+EZ*3+28)
|
|
|
|
1480 PRINT "Play again? (";: GU$ = "Yes/": GOSUB 1750: GU$ = "No": GOSUB 1750
|
|
|
|
1490 REM WHEN OFFERING NEW GAME, ALLOW PLAYER TO CHANGE DIFFICULTY LEVEL IF DESIRED
|
|
|
|
1500 FOR I = 1 TO 3: IF I<>EZ THEN PRINT "/";: GU$ = MID$("EasyMediumHard",(I=3)*2+I*4-3,I*2+2): GOSUB 1750
|
|
|
|
1510 NEXT: PRINT ") ";
|
|
|
|
1520 GOSUB 1800: A = ASC(A$)*2-107: I = D/A
|
|
|
|
1530 I = INT(I)=I: IF I THEN EZ = (A>31)+(A=37)+1
|
|
|
|
1540 IF A$ = "Y" OR I GOTO 1400
|
|
|
|
1550 ES$ = "": IF A$ <> "N" GOTO 1520
|
|
|
|
|
|
|
|
1600 REM ==CLEANUP AND EXIT==
|
|
|
|
1620 TEXT
|
|
|
|
1640 IF ES$ = "" THEN HOME: PRINT "GOOD BYE.": END
|
|
|
|
1660 GOSUB 14300: REM RING BELL
|
|
|
|
1680 PRINT : PRINT "* ERROR: ";ES$;"."
|
|
|
|
1700 END
|
|
|
|
|
|
|
|
1740 REM PRINT FIRST CHAR OF STRING GU$ INVERSE, THE REST NORMAL
|
|
|
|
1750 INVERSE: PRINT LEFT$(GU$,1);: NORMAL: PRINT MID$(GU$,2);: RETURN
|
|
|
|
|
|
|
|
1800 REM ==GET 1 UPPERCASE CHAR==
|
|
|
|
1820 GET A$
|
|
|
|
1840 IF A$ = CHR$ (1) THEN CHEET = 1
|
|
|
|
1860 IF A$ = CHR$ (27) OR A$ = CHR$ (3) THEN POP: GOTO 1600
|
|
|
|
1880 IF A$ > "_" THEN A$ = CHR$(ASC(A$) - 32)
|
|
|
|
1900 IF A$ < "A" OR A$ > "Z" THEN GOSUB 14300: GOTO 1820: REM RING BELL, TRY AGAIN
|
|
|
|
2020 RETURN
|
|
|
|
|
|
|
|
2100 REM ==GAME SUBROUTINE==
|
|
|
|
2120 GOSUB 9600: REM CHOOSE A SECRET WORD
|
|
|
|
2130 GOSUB 3600: REM SETUP GRAPHICS
|
|
|
|
2140 REM R=0:GOTO 7370 - WOULD DISPLAY TABLE OF WORDS AND THEIR DIFFICULTY SCORES
|
|
|
|
2150 OGUESS$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ": REM FULL ALPHABET AVAILABLE
|
|
|
|
2160 POKE 49168,0: REM CLEAR KEYB BUFFER
|
|
|
|
2180 NLIMBS = 0:GAMEOVER = 0
|
|
|
|
2220 HOME: VTAB 21
|
|
|
|
2300 REM --GUESS LOOP--
|
|
|
|
2320 GOSUB 7400: REM DISPLAY STATUS
|
|
|
|
2340 GOSUB 7700: REM GET A GUESS
|
|
|
|
2360 GOSUB 8100: REM CHECK GUESS
|
|
|
|
2380 IF NOT GAMEOVER THEN 2300
|
|
|
|
2400 RETURN
|
|
|
|
|
|
|
|
2500 REM ==SETUP SCREEN==
|
|
|
|
2520 TEXT : CB$ = "an" : CA$ = "ANIMAL"
|
|
|
|
2525 VTAB 12:HTAB 14: INVERSE : PRINT "H A N G M A N": NORMAL:VTAB 24
|
|
|
|
2530 FOR I=1 TO 11:PRINT:FOR D=1 TO 90:NEXT D,I:VTAB 5
|
|
|
|
2540 A$ = "Welcome to HANGMAN!": GOSUB 3000: PRINT : PRINT
|
|
|
|
2560 PRINT "You have been condemned for execution."
|
|
|
|
2580 PRINT "To escape this fate, you must guess"
|
|
|
|
2600 PRINT "the secret word (";CB$;" ";CA$;") by "
|
|
|
|
2620 PRINT "choosing letters from the alphabet."
|
|
|
|
2640 PRINT
|
|
|
|
2660 PRINT "The secret word's letters will be shown"
|
|
|
|
2680 PRINT "as dashes at first, and then will"
|
|
|
|
2700 PRINT "change to letters as you guess them."
|
|
|
|
2720 PRINT
|
|
|
|
2740 PRINT "With each incorrect guess, one body"
|
|
|
|
2760 PRINT "part will be added to the gallows."
|
|
|
|
2780 PRINT "Guess the secret word before all your"
|
|
|
|
2800 PRINT "limbs are hanging!"
|
|
|
|
2820 PRINT
|
|
|
|
2840 A$ = "Press any key to begin!": GOSUB 3000
|
|
|
|
2841 POKE 49168,0: REM CLEAR KEYB BUFFER
|
|
|
|
2842 I=1: REM Initialize random number generator
|
|
|
|
2850 GET A$
|
|
|
|
2860 I=RND(-PEEK(79)*999-PEEK(78))
|
|
|
|
2880 HTAB 1: CALL - 868: REM ERASE STATUS MESSAGE
|
|
|
|
2900 RETURN
|
|
|
|
|
|
|
|
3000 REM ==PRINT CENTERED==
|
|
|
|
3020 HTAB 20 - LEN (A$) / 2
|
|
|
|
3040 PRINT A$;
|
|
|
|
3060 RETURN
|
|
|
|
|
|
|
|
3500 REM ==DRAW SMILEY FACE==
|
|
|
|
3510 IF NOT GG THEN RETURN
|
|
|
|
3520 Z=0: HCOLOR=1: GOSUB 3880: REM ERASE GALLOWS
|
|
|
|
3530 ON NLIMBS<>4 GOSUB 4020: REM ERASE BODY, DRAW HEAD & FACE, AS NECESSARY
|
|
|
|
3540 HCOLOR=5: HPLOT 138,58 TO 143,62 TO 149,62 TO 154,58: REM DRAW SMILE
|
|
|
|
3550 RETURN
|
|
|
|
|
|
|
|
3600 REM ==SET UP GRAPHICS==
|
|
|
|
3620 IF NOT GG THEN RETURN
|
|
|
|
3640 HGR : GW=280 : GH=160 : Z=1 : REM THIS IS ALL FOR NOW
|
|
|
|
|
|
|
|
3800 REM ==DRAW GALLOWS==
|
|
|
|
3820 IF NOT GG THEN RETURN
|
|
|
|
3840 HCOLOR=1:FOR I=GH-1 TO 152 STEP -1:HPLOT 0,I TO GW-1,I:NEXT I
|
|
|
|
3860 HCOLOR=3
|
|
|
|
3880 FOR I=152 TO 148 STEP -1:HPLOT 70,I TO 210,I:HCOLOR=Z*3:NEXT I
|
|
|
|
3900 FOR I=80 TO 88:HPLOT I,10 TO I,147:NEXT I
|
|
|
|
3920 FOR I=10 TO 18:HPLOT 88,I TO 147,I:NEXT I
|
|
|
|
3940 FOR I=0 TO 7:HPLOT 80,48+I TO 110+I,18:NEXT I
|
|
|
|
3960 FOR I=145 TO 147:HPLOT I,18 TO I,29:NEXT I
|
|
|
|
3980 RETURN
|
|
|
|
|
|
|
|
4000 REM ==DRAW BODY PART==
|
|
|
|
4020 ON (NLIMBS<4 AND NOT Z)+NLIMBS GOTO 4300, 4500, 4700, 4900, 5500, 5400, 5300, 5200, 5100, 5000
|
|
|
|
|
|
|
|
4300 REM ==DRAW HEAD==
|
|
|
|
4320 REM Note: It'd be quicker (and use less code) to just HPLOT out the
|
|
|
|
4340 REM circle by hand rather than calling my CIRCLE2 subroutine, but
|
|
|
|
4360 REM then the trigonometry lesson would be wasted.
|
|
|
|
4370 REM N.B.: LESS CODE USED, REAL GEOMETRY LESSON NOT WASTED - SIN AND COS NOT NEEDED
|
|
|
|
4380 REM HCOLOR=2: HPLOT 126,30 TO 166,30 TO 166,70 TO 126,70 TO 126,30
|
|
|
|
4420 RADIUS=20: CX=146: CY=50: FILL=0: HC=2: GOSUB 6000
|
|
|
|
4430 IF Z THEN RETURN
|
|
|
|
|
|
|
|
4500 REM ==DRAW RIGHT EYE==
|
|
|
|
4510 REM (REMEMBER THAT THEIR RIGHT EYE WE SEE ON THE LEFT)
|
|
|
|
4520 HCOLOR=6:HPLOT 137,43 TO 140,43
|
|
|
|
4540 HPLOT 136,44 TO 141,44
|
|
|
|
4560 HPLOT 137,45 TO 140,45
|
|
|
|
4580 IF Z THEN RETURN
|
|
|
|
|
|
|
|
4700 REM ==DRAW LEFT EYE==
|
|
|
|
4720 HCOLOR=6:HPLOT 152,43 TO 155,43
|
|
|
|
4740 HPLOT 151,44 TO 156,44
|
|
|
|
4760 HPLOT 152,45 TO 155,45
|
|
|
|
4780 IF Z THEN RETURN
|
|
|
|
|
|
|
|
4900 REM ==DRAW NOSE==
|
|
|
|
4920 HCOLOR=(FILL<1)*3
|
|
|
|
4980 HPLOT 146,48 TO 143,52 TO 146,52
|
|
|
|
4990 RETURN
|
|
|
|
|
|
|
|
5000 REM ==DRAW LEFT LEG==
|
|
|
|
5020 HPLOT 146,106 TO 176,140 TO 188,133
|
|
|
|
5040 RETURN
|
|
|
|
|
|
|
|
5100 REM ==DRAW RIGHT LEG==
|
|
|
|
5120 HPLOT 146,106 TO 116,140 TO 104,133
|
|
|
|
5140 IF Z THEN RETURN
|
|
|
|
|
|
|
|
5200 REM ==DRAW LEFT ARM==
|
|
|
|
5220 HPLOT 146,88 TO 176,58
|
|
|
|
5240 IF Z THEN RETURN
|
|
|
|
|
|
|
|
5300 REM ==DRAW RIGHT ARM==
|
|
|
|
5320 HPLOT 146,88 TO 116,58
|
|
|
|
5340 IF Z THEN RETURN
|
|
|
|
|
|
|
|
5400 REM ==DRAW TORSO==
|
|
|
|
5420 IF Z THEN HCOLOR= 2
|
|
|
|
5430 HPLOT 146,70 TO 146,106
|
|
|
|
5440 IF Z THEN RETURN
|
|
|
|
|
|
|
|
5500 REM ==DRAW SAD MOUTH==
|
|
|
|
5520 HCOLOR=5*Z
|
|
|
|
5530 HPLOT 140,60 TO 143,56 TO 149,56 TO 152,60
|
|
|
|
5540 RETURN
|
|
|
|
|
|
|
|
6000 REM *** SUBROUTINE: CIRCLE2 (REWRITTEN SIMPLIFIED)
|
|
|
|
6020 REM * IN: RADIUS
|
|
|
|
6040 REM * IN: CX (X COORDINATE OF CENTER)
|
|
|
|
6060 REM * IN: CY (Y COORDINATE OF CENTER)
|
|
|
|
6080 REM * IN: FILL (0 OR 1)
|
|
|
|
6100 REM * IN: HC (HCOLOR)
|
|
|
|
6110 A=.06: F=.9982: HCOLOR=HC: R=1: REM R = ASPECT RATIO; CAN BE CHANGED TO DRAW ORTHOGONAL ELLIPSES
|
|
|
|
6120 FOR D=0 TO NOT FILL STEP .5
|
|
|
|
6130 X=RADIUS-D: Y=0: HPLOT X+CX,CY
|
|
|
|
6140 FOR I=1 TO 6.3/A: H=Y*A*R+X: Y=(Y-A*X/R)*F: X=F*H: HPLOT TO X+CX,Y+CY
|
|
|
|
6150 NEXT: NEXT: IF NOT FILL THEN RETURN
|
|
|
|
6160 REM FILL IN CIRCLE, IF SPECIFIED (NEVER USED)
|
|
|
|
6170 Y=0: FOR X=1-RADIUS TO 0
|
|
|
|
6180 FOR I=0 TO 1: I=HSCRN(CX+X,CY+Y): Y=Y+NOT I: NEXT
|
|
|
|
6190 HPLOT CX-X,CY-Y TO CX-X,CY+Y: HPLOT CX+X,CY-Y-1 TO CX+X,CY+Y
|
|
|
|
7290 NEXT: RETURN
|
|
|
|
|
|
|
|
7300 REM DISPLAY TABLE OF WORDS AND THEIR DIFFICULTY SCORES (NOT USED)
|
|
|
|
7320 TEXT:PR#3:H=1:X=0:Y=0:Z=0
|
|
|
|
7330 IF NOT R THEN RESTORE : FOR D = 1 TO 105: READ A$: REM ORIGINAL VERSION
|
|
|
|
7340 IF R THEN FOR D=1 TO 105:A$=W$(ASC(MID$(L$,D,1))): REM REVISED VERSION
|
|
|
|
7350 GOSUB 12120:IF PEEK(37)>20 THEN H=H+16:VTAB 1
|
|
|
|
7360 I=(WD<=.36)-(WD>.66):X=(I=1)+X:Y=Y+NOT I:Z=(I<0)+Z:WD=INT(WD*100+.5)/100+.003:HTAB (WD<10)+H:
|
|
|
|
7370 PRINT LEFT$(STR$(WD),5-(WD<10)) SPC(1) LEFT$(A$,9):NEXT:PRINT:PRINT "X=" X " Y=" Y " Z=" Z;
|
|
|
|
7380 IF R THEN PRINT SPC(1) C(1) "," C(2) "," C(3) SPC(1) S(1) "-" S(2) "-" S(3)
|
|
|
|
7390 END
|
|
|
|
|
|
|
|
7400 REM ==DISPLAY STATUS==
|
|
|
|
7420 REM HOME
|
|
|
|
7440 IF NOT CHEET THEN 7520
|
|
|
|
7460 VTAB 21: HTAB 1: CALL -868: PRINT "* Pssst... the word is ";SECRET$;"."
|
|
|
|
7480 D = 2: GOSUB 800
|
|
|
|
7500 CHEET=0
|
|
|
|
7520 I = (SW - LEN (HIDDEN$)) / 2
|
|
|
|
7540 IF I >= 1 THEN VTAB 22: HTAB I
|
|
|
|
7580 PRINT HIDDEN$
|
|
|
|
7600 RETURN
|
|
|
|
|
|
|
|
7700 REM ==GET A GUESS==
|
|
|
|
7880 VTAB 24: HTAB 1: PRINT "Guess? (";OGUESS$;") ";
|
|
|
|
7900 GOSUB 1800: L=ASC(A$) - 64
|
|
|
|
7920 IF MID$(OGUESS$,L,1) = "." THEN GOSUB 14300: GOTO 8900: REM RING BELL ON DUPE GUESS
|
|
|
|
7940 OGUESS$ = MID$(OGUESS$,1,L - 1) + "." + MID$(OGUESS$,L + 1): REMOVE FROM OGUESS$
|
|
|
|
7980 GUESS$ = A$
|
|
|
|
8000 HTAB 1: CALL - 868
|
|
|
|
8020 REM FOR I=0 TO L:D=RND(1):NEXT I:REM TWEAK RANDOM
|
|
|
|
8025 RETURN
|
|
|
|
|
|
|
|
8100 REM ==CHECK GUESS==
|
|
|
|
8120 OK = 0:TK = 1:NHIDDEN$ = "": VTAB 22
|
|
|
|
8140 A = LEN (SECRET$): FOR I = 1 TO A
|
|
|
|
8160 IF I > 1 THEN NHIDDEN$ = NHIDDEN$ + " "
|
|
|
|
8200 A$ = MID$ (HIDDEN$,2 * I - 1,1)
|
|
|
|
8220 TK = (A$ < "_") + TK
|
|
|
|
8260 D = MID$ (SECRET$,I,1) = GUESS$: IF D THEN A$ = GUESS$: OK = OK + 1
|
|
|
|
8340 NHIDDEN$ = NHIDDEN$ + A$
|
|
|
|
8360 IF D THEN HTAB 20 - A: PRINT NHIDDEN$; CHR$(7);: GOSUB 800
|
|
|
|
8380 NEXT I: PRINT: PRINT
|
|
|
|
8400 IF NOT OK THEN 9000
|
|
|
|
8440 IF TK + OK = I THEN 9400: REM WORD IS COMPLETE
|
|
|
|
8500 REM CORRECT GUESS
|
|
|
|
8620 D = 3518034/(127 - ASC(GUESS$)): I = INT ( RND (1) * 3)
|
|
|
|
8660 IF INT(D)=D THEN PRINT MID$("AwesomeGloriousEpic",I*8+NOT I,I+7) "!!!";: GOTO 8780: REM JUST FOR JQXZ
|
|
|
|
8680 ON I GOTO 8740,8760
|
|
|
|
8720 PRINT "Bah! Lucky guess.";: GOTO 8780
|
|
|
|
8740 PRINT "Nice work!";: GOTO 8780
|
|
|
|
8760 PRINT "Good job!";
|
|
|
|
8780 HIDDEN$ = NHIDDEN$
|
|
|
|
8800 HTAB 1: GOTO 9100
|
|
|
|
|
|
|
|
8900 REM DUPLICATE GUESS
|
|
|
|
8920 VTAB 24: HTAB 1: PRINT "You already guessed '";A$;"'.";
|
|
|
|
8940 CALL -868: D=2: HTAB 1: GOSUB 800: CALL -868: GOTO 7880
|
|
|
|
|
|
|
|
9000 REM WRONG GUESS
|
|
|
|
9020 I=20: GOSUB 14200: REM BZZZ
|
|
|
|
9040 PRINT "Wrong! The secret word has no '";GUESS$;"'.";
|
|
|
|
9060 NLIMBS = NLIMBS + 1
|
|
|
|
9080 GOSUB 4000: REM SHOW NEWLY ADDED BODY PART ON THE GALLOWS
|
|
|
|
9100 D=2: IF NLIMBS<10 THEN GOSUB 800:CALL -868:RETURN
|
|
|
|
|
|
|
|
9200 REM YOU LOSE
|
|
|
|
9220 GAMEOVER = 1
|
|
|
|
9240 PRINT : HTAB 1: CALL -868: PRINT "You lose. The secret word was... "
|
|
|
|
9260 HTAB 1: CALL -868: PRINT " ";SECRET$;"."
|
|
|
|
9280 REM A$ = "48 ,27 ,57 ,54 ,72 ,54 ,114,255.": GOSUB 14000
|
|
|
|
9300 RETURN
|
|
|
|
|
|
|
|
9400 REM YOU WIN
|
|
|
|
9420 HTAB 1: CALL -868: PRINT "You WIN! You solved the secret word, "
|
|
|
|
9440 HTAB 1: CALL -868: PRINT " ";SECRET$;"."
|
|
|
|
9460 REM A$ = "128,27 ,114,54 ,114,54 ,85 ,216.": GOSUB 14000
|
|
|
|
9480 GAMEOVER = 1
|
|
|
|
9500 GOTO 3500: REM DRAW SMILEY FACE
|
|
|
|
|
|
|
|
9600 REM ==SELECT WORD==
|
|
|
|
9620 HOME:VTAB 24:REM PRINT "Choosing word, please wait...";
|
|
|
|
9640 NR = 0
|
|
|
|
9660 NR = NR + 1: IF NR > 100 THEN ES$ = "COULD NOT LOAD A VALID WORD": GOTO 1620
|
|
|
|
9680 IF NW < = 0 THEN ES$ = "NO WORDS LOADED": GOTO 1620
|
|
|
|
|
|
|
|
9690 REM NEW SIMPLIFIED ALGORITHM (WITH ALL WORDS NOW ALREADY GROUPED BY DIFFICULTY)
|
|
|
|
9700 REM GOES THROUGH ALL WORDS IN GROUP ONCE; AFTERWARD PICKS FROM GROUP'S 9 WORDS LEAST RECENTLY SEEN
|
|
|
|
9710 WI = INT((C(EZ)+9*NOT C(EZ))*RND(1))+S(EZ)
|
|
|
|
9720 C(EZ) = C(EZ)-(C(EZ)>0)
|
|
|
|
9730 SECRET$ = W$(ASC(MID$(L$,WI,1))): REM FIND WORD IN INDEXED ARRAY
|
|
|
|
9740 REM MOVE CHOSEN WORD TO THE END OF ITS GROUP SO IT WON'T BE PICKED AGAIN FOR A LONG TIME
|
|
|
|
9750 IF WI+1<S(EZ+1) THEN L$ = MID$(L$,1,WI-1)+MID$(L$,WI+1,S(EZ+1)-WI-1)+MID$(L$,WI,1)+MID$(L$,S(EZ+1))
|
|
|
|
|
|
|
|
10320 WO = WI
|
|
|
|
10420 HIDDEN$ = ""
|
|
|
|
10440 FOR I = 1 TO LEN (SECRET$)
|
|
|
|
10500 C = ASC ( MID$ (SECRET$,I,1))
|
|
|
|
10520 IF C < AA OR C > AZ THEN 10560
|
|
|
|
10540 HIDDEN$ = HIDDEN$ + " _": GOTO 10580
|
|
|
|
10560 HIDDEN$ = HIDDEN$ + " " + MID$ (SECRET$,I,1)
|
|
|
|
10580 NEXT I: HIDDEN$ = MID$(HIDDEN$,2)
|
|
|
|
10600 HTAB 1: CALL - 868: REM ERASE STATUS MESSAGE
|
|
|
|
10620 RETURN
|
|
|
|
|
|
|
|
10700 REM ==COUNT AVAILABLE WORDS==
|
|
|
|
10720 REM THE ARRAYS BELOW ARE USED TO CALCULATE LETTER FREQUENCIES, WHICH IN
|
|
|
|
10740 REM TURN ARE USED TO CATEGORIZE WORDS INTO EASY, MEDIUM, AND HARD LEVELS.
|
|
|
|
10760 REM THE FQ TABLE IS INITIALIZED TO THE FREQUENCIES CORRESPONDING TO
|
|
|
|
10780 REM OVERALL ENGLISH LANGUAGE USAGE. IF CQ<>0, THEN WE OVERWRITE THESE
|
|
|
|
10800 REM WITH THE FREQS DETERMINED FROM THE WORD LIST ITSELF, WHICH IS
|
|
|
|
10820 REM MORE ACCURATE BUT TAKES A LOT OF TIME TO DO AT STARTUP.
|
|
|
|
10840 DIM W$(105),S(4),C(3),FQ(27),FC(27)
|
|
|
|
10860 DATA 8.167,1.492,2.782,4.253,12.702,2.228,2.015,6.094,6.966
|
|
|
|
11040 DATA .153,.772,4.025,2.406,6.749,7.507,1.929,.095,5.987
|
|
|
|
11220 DATA 6.327,9.056,2.758,.978,2.360,.150,1.974,.074,0
|
|
|
|
11380 CQ = 0
|
|
|
|
11400 NW = 0:NB = 0:L$ = ""
|
|
|
|
11420 FOR I = 0 TO 26: READ FQ(I): FC(I) = 0: NEXT I
|
|
|
|
11440 READ SECRET$
|
|
|
|
11460 IF SECRET$ = "*NO MORE WORDS*" THEN 11700
|
|
|
|
11480 L = LEN (SECRET$): IF CQ = 0 THEN 11620
|
|
|
|
11500 AA = ASC ("A"): AZ = ASC ("Z")
|
|
|
|
11520 FOR I = 1 TO L
|
|
|
|
11540 C = ASC ( MID$ (SECRET$,I,1))
|
|
|
|
11560 IF C < AA OR C > AZ THEN 11600
|
|
|
|
11580 C = C - AA:FC(C) = FC(C) + 1
|
|
|
|
11600 NEXT I
|
|
|
|
11620 NW = NW + 1: L$ = L$ + CHR$(NW): W$(NW) = SECRET$: REM STORE WORDS IN AN INDEXED ARRAY
|
|
|
|
11640 IF NW > 10000 THEN ES$ = "INVALID WORD DATA": GOTO 1620
|
|
|
|
11660 IF L < 3 OR L > 20 THEN NB = NB + 1
|
|
|
|
11680 GOTO 11440
|
|
|
|
|
|
|
|
11700 IF NW < 1 OR NB > = NW THEN ES$ = "INVALID WORD DATA": GOTO 1620
|
|
|
|
11800 REM COMPUTE ALPHABET FREQUENCIES
|
|
|
|
11820 FOR I = 0 TO 25:FC(26) = FC(26) + FC(I): NEXT I
|
|
|
|
11840 IF CQ THEN FOR I = 0 TO 25:FQ(I) = FC(I) * 100 / FC(26): NEXT I
|
|
|
|
11900 REM GOSUB 12600
|
|
|
|
11920 REM GOSUB 12800
|
|
|
|
11940 REM A$="YAK": GOSUB 12100
|
|
|
|
11942 VTAB 22:PRINT:CALL -958
|
|
|
|
11943 REM GROUP WORDS INTO EASY, MEDIUM, AND HARD BY REARRANGING INDEX STRING L$
|
|
|
|
11944 S(1)=1:S(2)=1:S(3)=1:S(4)=NW+1:J=1:FOR R=1 TO NW:A$=W$(R):GOSUB 12120
|
|
|
|
11946 D = (WD > .66)-(WD <= .36): C(D+2)=C(D+2)+1: S(2)=(D<0)+S(2): S(3)=(D<1)+S(3)
|
|
|
|
11948 IF D<0 AND R>1 THEN L$ = MID$(L$,J,1)+LEFT$(L$,J-1)+MID$(L$,J+1)
|
|
|
|
11950 IF D=1 THEN L$ = MID$(L$,1,J-1)+MID$(L$,J+1)+MID$(L$,J,1)
|
|
|
|
11952 J=(D<1)+J:NEXT:L$=L$+"X":REM R=1:GOTO 7370
|
|
|
|
11960 RETURN
|
|
|
|
|
|
|
|
12100 REM ==CALCULATE WORD DIFFICULTY==
|
|
|
|
12120 IF FQ(0) < = 0 THEN 12440
|
|
|
|
12140 WD = 0:AA = ASC ("A"):AZ = ASC ("Z")
|
|
|
|
12160 L = LEN (A$)
|
|
|
|
12180 FOR I = 1 TO L
|
|
|
|
12200 C = ASC ( MID$ (A$,I,1))
|
|
|
|
12220 IF C < AA OR C > AZ THEN 12280
|
|
|
|
12240 QC = FQ(C - AA)
|
|
|
|
12260 WD = WD + 1 / (QC * QC)
|
|
|
|
12280 NEXT I
|
|
|
|
12300 IF WD < = 0 OR L < = 0 THEN WD = 0
|
|
|
|
12345 REM IF A SHORT WORD AND A LONG WORD SCORED THE SAME, THE SHORT WORD MUST HAVE 'HARDER' LETTERS
|
|
|
|
12400 WD = WD * 2.25 / SQR(L): REM
|
|
|
|
12500 REM HTAB 1:PRINT:PRINT "DIFFICULTY FOR ";A$;" = ";WD;".":PRINT
|
|
|
|
12520 RETURN
|
|
|
|
|
|
|
|
12600 REM ==PRINT FREQUENCIES==
|
|
|
|
12620 HTAB 1: PRINT : PRINT
|
|
|
|
12640 AA = ASC ("A")
|
|
|
|
12660 FOR I = 1 TO 13
|
|
|
|
12680 PRINT CHR$ (AA + I - 1);": ";FQ(I - 1);" "; CHR$ (AA + I - 1 + 13);": ";FQ(I - 1 + 13)
|
|
|
|
12700 NEXT I
|
|
|
|
12720 PRINT : INPUT "PRESS RETURN TO CONTINUE...";A$
|
|
|
|
12740 RETURN
|
|
|
|
|
|
|
|
12800 REM ==CALCULATE AVERAGE WORD DIFFICULTY==
|
|
|
|
12820 RESTORE
|
|
|
|
12840 NW = 0:TD = 0:D0 = 999999:D9 = - 1:W0$ = "":W9$ = ""
|
|
|
|
12860 READ SECRET$
|
|
|
|
12880 IF SECRET$ = "*NO MORE WORDS*" THEN 13000
|
|
|
|
12900 A$ = SECRET$: GOSUB 12100
|
|
|
|
12920 NW = NW + 1:TD = TD + WD
|
|
|
|
12940 IF WD < D0 THEN D0 = WD:W0$ = A$
|
|
|
|
12960 IF WD > D9 THEN D9 = WD:W9$ = A$
|
|
|
|
12980 GOTO 12860
|
|
|
|
13000 IF NW < = 0 THEN 13140
|
|
|
|
13020 TD = TD / NW
|
|
|
|
13040 HTAB 1: PRINT : PRINT
|
|
|
|
13060 PRINT "AVG DIFFICULTY = ";TD
|
|
|
|
13080 PRINT "EASIEST WORD = ";D0;", ";W0$
|
|
|
|
13100 PRINT "HARDEST WORD = ";D9;", ";W9$
|
|
|
|
13120 PRINT : INPUT "PRESS RETURN TO CONTINUE...";A$
|
|
|
|
13140 RETURN
|
|
|
|
|
|
|
|
13200 REM ==================
|
|
|
|
13220 REM DATA SECTION:
|
|
|
|
13240 REM SECRET WORDS ARE
|
|
|
|
13260 REM LISTED BELOW.
|
|
|
|
13280 REM ==================
|
|
|
|
13300 NW = 0: REM NUMBER OF WORDS LOADED (= 105)
|
|
|
|
13320 SECRET$ = ""
|
|
|
|
13340 WI = - 1: REM SECRET WORD #
|
|
|
|
13360 WO = - 1: REM PREVIOUS SECRET WORD #
|
|
|
|
13380 DATA ALLIGATOR,ANT,APE,BAT,BEAR,BEE,BIRD,BOBCAT,CAT,CENTIPEDE,CHEETAH,CHICKEN,CHIMPANZEE,CLAM,COBRA
|
|
|
|
13400 DATA CONDOR,COUGAR,COW,CROCODILE,DEER,DINGO,DOG,DONKEY,DUCK,EAGLE,ELECTRIC EEL,ELEPHANT,ELK,EMU,FISH,FOX,FROG,GAZELLE
|
|
|
|
13420 DATA GIRAFFE,GOAT,GOOSE,GORILLA,GRIZZLY BEAR,HAWK,HEDGEHOG,HIPPOPOTAMUS,HORSE,HYENA,IGUANA,JAGUAR
|
|
|
|
13440 DATA JELLYFISH,KANGAROO,KRILL,LEMUR,LEOPARD,LION,LIZARD,LLAMA,LOBSTER,LYNX,MOLE,MONKEY,MOOSE,NEWT
|
|
|
|
13460 DATA OCTOPUS,OKAPI,OPOSSUM,ORANGUTAN,OTTER,OWL,PANDA,PENGUIN,PIG,POLAR BEAR,PORCUPINE,PUMA,QUAIL
|
|
|
|
13480 DATA RABBIT,RACCOON,REINDEER,RHINOCEROS,SCORPION,SEA LION,SEAL,SHARK,SHRIMP,SNAIL,SNAKE,SPIDER,SQUID
|
|
|
|
13500 DATA SQUIRREL,TIGER,TOAD,TORTOISE,TUNA,TURKEY,TURTLE,TYRANNOSAURUS REX,VOLE,VULTURE,WALRUS,WARTHOG,WASP,WHALE,WILDCAT
|
|
|
|
13520 DATA WILDEBEEST,WOLF,WORM,YAK,ZEBRA
|
|
|
|
13540 DATA *NO MORE WORDS*
|
|
|
|
13600 REM THIS VERSION OF THE PROGRAM
|
|
|
|
13620 REM HAS DATA BUILT-IN, RATHER
|
|
|
|
13640 REM THAN USING A DATAFILE.
|
|
|
|
13660 GOTO 10700
|
|
|
|
|
|
|
|
13800 REM ==INSTALL TONE GENERATOR== (REMOVED)
|
|
|
|
13820 RETURN
|
|
|
|
|
|
|
|
14000 REM ==PLAY TUNE== (REMOVED)
|
|
|
|
14020 REM A$ = "128,27 ,114,54 ,114,54 ,85 ,216."
|
|
|
|
14040 RETURN
|
|
|
|
|
|
|
|
14200 REM ==BUZZ SPEAKER==
|
|
|
|
14220 L=PEEK(-16336):I=I-1:IF I > 0 THEN 14220
|
|
|
|
14240 RETURN
|
|
|
|
|
|
|
|
14300 REM ==RING BELL==
|
|
|
|
14340 PRINT CHR$(7);
|
|
|
|
14360 RETURN
|