QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: bplus on October 11, 2020, 04:35:43 pm

Title: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 04:35:43 pm
You know the Hi Lo Number Guessing Game where you keep guessing until you guess a secret number between 1 and 100.

Could you tell if the game had no secret number? Can you create such a game?
Title: Re: Hi Lo without Secret Number?
Post by: jack on October 11, 2020, 04:48:49 pm
who is doing the guessing, the user or the PC?
Title: Re: Hi Lo without Secret Number?
Post by: STxAxTIC on October 11, 2020, 05:07:40 pm
I want to see something in this question, but I can't yet - are you saying that the computer says "go higher" or "go lower" with a given guess, but you never get it right?

Just choose an irrational number for an answer, the user can never type it all out.
Title: Re: Hi Lo without Secret Number?
Post by: jack on October 11, 2020, 05:07:59 pm
ok, bplus
here's a small progie that will guess a number that you pick between 1 and 127
Code: [Select]
_TITLE "number guess" 
PRINT " Think of an Integer Number between 1 and 127"
PRINT "press RETURN when you have picked a number"
PRINT "and I will present you with 7 screens of numbers"
PRINT "on each screen of numbers, see if your number is there"
PRINT "and answer y or n to the question"
PRINT
DIM i%, j%, m%, n%, k%, l%, p%, yn%
yn% = 0
DIM a$
m% = 7
n% = (2 ^ m%) - 1
DIM c%(m%, (2 ^ (m% - 1)))
k% = 1
l% = 1
INPUT "Press Return to start "; a$
WHILE k% < n%
    p% = 1
    FOR i% = k% TO n% STEP k% * 2
        FOR j% = i% TO i% + k% - 1
            c%(l%, p%) = j%
            p% = p% + 1
        NEXT
    NEXT
    l% = l% + 1
    k% = k% * 2
WEND
FOR i% = 1 TO m%
    FOR j% = 1 TO (2 ^ (m% - 1)) STEP 4
        PRINT USING "####"; c%(i%, j%);
        PRINT USING "####"; c%(i%, j% + 1);
        PRINT USING "####"; c%(i%, j% + 2);
        PRINT USING "####"; c%(i%, j% + 3)
    NEXT j%
    INPUT "is your number there? ", a$
    IF a$ = "y" THEN yn% = yn% + c%(i%, 1)
    CLS
NEXT i%
PRINT "your number is "; yn%
SLEEP
Title: Re: Hi Lo without Secret Number?
Post by: jack on October 11, 2020, 05:19:58 pm
version 2, pick an integer between 1 and 31
Code: [Select]
_TITLE "number guess"
DIM a$
m% = 5
n% = (2 ^ m%) - 1
PRINT " Think of an Integer Number between 1 and "; n%
PRINT "press RETURN when you have picked a number"
PRINT "and I will present you with "; m%; " screens of numbers"
PRINT "on each screen of numbers, see if your number is there"
PRINT "and answer y or n to the question"
PRINT
DIM i%, j%, k%, l%, p%, yn%
yn% = 0
DIM c%(m%, (2 ^ (m% - 1)))
k% = 1
l% = 1
INPUT "Press Return to start "; a$
WHILE k% < n%
    p% = 1
    FOR i% = k% TO n% STEP k% * 2
        FOR j% = i% TO i% + k% - 1
            c%(l%, p%) = j%
            p% = p% + 1
        NEXT
    NEXT
    l% = l% + 1
    k% = k% * 2
WEND
FOR i% = 1 TO m%
    FOR j% = 1 TO (2 ^ (m% - 1)) STEP 4
        PRINT USING "####"; c%(i%, j%);
        PRINT USING "####"; c%(i%, j% + 1);
        PRINT USING "####"; c%(i%, j% + 2);
        PRINT USING "####"; c%(i%, j% + 3)
    NEXT j%
    INPUT "is your number there? ", a$
    IF a$ = "y" THEN yn% = yn% + c%(i%, 1)
    CLS
NEXT i%
PRINT "your number is "; yn%
SLEEP
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 05:32:29 pm
Here is a reminder how the usual game of Hi Lo goes:
Code: QB64: [Select]
  1. 'now 4 lines
  2. 1 num = ABS(INT(99 * SIN(TIMER * RND)))
  3. 2 INPUT "Guess my number between 1 and 100 (inclusive) ", guess
  4. IF guess < num THEN PRINT "Higher" ELSE IF guess > num THEN PRINT "Lower" ELSE IF guess = num THEN PRINT "Correct. You Win"
  5. IF guess = num THEN GOTO 1 ELSE GOTO 2
  6.  

Line 1 would normally be:

Code: QB64: [Select]
  1. num = int(rnd *100) + 1

The program generally starts by picking a random number between 1 and 100 and having the player/user guess. If the guess is not the number, then the program says if the guess was too High or too Low, thus the name of the Game Hi Lo.

One can write a program to appear to be using a Random number "secret" but in fact never has a secret number. It goes by other things to say if correct or too high or too low.

The numbers guessed will have the same random distribution between 1 and 100 as a normal program with a secret number. ie with 10000 games played, each number guessed between 1 and 100 will have been played around 100 times.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 05:35:40 pm
Hey jack,

I know and seen your version too, but not what I had in mind for here.

I did that trick or variation with 27 cards. Cool!
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 05:39:19 pm
Yes, @johnno56 @jack  (I saw Spock and just assumed Johnno Ha, ha!) you are guessing a number from 1 and 100 and the computer program has not set a secret number but "fakes it" so to speak when it says you are too high or low or have guessed the number.
Title: Re: Hi Lo without Secret Number?
Post by: STxAxTIC on October 11, 2020, 05:42:52 pm
I am so confused. Isn't f(RND) just as unpredictable as RND in the way you've used it? What's *not* secret about RND? You never know what it's result is until you bite into it.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 05:43:14 pm
@STxAxTIC  the program does say go higher or too high... but it also will say if you guessed.

BTW there is a 1 in 100 change you will guess right, right off the bat!
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 05:46:34 pm
I am so confused. Isn't f(RND) just as unpredictable as RND in the way you've used it? What's *not* secret about RND? You never know what it's result is until you bite into it.

Yes well RND is used quite a bit but no random number secret is set in stone when you start guessing.

