How Did You Do?
Seven guesses — is that good? The player doesn't know until you tell them. A rating turns a bare number into a verdict, and a verdict makes the player want to play again. The finishing touch that completes Lucky Number.
The game says "You found it in 7 guesses." But 7 is just a number. Is that good? The player doesn't know — so the program should tell them. One last touch turns a count into a verdict.
10 BORDER 0: PAPER 0: INK 7: CLS
20 RANDOMIZE
30 LET n = INT (RND * 100) + 1
40 LET c = 0
50 INVERSE 1: PRINT AT 2, 0; " *** LUCKY NUMBER *** ": INVERSE 0
60 PRINT
70 PRINT "I'm thinking of a number"
80 PRINT "between 1 and 100."
90 PRINT
100 PAUSE 0
110 CLS
120 INPUT "Your guess: "; g
130 LET c = c + 1
140 LET d = ABS (g - n)
150 IF d > 50 THEN BORDER 1
160 IF d > 25 AND d <= 50 THEN BORDER 5
170 IF d > 10 AND d <= 25 THEN BORDER 6
180 IF d > 5 AND d <= 10 THEN BORDER 2
190 IF d <= 5 THEN BORDER 7
200 IF g = n THEN GO TO 300
210 IF g < n THEN PRINT "Too low!": BEEP 0.1, -5
220 IF g > n THEN PRINT "Too high!": BEEP 0.1, 5
230 GO TO 120
300 BORDER 4: BEEP 0.1, 10: BEEP 0.1, 15: BEEP 0.1, 20: BEEP 0.2, 24
310 PRINT "Got it! The number was "; n
320 PRINT "You found it in "; c; " guesses."
330 PRINT
340 IF c <= 5 THEN PRINT "Incredible!"
350 IF c > 5 AND c <= 10 THEN PRINT "Not bad!"
360 IF c > 10 THEN PRINT "Keep trying!"
Four lines at the end: a blank line, then three IFs that map the guess count to a rating.
A number, judged
The three IFs split the guess count into bands, the same shape as the colour border:
- 5 or fewer — "Incredible!"
- 6 to 10 — "Not bad!"
- Over 10 — "Keep trying!"
A bare "7" means nothing on its own. "Not bad!" reframes it: now the player knows where they stand, and — this is the point — wants to do better next time. A verdict gives the score stakes. It's the difference between a program that stops and a game that pulls you back in.
Make it yours
This is your game now. Change the ratings to your own voice — "Lucky!" or "The Oracle is unimpressed." Move the thresholds: "Incredible" at 5 assumes a 1–100 range, so if you narrow the range, tighten the ratings too. Change the title, the colours, the fanfare. Add a high score. Every line is yours to bend.
What you built
Lucky Number opened as the guess loop you already knew, and across five units you turned it into a game: a fresh secret each play, a border that runs hot and cold, sound that points the way, an offered start, a framed win, and a verdict. None of it changed what the program does — it still picks a number and takes guesses. All of it changed how the game feels. That layer — feedback, framing, stakes — is what game design is.
Next: Oracle Stone — ask it a question, and it pretends to think before it answers.