And when you play the game you would not be able to tell the difference.
Title: Re: Hi Lo without Secret Number?
Post by: Gets on October 11, 2020, 07:10:14 pm
You know the Hi Lo Number Guessing Game where you keep guessing until you guess a secret number between 1 and 100.

Could you tell if the game had no secret number? Can you create such a game?

A correct answer would be generated by high/low responses regardless of whether it was chosen before the game started, and reaching that value is exactly where players would be able to tell no such number existed.

So the goal of such a program would be to keep track of previous guesses and responses and give false information for as long as possible without getting caught. Basically looking for an opportunity to tell the player that 31 is low, after it already said 30 is high, without the player noticing.

It's doable, but probably needs to be based on a more complex game in order to really pull it off.

Something like a Rubix Cube that shuffles squares around when  you aren't looking.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 07:40:33 pm
Quote
Basically looking for an opportunity to tell the player that 31 is low, after it already said 30 is high, without the player noticing.

Nope, no way, that's lying and cheating. It does track the low and high it's told the player and stays consistent with what it says.

And like in jack's variation you must arrive at the answer in maybe 7 guesses or less specially if user is using a Binary search method.
Title: Re: Hi Lo without Secret Number?
Post by: SMcNeill on October 11, 2020, 08:00:43 pm
Code: QB64: [Select]
  1. 1 SCREEN _NEWIMAGE(1280, 720, 32)
  2. 2
  3. 3 FOR j = 0 TO 1
  4.   4 CLS
  5.   5 PRINT "Bite MY Lucky Seven"
  6.   6 PRINT "Most games want you to guess from 1 to 100, but I'm smarter than them."
  7.   7 PRINT "Choose any whole number from 0 to 127, and give me 7 guesses."
  8.   8 PRINT "I bet after that time, I can tell you what the number is."
  9.   9 PRINT CHR$(13); "Choose your number and press any key to begin"
  10.   10 junk$ = INPUT$(1)
  11.   11 guess = 64
  12.   12 CLS
  13.   13 FOR i = 5 TO 0 STEP -1
  14.       14 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i + 1)
  15.       15 PRINT "For Guess #"; (6 - i); ", my guess is"; guess
  16.       16 PRINT CHR$(13); "Am I:  (0) Correct   (1) High   (2) Low"; CHR$(13)
  17.       17 PRINT "PRESS 0, 1, or 2 please for your answer =>";
  18.       18 a = VAL(INPUT$(1))
  19.       19 PRINT a; CHR$(13); CHR$(13)
  20.       20 i = i - ((a - 1) AND 2) / 2 * i 'answer 0, and we win
  21.   21 NEXT
  22.   22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i +1)
  23.   23 PRINT "Your number is "; guess
  24.   24 PRINT
  25.   25 PRINT "Would you like to:     (1) Try again"
  26.   26 PRINT "                       (2) Run away crying, unable to stop my awesome power"
  27.   27 a = VAL(INPUT$(1))
  28.   28 j = 1 - (1 AND a)
  29. 29 NEXT
  30. 30 END

There’s my overly complex version of this problem, without any use of IFs, or conditional statements.  It was my entry in an old 30-line code challenge back over at .net, ages ago.  ;)
Title: Re: Hi Lo without Secret Number?
Post by: jack on October 11, 2020, 08:22:37 pm
you can also find it at the Rosetta Code http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)
I translated the bbc basic code http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)#BBC_BASIC
Code: QB64: [Select]
  1. min% = 1
  2. max% = 100
  3. PRINT "Think of a number between "; min%; " and "; max%
  4. PRINT "I will try to guess your number."
  5.     guess% = (min% + max%) \ 2
  6.     PRINT "My guess is "; guess%
  7.     INPUT "Is it higher than, lower than or equal to your number ", answer$
  8.     SELECT CASE LEFT$(answer$, 1)
  9.         CASE "L", "l": min% = guess% + 1
  10.         CASE "H", "h": max% = guess% - 1
  11.         CASE "E", "e": EXIT DO
  12.         CASE ELSE: PRINT "Sorry, I didn't understand your answer."
  13.     END SELECT
  14. LOOP UNTIL FALSE
  15. PRINT "Goodbye."
  16.  
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 08:38:49 pm
Steve, jack you've got it backwards the program is not trying to guess the user's number. The user is trying to narrow down what the program has made up (though the challenge is to not make up any secret number).

OK time to translate the example I worked my Hi Lo Game version from.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 08:47:48 pm
I made my version of Hi Lo Game after playing around with this:
Code: QB64: [Select]
  1.  
  2. 'ref tsh73 from JB forum 2020-10-08
  3. 'https://justbasiccom.proboards.com/thread/567/guess-number-secret
  4. 'translated to QB64 b+ 2020-10-11
  5.  
  6.  
  7. 'guessANumber
  8. '   idea
  9. '   instead of making a number
  10. '   we deside on each turn
  11. 'of cource we should store numbers tried to say "no" again
  12. 'and fix probability according to not tried numbers
  13.  
  14. 'logic: loop
  15. '   get a number
  16. '   check if number is new
  17. '       if it is,
  18. '       with probabilty 1/#(numbers left) say Yes and stop
  19. '       (or else)  store it
  20. '       else say No
  21.  
  22. PRINT "---- Guess a number ----"
  23. PRINT "I made up a number, (1..9)"
  24. PRINT "- you guess it. That's all ;)"
  25. PRINT "No! Not quite."
  26. PRINT "Actually I do not made a number."
  27. PRINT "I will deside on the go."
  28.  
  29. tried$ = ""
  30.  
  31.     INPUT "Make your guess (1..9): "; guess
  32.     IF guess < 1 OR guess > 9 OR INT(guess) <> guess THEN
  33.         PRINT "Guess not valid"
  34.         GOTO cont
  35.     END IF
  36.     IF INSTR(tried$, _TRIM$(STR$(guess))) THEN
  37.         PRINT "Already tried that"
  38.         GOTO cont
  39.     END IF
  40.     numsLeft = 9 - LEN(tried$)
  41.     'print "1/";numsLeft,  'and the probability is
  42.     IF RND < 1 / numsLeft THEN
  43.         PRINT "You did it!"
  44.         EXIT WHILE
  45.     END IF
  46.     'else
  47.     tried$ = tried$ + _TRIM$(STR$(guess))
  48.     PRINT "Nope, try again"
  49.     cont:
  50. PRINT "-=* thanks for playing *=-"
  51.  
  52.  

BTW tsh73 is generous programming teacher in Russia, so maybe we can forgive his mistakes of English spelling and grammar.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 08:57:23 pm
As a joke, I posted this for reply to tsh73:

Code: QB64: [Select]
  1. _TITLE "Guess the cruel joke." ' b+ 2020-10-08 reply to tsh73 trans to QB64
  2.     INPUT "Make your guess (1..9): "; guess
  3.     IF guess < 1 OR guess > 9 OR INT(guess) <> guess THEN
  4.         PRINT "Guess not valid"
  5.         GOTO cont
  6.     END IF
  7.     IF INSTR(tried$, _TRIM$(STR$(guess))) THEN
  8.         PRINT "Already tried that"
  9.         GOTO cont
  10.     END IF
  11.     IF LEN(tried$) >= 8 THEN
  12.         PRINT "You did it!"
  13.         EXIT WHILE
  14.     END IF
  15.     'else
  16.     tried$ = tried$ + _TRIM$(STR$(guess))
  17.     PRINT "Nope, but you're getting closer!"
  18.     cont:
  19. PRINT "-=* thanks for playing *=-"
  20.  
  21.  
Title: Re: Hi Lo without Secret Number?
Post by: STxAxTIC on October 11, 2020, 09:20:09 pm
waaait, the backwards version is interesting...

Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 11, 2020, 09:30:07 pm
waaait, the backwards version is interesting...

Sure check this out:
https://www.qb64.org/forum/index.php?topic=1854.msg110907#msg110907
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 12, 2020, 11:04:54 am
Here is a distribution of "Secret Numbers" finally determined at games end in 10,000 trials:
Code: [Select]
Secret Numbers results:
Program errors = 0
1             92
2             94
3             101
4             111
5             110
6             100
7             114
8             104
9             91
10            89
11            82
12            122
13            97
14            97
15            115
16            109
17            96
18            97
19            91
20            103
21            108
22            95
23            104
24            99
25            99
26            108
27            104
28            91
29            102
30            105
31            97
32            81
33            106
34            101
35            107
36            89
37            99
38            88
39            87
40            102
41            100
42            107
43            92
44            81
45            84
46            103
47            100
48            98
49            89
50            95
51            107
52            102
53            105
54            95
55            110
56            92
57            119
58            110
59            106
60            93
61            92
62            84
63            103
64            113
65            94
66            95
67            99
68            92
69            99
70            110
71            91
72            96
73            95
74            87
75            93
76            95
77            111
78            102
79            101
80            111
81            113
82            110
83            115
84            95
85            105
86            106
87            107
88            92
89            93
90            118
91            95
92            106
93            91
94            104
95            106
96            104
97            98
98            97
99            101
100           106
Total 10000
 Lowest count 81 for i = 32
Highest count 122 for i = 12


As you can see no holes and no heavy favorites. This tells me this game plays the same as one in which a secret number is decided before the start of each game or round.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 12, 2020, 11:18:34 am
BTW here is my QB64 version of the backwards (the program guesses my number) Hi Lo Game from 2019:
Code: QB64: [Select]
  1. '2019-09-14
  2.     Hi = 101: Lo = 0
  3.     DO
  4.         guess = INT((Hi - Lo) / 2) + Lo
  5.         PRINT "AI guesses your number ( 1 to 100) is "; guess
  6.         INPUT "Enter l for low, c for correct, h for high > "; r$
  7.         IF r$ = "l" THEN Lo = guess
  8.         IF r$ = "h" THEN Hi = guess
  9.     LOOP UNTIL r$ = "c"
  10.     PRINT "Yeah, start another..."
  11.  
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 12, 2020, 11:34:59 am
And just to round things out, here is my version of the Standard Hi Lo Game written in SB (Shorthand Basic) for my Interpreter built with QB64:
Code: QB64: [Select]
  1. Hi lo game SB.txt b+ 2020-03-07
  2. [
  3.     n r int(rnd * 100) + 1
  4.     n c 0
  5.     [
  6.         ? g Guess my number from 1 to 100, (0 quits)
  7.         i  g >= 1
  8.             n c c + 1
  9.             i  g >  r
  10.                 . Too High!
  11.             e
  12.                 i  g < r
  13.                     . Too Low!
  14.                 e
  15.                     . You guessed in c guesses!
  16.                     .
  17.                     x
  18.                 f
  19.             f
  20.         e
  21.             . You signaled quit, goodbye!
  22.             z
  23.         f
  24.     ]  
  25. ]
  26.  

[ starts a loop
] ends a loop

n sets a number variable the very next item in the line is the variable name and the next stuff is number literal or numeric expression for the variables value. (So here, r is the secret number set at the beginning of the round and c is for count as in counting the number of guesses.)

? starts an INPUT statement, next item is the variable name being set and the rest is the propmt string, notice NO double quotes!

i starts an IF branch decision, the stuff following is the expression to evaluate if evaluates to True then execute the next statement else look for an f (the end of an IF block or an e the ELSE block to execute.

. starts a PRINT statement, notice no double quotes BUT if one of the isolated letters or words is a variable name the variable's value will be substituted in for the name.

x of course is for exit loop, the only way out of [ loop code ]

For comments, just don't start a line with a command like [].nxief, but for your comfort use ' to feel safe it wont be used for anything else.

BTW the indents are optional but each executable line must start with executable command. So line 1 is just  comment.

One of these days I am going to work in strings and SUBs or FUNCTIONs.

Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 12, 2020, 03:57:56 pm
BTW I found the 256 Cards Trick, program can pick your card out of 256 cards by telling it which line of 4 it's in, do this 4 X's and it will count out your favorite number of cards and your card will be last shown.

https://www.qb64.org/forum/index.php?topic=1865.msg111002#msg111002

But again, this is backwards to the challenge presented in OP.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 13, 2020, 12:55:02 pm
Update: tsh73 says my code looks OK (for Hi Lo Game that does not start with established secret numbers) but might have found something literally funny about frequency distribution of resulting "secret" numbers from pure random guessing.

I was only checking guessing with some intelligence being applied including sliding down my guess by 1 number each time, those were fine but pure random guessing produced a frequency distribution chart that lifted up at both ends like a giant smiling at a joke!

hmm... got to check that out, it may be some artifact from the chart system he is using but like I said I never thought to check pure random guessing.

OK so here is my Hi Lo Game that plays without a secret number for QB64:
Code: QB64: [Select]
  1. _TITLE "Hi Lo Game without Secret Number" 'B+ 2020-10-10 works now
  2. ' trans from JB 2020-10-11 minimal changes
  3. restart:
  4. Hi = 101: Lo = 0 '<<<<  make these higher and lower than what the secret number can be
  5. guesses$ = ""
  6. WHILE Hi - Lo > 1
  7.     INPUT "Guess Number 1 to 100, Enter your guess "; PlayerGuess
  8.     'if PlayerGuess = 0 then goto [restart]  ' GOOD! we split first guess of 50 both ways!
  9.     IF PlayerGuess < 1 OR PlayerGuess > 100 THEN
  10.         PRINT "Your guess is out of range of this game."
  11.         GOTO cont
  12.     END IF
  13.     IF INSTR(guesses$, RIGHT$("000" + STR$(PlayerGuess), 3)) THEN
  14.         PRINT "You've guessed that number already."
  15.         GOTO cont
  16.     END IF
  17.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(PlayerGuess), 3)
  18.     IF PlayerGuess > Lo AND PlayerGuess < Hi THEN
  19.         r = RND: p = 1 / (Hi - Lo - 1) ' must be inside the Lo and Hi range ie not inclusive boundaries.
  20.         IF r <= p THEN
  21.             PRINT "You Guessed!"
  22.             Guessed = 1
  23.             EXIT WHILE
  24.         ELSE
  25.             IF PlayerGuess = Hi - 1 THEN 'guess must of been too high
  26.                 'PRINT Lo, Hi, "Your guess was too high.", r, p
  27.                 PRINT "Your guess was too high."
  28.                 Hi = PlayerGuess
  29.             ELSE
  30.                 IF PlayerGuess = Lo + 1 THEN
  31.                     'PRINT Lo, Hi, "Your guess was too low.", r, p
  32.                     PRINT "Your guess was too low."
  33.                     Lo = PlayerGuess
  34.                 ELSE 'toss coin if too high or low
  35.                     IF RND < .5 THEN
  36.                         'PRINT Lo, Hi, "Your guess was too low.", r, p
  37.                         PRINT "Your guess was too low."
  38.                         Lo = PlayerGuess
  39.                     ELSE
  40.                         ' PRINT Lo, Hi, "Your guess was too high.", r, p
  41.                         PRINT "Your guess was too high."
  42.                         Hi = PlayerGuess
  43.                     END IF
  44.                 END IF
  45.             END IF
  46.         END IF
  47.     ELSE
  48.         IF PlayerGuess >= Hi THEN PRINT "Your guess was too high." ELSE PRINT "Your guess was too low."
  49.     END IF
  50.     cont:
  51. IF Guessed <> 1 THEN PRINT "Yikes! Programming error, did not find secret number."
  52. PRINT: INPUT "press Enter to go again, any other + Enter to quit "; again$
  53. IF LEN(again$) THEN END ELSE GOTO restart
  54.  

And here is what I was using to check frequency distributions of secret numbers discovered at the end of a game:
Code: QB64: [Select]
  1. _TITLE "Hi Lo Game wo secret Test Distribution" '  B+ 2020-10-10 works now
  2.  
  3. DIM secrets(100) 'check distribution of answers, also checking if we fail to arrive at answer
  4. 'SCREEN _NEWIMAGE(800, 600, 32)
  5. restart:
  6. Hi = 101: Lo = 0 '<<<<  make these higher and lower than what the secret number can be
  7. guesses$ = ""
  8. ALO = 0: AHI = 101
  9. Guessed = 0
  10. WHILE Hi - Lo > 1
  11.     'input "Guess Number 1 to 100, Enter your guess "; PlayerGuess
  12.  
  13.     'use AI to guess
  14.     'PlayerGuess = int((AHI - ALO)/ 2) + ALO 'OK have removed blunder!
  15.  
  16.     'make all the guesses way too high ie ride the AHI down 1 by 1
  17.     PlayerGuess = AHI - 1 'Ah still a very nice ditribution of secrets, no holes nor mountains
  18.  
  19.     'PlayerGuess = int((Hi - Lo )/ 2) + Lo  'debug what the heck is going on with ALO AHI??
  20.     'PRINT "Player Guesses "; PlayerGuess
  21.  
  22.     'if PlayerGuess = 0 then goto [restart]  ' GOOD! we split first guess of 50 both ways!
  23.     IF PlayerGuess < 1 OR PlayerGuess > 100 THEN
  24.         PRINT "Your guess is out of range of this game."
  25.         _DELAY 2
  26.         GOTO cont
  27.     END IF
  28.     IF INSTR(guesses$, RIGHT$("000" + STR$(PlayerGuess), 3)) THEN
  29.         PRINT "You've guessed that number already."
  30.         _DELAY 2
  31.         GOTO cont
  32.     END IF
  33.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(PlayerGuess), 3)
  34.     IF PlayerGuess > Lo AND PlayerGuess < Hi THEN
  35.         r = RND: p = 1 / (Hi - Lo - 1) ' must be inside the Lo and Hi range ie not inclusive boundaries.
  36.         IF r <= p THEN
  37.             ' PRINT "You Guessed!"
  38.             ' _DELAY 3
  39.             Guessed = 1
  40.             EXIT WHILE
  41.         ELSE
  42.             IF PlayerGuess = Hi - 1 THEN 'guess must of been too high
  43.                 'PRINT Lo, Hi, "Your guess was too high.", r, p
  44.                 Hi = PlayerGuess
  45.                 AHI = PlayerGuess
  46.             ELSE
  47.                 IF PlayerGuess = Lo + 1 THEN
  48.                     'PRINT Lo, Hi, "Your guess was too low.", r, p
  49.                     Lo = PlayerGuess
  50.                     ALO = PlayerGuess
  51.                 ELSE 'toss coin if too high or low
  52.                     IF RND < .5 THEN
  53.                         'PRINT Lo, Hi, "Your guess was too low.", r, p
  54.                         Lo = PlayerGuess
  55.                         ALO = PlayerGuess
  56.                     ELSE
  57.                         'PRINT Lo, Hi, "Your guess was too high.", r, p
  58.                         Hi = PlayerGuess
  59.                         AHI = PlayerGuess
  60.                     END IF
  61.                 END IF
  62.             END IF
  63.         END IF
  64.     ELSE 'going wrong way with guessing, not narrowing down with current guess
  65.         'if PlayerGuess >= Hi then Print "Your guess was too high." else print "Your guess was too low."
  66.         '_DELAY 2
  67.     END IF
  68.     cont:
  69.     'PRINT Lo, Hi, ALO, AHI 'OK that blunder was pretty dumb!
  70.     'INPUT "Press enter to continue..."; wait$
  71. IF Guessed <> 1 THEN
  72.     BEEP
  73.     PRINT "Yikes! Programming error, did not find secret number."
  74.     programErrors = programErrors + 1
  75.     secrets(PlayerGuess) = secrets(PlayerGuess) + 1
  76. trial = trial + 1
  77. IF trial < 10000 THEN GOTO restart
  78.  
  79. PRINT "Secret Numbers results:"
  80. PRINT "Program errors = "; programErrors
  81. low = 10000
  82. FOR i = 1 TO 100
  83.     PRINT i, secrets(i)
  84.     tot = tot + secrets(i)
  85.     IF secrets(i) < low THEN low = secrets(i): saveLowI = i
  86.     IF secrets(i) > high THEN high = secrets(i): saveHighI = i
  87.     IF i MOD 20 = 0 THEN
  88.         INPUT "Press enter to continue... "; w$
  89.         CLS
  90.     END IF
  91. PRINT "Total "; tot
  92. PRINT " Lowest count "; low; " for i = "; saveLowI
  93. PRINT "Highest count "; high; " for i = "; saveHighI
  94.  

So there it is so far for those of you into esoteric program problems :)
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 13, 2020, 07:17:29 pm
My independent test confirms tsh73 report is correct, the graph of the distribution of jump way up at the two ends:
Code: QB64: [Select]
  1. ' Hi Lo Game WO Secret Number Test Random Guessing Distribution  B+ 2020-10-13
  2.  
  3. ' Check tsh73 report of wackiness for pure random guessing.
  4. ' So we aren't here all day waiting for results of 1000 tests
  5. ' let us store all the guess numbers into a deck.
  6. ' Shuffle the deck before each round and use 100 numbers WITHOUT REPEAT
  7. ' to get that secret number established! That should save us a ship load
  8. ' of time and still produce results of pure random guesses.
  9.  
  10. ' 2020-10-13 trans JB code to QB64
  11.  
  12. DEFINT A-Z
  13. DIM secrets(100) ' Check distribution of answers, also checking if we fail to arrive at answer.
  14. DIM rg(100) '      Get our random guesses in a row! Here is our Deck!
  15. FOR i = 1 TO 100 ' Create our deck of random numbers to test, rg stands for Random Guess
  16.     rg(i) = i
  17.  
  18. restart:
  19. ' reinitialize all that is necessary start by reshuffle rg()
  20. FOR i = 100 TO 2 STEP -1 'forget about 0 leave it alone
  21.     tmp = rg(i)
  22.     r = INT(RND * i) + 1
  23.     rg(i) = rg(r)
  24.     rg(r) = tmp
  25. rIdx = 1 'reset deck index
  26. Hi = 101: Lo = 0 '  reset, make these higher and lower than what the secret number can be
  27. guesses$ = "" '     track what has been guessed
  28. Guessed = 0 '     flag the number has been established!
  29.  
  30. WHILE Hi - Lo > 1 ' Begin rounds of guesses for number
  31.  
  32.     PlayerGuess = rg(rIdx) ' 1 of 100 pure random guesses
  33.     rIdx = rIdx + 1
  34.     'PRINT "Player Guesses "; PlayerGuess
  35.  
  36.     'if PlayerGuess = 0 then goto restart  ' GOOD! we split first guess of 50 both ways!
  37.     IF PlayerGuess < 1 OR PlayerGuess > 100 THEN 'not going to happen
  38.         GOTO cont
  39.     END IF
  40.     IF INSTR(guesses$, RIGHT$("000" + STR$(PlayerGuess), 3)) THEN 'not going to happen
  41.         GOTO cont
  42.     END IF
  43.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(PlayerGuess), 3) 'wasting time but...
  44.     IF PlayerGuess > Lo AND PlayerGuess < Hi THEN
  45.         r = RND: p = 1 / (Hi - Lo - 1) ' must be inside the Lo and Hi range ie not inclusive boundaries.
  46.         IF r <= p THEN
  47.             'PRINT "You guessed it!"
  48.             Guessed = 1
  49.             EXIT WHILE
  50.         ELSE
  51.             IF PlayerGuess = Hi - 1 THEN 'guess must of been too high
  52.                 'print Lo, Hi, "Your guess was too high.", r, p
  53.                 Hi = PlayerGuess
  54.             ELSE
  55.                 IF PlayerGuess = Lo + 1 THEN
  56.                     'print Lo, Hi, "Your guess was too low.", r, p
  57.                     Lo = PlayerGuess
  58.                 ELSE 'toss coin if too high or low
  59.                     IF RND < .5 THEN
  60.                         'print Lo, Hi, "Your guess was too low.", r, p
  61.                         Lo = PlayerGuess
  62.                     ELSE
  63.                         'print Lo, Hi, "Your guess was too high.", r, p
  64.                         Hi = PlayerGuess
  65.                     END IF
  66.                 END IF
  67.             END IF
  68.         END IF
  69.     ELSE 'going wrong way with guessing, not narrowing down with current guess this will happen allot!!!
  70.         IF PlayerGuess >= Hi THEN
  71.             'Print "Your guess was too high."
  72.         ELSE
  73.             'print "Your guess was too low."
  74.         END IF
  75.     END IF
  76.     cont:
  77.     'INPUT "Press enter to continue..."; wait$
  78. IF Guessed <> 1 THEN
  79.     'PRINT "Yikes! Programming error, did not find secret number."
  80.     programErrors = programErrors + 1
  81.     secrets(PlayerGuess) = secrets(PlayerGuess) + 1
  82. trial = trial + 1
  83. IF trial < 10000 THEN GOTO restart
  84.  
  85. 'report results
  86. PRINT "Secret Numbers results:"
  87. PRINT "Program errors = "; programErrors
  88. low = 1000
  89. FOR i = 1 TO 100
  90.     PRINT i, secrets(i) 'that's right in JB you can scroll output screen to review all 100
  91.     tot = tot + secrets(i)
  92.     IF secrets(i) < low THEN low = secrets(i): saveLowI = i
  93.     IF secrets(i) > high THEN high = secrets(i): saveHighI = i
  94.     IF i MOD 20 = 0 THEN
  95.         INPUT " Press enter to cont..."; w$
  96.         CLS
  97.     END IF
  98. PRINT "Total "; tot
  99. PRINT " Lowest count "; low; " for i = "; saveLowI
  100. PRINT "Highest count "; high; " for i = "; saveHighI
  101.  
Title: Re: Hi Lo without Secret Number?
Post by: SMcNeill on October 14, 2020, 08:10:16 pm
One caveat:  I haven't tried any of the code in this topic yet, to actually see what the heck type of game we're supposed to be making.  I didn't want to be inspired (or limited) by looking over anyone else's work first.  Instead, I tried to make a little program which does a magic number, without having a magic number, like I understood from bplus's posts..

Regardless of whether or not this is quite what we were looking for, here's a Steve Magic Number (without a magic number) program for everyone to enjoy:

Code: QB64: [Select]
  1. min = 1: max = 100
  2.  
  3. PRINT "Guess my magic number.  It's between 1 and 100!"
  4. PRINT "If you guess high, I'll tell you to guess lower,"
  5. PRINT "and if you guess low, I'll tell you to guess higher."
  6.  
  7.  
  8.     NumberOfGuesses = NumberOfGuesses + 1
  9.     PRINT
  10.     PRINT "How many guesses will it take for you to find my number?"
  11.     PRINT "Let's find out! Give me your Guess #"; NumberOfGuesses;
  12.     INPUT " "; Guess
  13.     result = 0
  14.     IF Guess < min THEN result = 1
  15.     IF Guess > max THEN result = -1
  16.     IF result = 0 THEN 'it's a good guess, progressing the game.
  17.         target = (min + max) \ 2
  18.         IF Guess >= target THEN
  19.             IF min - max = 0 THEN result = 0 ELSE min = Guess + 1: result = 1
  20.         ELSE
  21.             max = Guess - 1: result = -1
  22.         END IF
  23.     END IF
  24.     COLOR 4
  25.     IF result < 0 THEN
  26.         PRINT "PLEASE GUESS LOWER"
  27.     ELSEIF result > 0 THEN
  28.         PRINT "PLEASE GUESS HIGHER"
  29.     ELSE
  30.         PRINT "YEP!"
  31.         PRINT "My secret number was "; Guess
  32.         COLOR 7
  33.         END
  34.     END IF
  35.     COLOR 15
  36.  
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 14, 2020, 09:32:17 pm
Quote
I haven't tried any of the code in this topic yet, to actually see what the heck type of game we're supposed to be making.  I didn't want to be inspired (or limited) by looking over anyone else's work first.  Instead, I tried to make a little program which does a magic number, without having a magic number, like I understood from bplus's posts.

I don't like to be influenced either, try the challenge raw first, see what first impressions will bring up.

Yeah Steve, that's going the right way now but the game plays the same over and over and over (because I play same numbers over and over, I always start at 50 then 75 or 25...)  I don't think RANDOMIZE TIMER would even help.

Also I am guessing the game will always take 6 guesses, that's as cruel as my version I posted as joke. You could just count the player's guesses and give them the game after a max of 7 but could be after any guess 1 to 7 if they were all different. Man! that would meet the criteria and produce a wide range of secret numbers ultimately established at the end of the game. Wish I thought of that days ago, I just found a Hi Lo Game without Secret Number with much improved frequency distribution.

Steve thanks for hanging in there with this crazy stuff!

Oh I should try different number starts, oh boy!
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Hi Lo without Secret Number?
Post by: SMcNeill on October 14, 2020, 09:54:54 pm
Who ever said we used integers?  :P

How the heck did you get stuck between 29 and 30?  I’ll have to dig into that issue.

And it’s only 6 or 7 guesses, if you narrow it down by a binary pattern.  50, +/- 25, +/- 12, +/- 6, +/- 3, +/- 1, +/- 1.

When I came up with this little concept, the idea was basically: How can the AI stretch out the game to tease the player the longest, making them use as many guesses as possible?

BEST game should be 6-7 guesses.  Worst game, could be forever, if you don’t read the instructions ((or get stuck in and endless loop).

I’ll play around a bit tomorrow, and see what the glitch is, and I might even toss in a random target for you to shoot at with it, just so it won’t be quite as easy to tell the computer is cheating.  :)
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 14, 2020, 10:18:34 pm
Quote
You could just count the player's guesses and give them the game after a max of 7 but could be after any guess 1 to 7 if they were all different. Man! that would meet the criteria and produce a wide range of secret numbers ultimately established at the end of the game. Wish I thought of that days ago, I just found a Hi Lo Game without Secret Number with much improved frequency distribution.

On 2nd thought no that won't work. You have to pay attention to players guesses and remain consistent in what you say with go higher or go lower, so the number still has to be narrowed down and you have to be careful in the narrowing down. I am pretty sure you have to test if 1 away from Lo or Hi and if it's going to be reported as a miss then only one way to go with narrowing down, no random up or down there. Maybe the glitch with Steve's code?

I was going to post my revised and improved game but now I think I will wait :)
Teaser: it has just the frequency distribution I was hoping to see of secret numbers established at end of each game ie spread pretty level from 1 to 100.
Title: Re: Hi Lo without Secret Number?
Post by: bplus on October 15, 2020, 09:17:25 pm
Before the river of time travels too far, here is my revised version of Hi Lo Game that has no secret number from start. The number gets established later by careful applications of RND s.t. the final secret numbers established cover fairly evenly the number range 1 to 100 like int(rnd*100) + 1 for secret number would have done.

Code: QB64: [Select]
  1. _TITLE "Hi Lo Game without Secret Number v2" 'B+ 2020-10-13
  2. ' trans from JB 2020-10-11 minimal changes
  3. DEFINT A-Z
  4. DIM hi, lo, guesses$, playerGuess, guessed, range, again$
  5. restart:
  6. hi = 101: lo = 0 '<<<<  make these higher and lower than what the secret number can be
  7. guesses$ = ""
  8. WHILE hi - lo > 1
  9.     INPUT "Guess Number 1 to 100, Enter your guess "; playerGuess
  10.     'if PlayerGuess = 0 then goto [restart]  ' GOOD! we split first guess of 50 both ways!
  11.     IF playerGuess < 1 OR playerGuess > 100 THEN
  12.         PRINT "Your guess is out of range of this game."
  13.         GOTO cont
  14.     END IF
  15.     IF INSTR(guesses$, RIGHT$("000" + STR$(playerGuess), 3)) THEN
  16.         PRINT "You've guessed that number already."
  17.         GOTO cont
  18.     END IF
  19.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(playerGuess), 3)
  20.     IF playerGuess > lo AND playerGuess < hi THEN
  21.         ' must be inside the Lo and Hi range ie not inclusive boundaries.
  22.         IF RND <= 1 / (hi - lo - 1) THEN
  23.             PRINT "You Guessed!"
  24.             guessed = 1
  25.             EXIT WHILE
  26.         ELSE
  27.             IF playerGuess = lo + 1 THEN
  28.                 PRINT "Your guess was low."
  29.                 lo = lo + 1
  30.             ELSE
  31.                 IF playerGuess = hi - 1 THEN
  32.                     PRINT "Your guess was high."
  33.                     hi = hi - 1
  34.                 ELSE
  35.                     'p < guess = (guess - lo -1) / range
  36.                     range = hi - lo - 1
  37.                     IF RND * range <= playerGuess - lo - .5 THEN
  38.                         PRINT lo, hi, "Your guess was too high."
  39.                         hi = playerGuess
  40.                     ELSE
  41.                         PRINT lo, hi, "Your guess was too low."
  42.                         lo = playerGuess
  43.                     END IF
  44.                 END IF
  45.             END IF
  46.         END IF
  47.     ELSE
  48.         IF playerGuess >= hi THEN PRINT "Your guess was too high." ELSE PRINT "Your guess was too low."
  49.     END IF
  50.     cont:
  51. IF guessed <> 1 THEN PRINT "Yikes! Programming error, did not find secret number."
  52. PRINT: INPUT "press Enter to go again, any other + Enter to quit "; again$
  53. IF LEN(again$) THEN END ELSE GOTO restart
  54.  
  55.  

And here are 2 frequency testers in one, just change what is commented out for PlayerGuess:
Code: QB64: [Select]
  1. _TITLE "Hi Lo Game wo secret Test Distribution" '  B+ 2020-10-10 works now
  2. DEFINT A-Z
  3. DIM secrets(100) 'check distribution of answers, also checking if we fail to arrive at answer
  4. DIM hi, lo, guesses$, alo, ahi, guessed, playerGuess, range, programErrors, trial, low, i, tot, saveLowI, high, saveHighI, w$
  5.  
  6. restart:
  7. hi = 101: lo = 0 '<<<<  make these higher and lower than what the secret number can be
  8. guesses$ = ""
  9. guessed = 0
  10. ahi = 101
  11. WHILE hi - lo > 1
  12.     'input "Guess Number 1 to 100, Enter your guess "; PlayerGuess
  13.  
  14.     'use AI to guess
  15.  
  16.     'make all the guesses way too high ie ride the AHI down 1 by 1
  17.     'ahi = ahi - 1
  18.     'playerGuess = ahi
  19.  
  20.     playerGuess = INT((hi - lo) / 2) + lo 'debug what the heck is going on with ALO AHI??
  21.     'PRINT "Player Guesses "; playerGuess
  22.  
  23.     'if PlayerGuess = 0 then goto [restart]  ' GOOD! we split first guess of 50 both ways!
  24.     IF playerGuess < 1 OR playerGuess > 100 THEN
  25.         PRINT "Your guess is out of range of this game."
  26.         GOTO cont
  27.     END IF
  28.     IF INSTR(guesses$, RIGHT$("000" + STR$(playerGuess), 3)) THEN
  29.         PRINT "You've guessed that number already."
  30.         GOTO cont
  31.     END IF
  32.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(playerGuess), 3)
  33.     IF playerGuess > lo AND playerGuess < hi THEN
  34.         ' must be inside the Lo and Hi range ie not inclusive boundaries.
  35.         IF RND <= 1 / (hi - lo - 1) THEN
  36.             PRINT "You Guessed!"
  37.             guessed = 1
  38.         ELSE
  39.             IF playerGuess = lo + 1 THEN
  40.                 'PRINT "Your guess was low."
  41.                 lo = lo + 1
  42.             ELSE
  43.                 IF playerGuess = hi - 1 THEN
  44.                     'PRINT "Your guess was high."
  45.                     hi = hi - 1
  46.                 ELSE
  47.                     'p < guess = (guess - lo -1) / range
  48.                     range = hi - lo - 1
  49.                     IF RND * range <= playerGuess - lo - .5 THEN
  50.                         ' PRINT lo, hi, "Your guess was too high."
  51.                         hi = playerGuess
  52.                     ELSE
  53.                         'PRINT lo, hi, "Your guess was too low."
  54.                         lo = playerGuess
  55.                     END IF
  56.                 END IF
  57.             END IF
  58.         END IF
  59.     ELSE 'going wrong way with guessing, not narrowing down with current guess
  60.         'IF playerGuess >= hi THEN PRINT "Your guess was too high." ELSE PRINT "Your guess was too low."
  61.     END IF
  62.  
  63.     cont:
  64.     'PRINT lo, hi, alo, ahi 'OK that blunder was pretty dumb!
  65.     'INPUT "Press enter to continue..."; w$
  66.     IF guessed THEN EXIT WHILE
  67. IF guessed <> 1 THEN
  68.     BEEP
  69.     PRINT "Yikes! Programming error, did not find secret number."
  70.     programErrors = programErrors + 1
  71.     secrets(playerGuess) = secrets(playerGuess) + 1
  72. trial = trial + 1
  73. IF trial < 10000 THEN GOTO restart
  74.  
  75. PRINT "Secret Numbers results:"
  76. PRINT "Program errors = "; programErrors
  77. low = 10000
  78. FOR i = 1 TO 100
  79.     PRINT i, secrets(i)
  80.     tot = tot + secrets(i)
  81.     IF secrets(i) < low THEN low = secrets(i): saveLowI = i
  82.     IF secrets(i) > high THEN high = secrets(i): saveHighI = i
  83.     IF i MOD 20 = 0 THEN
  84.         INPUT "Press enter to continue... "; w$
  85.         CLS
  86.     END IF
  87. PRINT "Total "; tot
  88. PRINT " Lowest count "; low; " for i = "; saveLowI
  89. PRINT "Highest count "; high; " for i = "; saveHighI
  90.  

And this is the frequency tester in which the V2 Game code (the AI deciding if guess too high or low or correct) was developed using a deck of numbers from 1 to 100 shuffled for guessing randomly without repetition.
Code: QB64: [Select]
  1. ' Hi Lo Game WO Secret Number v2 Test Random Guessing Distribution  B+ 2020-10-13
  2.  
  3. ' Check tsh73 report of wackiness for pure random guessing.
  4. ' So we aren't here all day waiting for results of 1000 tests
  5. ' let us store all the guess numbers into a deck.
  6. ' Shuffle the deck before each round and use 100 numbers WITHOUT REPEAT
  7. ' to get that secret number established! That should save us a ship load
  8. ' of time and still produce results of pure random guesses.
  9.  
  10. ' 2020-10-13 trans JB code to QB64
  11.  
  12. DEFINT A-Z
  13. DIM secrets(100) ' Check distribution of answers, also checking if we fail to arrive at answer.
  14. DIM rg(100) '      Get our random guesses in a row! Here is our Deck!
  15. FOR i = 1 TO 100 ' Create our deck of random numbers to test, rg stands for Random Guess
  16.     rg(i) = i
  17.  
  18. restart:
  19. ' reinitialize all that is necessary start by reshuffle rg()
  20. FOR i = 100 TO 2 STEP -1 'forget about 0 leave it alone
  21.     tmp = rg(i)
  22.     r = INT(RND * i) + 1
  23.     rg(i) = rg(r)
  24.     rg(r) = tmp
  25. rIdx = 1 'reset deck index
  26. Hi = 101: Lo = 0 '  reset, make these higher and lower than what the secret number can be
  27. guesses$ = "" '     track what has been guessed
  28. Guessed = 0 '     flag the number has been established!
  29.  
  30. WHILE Hi - Lo > 1 ' Begin rounds of guesses for number
  31.  
  32.     PlayerGuess = rg(rIdx) ' 1 of 100 pure random guesses
  33.     rIdx = rIdx + 1
  34.     'PRINT "Player Guesses "; PlayerGuess
  35.  
  36.     'if PlayerGuess = 0 then goto restart  ' GOOD! we split first guess of 50 both ways!
  37.     IF PlayerGuess < 1 OR PlayerGuess > 100 THEN 'not going to happen
  38.         GOTO cont
  39.     END IF
  40.     IF INSTR(guesses$, RIGHT$("000" + STR$(PlayerGuess), 3)) THEN 'not going to happen
  41.         GOTO cont
  42.     END IF
  43.     guesses$ = guesses$ + "," + RIGHT$("000" + STR$(PlayerGuess), 3) 'wasting time but...
  44.     IF PlayerGuess > Lo AND PlayerGuess < Hi THEN
  45.         r = RND: p = 1 / (Hi - Lo - 1) ' must be inside the Lo and Hi range ie not inclusive boundaries.
  46.         IF r <= p THEN
  47.             'PRINT "You guessed it!"
  48.             Guessed = 1
  49.             EXIT WHILE
  50.         ELSE
  51.             IF PlayerGuess = Lo + 1 THEN
  52.                 'PRINT "Your guess was low."
  53.                 Lo = Lo + 1
  54.             ELSE
  55.                 IF PlayerGuess = Hi - 1 THEN
  56.                     'PRINT "Your guess was high."
  57.                     Hi = Hi - 1
  58.                 ELSE
  59.                     'p < guess = (guess - lo -1) / range
  60.                     range = Hi - Lo - 1
  61.                     IF RND * range <= PlayerGuess - Lo - .5 THEN
  62.                         'PRINT Lo, Hi, "Your guess was too high."
  63.                         Hi = PlayerGuess
  64.                     ELSE
  65.                         'PRINT Lo, Hi, "Your guess was too low."
  66.                         Lo = PlayerGuess
  67.                     END IF
  68.                 END IF
  69.             END IF
  70.         END IF
  71.     ELSE 'going wrong way with guessing, not narrowing down with current guess this will happen allot!!!
  72.         IF PlayerGuess >= Hi THEN
  73.             'Print "Your guess was too high."
  74.         ELSE
  75.             'print "Your guess was too low."
  76.         END IF
  77.     END IF
  78.     cont:
  79.     'INPUT "Press enter to continue..."; wait$
  80. IF Guessed <> 1 THEN
  81.     'PRINT "Yikes! Programming error, did not find secret number."
  82.     programErrors = programErrors + 1
  83.     secrets(PlayerGuess) = secrets(PlayerGuess) + 1
  84. trial = trial + 1
  85. IF trial < 10000 THEN GOTO restart
  86.  
  87. 'report results
  88. PRINT "Secret Numbers results:"
  89. PRINT "Program errors = "; programErrors
  90. low = 10000
  91. FOR i = 1 TO 100
  92.     PRINT i, secrets(i) 'that's right in JB you can scroll output screen to review all 100
  93.     tot = tot + secrets(i)
  94.     IF secrets(i) < low THEN low = secrets(i): saveLowI = i
  95.     IF secrets(i) > high THEN high = secrets(i): saveHighI = i
  96.     IF i MOD 20 = 0 THEN
  97.         INPUT " Press enter to cont..."; w$
  98.         CLS
  99.     END IF
  100. PRINT "Total "; tot
  101. PRINT " Lowest count "; low; " for i = "; saveLowI
  102. PRINT "Highest count "; high; " for i = "; saveHighI
  103.  
  104.