(11C) "Hi-Lo" Game
01-15-2018, 01:11 PM (This post was last modified: 01-16-2018 05:17 AM by Gamo.)
Post: #1
 Gamo Senior Member Posts: 605 Joined: Dec 2016
(11C) "Hi-Lo" Game
This Hi-Lo program randomly pick numbers between 0 and 99
You make a guess and program will tell you if it High or Low
Continue guessing until the display flash all 8's and the number of guesses you took to hit on the correct number.
The calculator then selects a new number to start a new game.

How to play:
1. LBL E (Display show 0.00) for Game Reset
2. Enter number the display read "Hi.00" or "L0.00" when look inverted.
3. When hit the right number all 8's flashing on display then show the number of guesses you took and automatically start new game.

Code:
 LBL E RAN#   2 10^X   x INT STO 1 FIX 2 8,888,888,888 STO 2 .07  STO 3  14 STO 4 *LBL 3 RCL 1 CLx R/S ENTER   1 STO+5 Roll Down X=Y? GTO 1 X<>Y X>Y? GTO 2 GTO 4 *LBL 1 RCL 2 PSE PSE PSE RCL 5 PSE PSE CLx STO 5 GTO E *LBL 2 RCL 3 PSE PSE RCL 1 GTO 3 *LBL 4 RCL 4 PSE PSE RCL 1 GTO 3

Gamo
01-15-2018, 06:16 PM (This post was last modified: 01-15-2018 08:24 PM by Dieter.)
Post: #2
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-15-2018 01:11 PM)Gamo Wrote:  This Hi-Lo program randomly pick numbers between 1 and 100
...
Enter number the display read "Hi" or "Lo" when look inverted.

There are several issues with this program:

- The program does not generate a number between 1 and 100, but between 0 and 99.
- If you turn the display upside down it does not read "hi" and "Lo" but "00hI" and "LOO"
- The guess counter in R5 is not initialized. It is reset to zero after the game instead of at the beginning.
- Most important: the program evaluates the first guess incorrectly. The first hint given by the program compares the user input not with the hidden number but with 14.

This is because the hidden number is assumed to be on the stack, but on the first run it isn't. Try it: Start the program and enter 14 as your first guess. The program will say that this is the correct number.

You generally should not carry the secret number on the stack. If the user presses only one additional key the whole stack is disturbed any everything will go wrong. But you don't have to do this – the number is stored in R1, so there is no need at all to keep it on the stack.

BTW, I like this idea of displaying hI and LO with the numbers 14 and 07. This reminds me of other early calculator games where messages had to be read upside down – remember the Nim program in the 34C manual which displayed 55178 ("bliss") or 3507.1 ("I lose") ? But what about displaying this in the two exponent digits?

3.       07    => 3. guess is LO
4.       14    => 4. guess is HI

And what about a counter? You lose if you haven't made it in 8 guesses. ;-)

Finally, on the 15C there is an easy way to get a flashing display: simply cause an overflow. Maybe you can also test this on the 11C – I'm not sure if it works the same way. If it does, EEX 2 10^x RCL 5 may be used to show the number of guesses with a flashing display.

Dieter
01-16-2018, 01:54 AM
Post: #3
 Gerson W. Barbosa Senior Member Posts: 1,332 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-15-2018 06:16 PM)Dieter Wrote:  Finally, on the 15C there is an easy way to get a flashing display: simply cause an overflow.

On the 15C you can simply set flag 9 for this (g SF 9). This flag is not available on the 11C, I’m afraid.
The HI-LO game was available on the Master Library Module for the Ti-58C/59 calculator. The secret number was in the range 0-1023 or 1-1024 (I don’t remember). Mastermind was available as a program listing in the user’s manual (There’s a 42S version here).

Gerson.
01-16-2018, 08:25 AM (This post was last modified: 01-16-2018 08:33 AM by Dieter.)
Post: #4
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  On the 15C you can simply set flag 9 for this (g SF 9).

Interesting – I didn't know that. But now I found it in the 15C manual:

Quote:If you set flag 9 manually (SF 9), it causes the display to blink irrespective
of the overflow status of the calculator. As usual, a program will run to
completion before the display starts blinking. Therefore, flag 9 can be used
as a programming tool to provide a visual signal for a selected condition.

I'd like to have something like that on other calculators, too. ;-)

(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  This flag is not available on the 11C, I’m afraid.

And the display doesn't even flash on overflow ?-)

(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  The HI-LO game was available on the Master Library Module for the Ti-58C/59 calculator. The secret number was in the range 0-1023 or 1-1024 (I don’t remember).

Yes, I remember. This might have been my very first "computer game". The number was between 1 and 1023.

(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  Mastermind was available as a program listing in the user’s manual (There’s a 42S version here).

Mastermind becomes interesting if it's the calculator that has to guess your code. 8-)

Dieter
01-16-2018, 08:35 PM
Post: #5
 Gerson W. Barbosa Senior Member Posts: 1,332 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-16-2018 08:25 AM)Dieter Wrote:
(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  This flag is not available on the 11C, I’m afraid.

And the display doesn't even flash on overflow ?-)

No, it doesn’t. It behaves like the 12C, just a static “9.999999 99” display.

(01-16-2018 08:25 AM)Dieter Wrote:
(01-16-2018 01:54 AM)Gerson W. Barbosa Wrote:  The HI-LO game was available on the Master Library Module for the Ti-58C/59 calculator. The secret number was in the range 0-1023 or 1-1024 (I don’t remember).

Yes, I remember. This might have been my very first "computer game". The number was between 1 and 1023.

I’d forgotten about the exact range. Thanks!

Gerson.
01-17-2018, 08:15 PM (This post was last modified: 01-17-2018 10:01 PM by Dieter.)
Post: #6
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-16-2018 08:35 PM)Gerson W. Barbosa Wrote:  I’d forgotten about the exact range. Thanks!

Those were the days. Remembering this extremely simple game, here is a version for the 11C which should also run on some other calculators, e.g. the 34C. 15C users replace ISG with ISG I ...and may add a SF 9 after LBL 2. ;-)

Code:
01  LBL A 02  RAN# 03  9 04  9 05  9 06  * 07  INT 08  1 09  + 10  STO 1 11  CLX 12  STO I 13  LBL 1 14  FIX 3 15  R/S 16  ISG 17  ENTER 18  , 19  1 20  % 21  RCL I 22  + 23  x<>y 24  RCL 1 25  - 26  x=0? 27  GTO 2 28  ENTER 29  ABS 30  / 31  * 32  GTO 1 33  LBL 2 34  FIX 0 35  RCL I 36  RTN 37  LBL B 38  CLX 39  STO I 40  1 41  STO 2 42  EEX 43  3 44  STO 3 45  LBL 3 46  RCL 2 47  RCL 3 48  + 49  2 50  / 51  INT 52  STO 1 53  ISG 54  ENTER 55  EEX 56  3 57  / 58  RCL I 59  + 60  FIX 3 61  R/S 62  x=0? 63  GTO 2 64  x>0? 65  GTO 4 66  RCL 1 67  STO 2 68  GTO 3 69  LBL 4 70  RCL 1 71  STO 3 72  GTO 3

Note: the ENTER following the two ISGs is a dummy instruction.

Usage:
f [A] starts a new game where the user has to guess the calculator's number which is between 1 and 999.
Enter a guess and press [R/S]. The answer is displayed as ±g.nnn where g is the number of guesses so far, nnn is the entered guess and the sign indicates whether the input was too low or too high. So –3,750 means that "750" is your third guess and this is less than the secret number.
After success the number of guesses is displayed.

f [B] starts a new game where the calculator tries to guess the user's secret number, again something between 1 and 999.
The display shows g.nnn where g is the number of guesses so far and nnn is the calculator's guess itself. So 1,500 means that the first guess is 500.
Now enter a positive or negative value to indicate whether the guess was too high or too low. Since the displayed number is always positive at this point you may simply press [R/S] for "high" or [CHS] [R/S] for "low". If the calculator was successful, enter zero. This returns the total number of guesses.

Example:
f [A] => 0,000
(If you want to reproduce the following results type 777 STO 1 now)

500 [R/S] => –1,500
500 is low
800 [R/S] =>   2,800
800 is high
750 [R/S] => –3,750
750 is low
780 [R/S] =>   4,780
780 is high
775 [R/S] => –5,775
775 is low
777 [R/S] =>   6
So you found the number in six guesses.

Now let the calculator find out your secret number, e.g. 468:

f [B] => 1,500
500 is high
[R/S] => 2,250
250 is low
[CHS] [R/S] => 3,375
375 is low
[CHS] [R/S] => 4,437
437 still is low
[CHS] [R/S] => 5,468
Bingo
0 [R/S] => 5

Dieter
01-17-2018, 11:39 PM
Post: #7
 Gerson W. Barbosa Senior Member Posts: 1,332 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-17-2018 08:15 PM)Dieter Wrote:
(01-16-2018 08:35 PM)Gerson W. Barbosa Wrote:  I’d forgotten about the exact range. Thanks!

Those were the days. Remembering this extremely simple game, here is a version for the 11C which should also run on some other calculators, e.g. the 34C. 15C users replace ISG with ISG I ...and may add a SF 9 after LBL 2. ;-)

Very nice to play it on my very first HP-15C, thanks! Yes, those were the days (1983 or so).

Code:
031  LBL 2 032  SF 9 033  FIX 0 034  RCL I 035  R/S 036  CF 9 037  FIX 9 038  RTN

The total number of steps has remained the same (recall arithmetic has been used in four occasions).

Gerson.
01-18-2018, 01:25 AM (This post was last modified: 01-18-2018 01:35 AM by Gamo.)
Post: #8
 Gamo Senior Member Posts: 605 Joined: Dec 2016
RE: (11C) "Hi-Lo" Game
Thank You Dieter and Gerson W. Barbosa

Very interesting Hi-Lo Game that Dieter make with added
LBL B that let the calculator make a guess then tell calculator that the guess is Hi or Lo.

I'm 7 years old when HP Voyager Series release on 1981 not until when I was 16 years old that I start to know one of the HP Voyager Series which is the
HP-12C that my Step-Sister use on her MBA course. At that time I try to play around with it and don't know how to use it.
That memory kept in to my mine until I saw the newest release of the HP-12C+ on Amazon and finally got one but this time now I'm 40+ year old !!
Since I got the 12C+ I start to learn on how to use RPN logic and Program from Owner's Handbook and from the web.
This HP Calculators Forum is very helpful with many suggestion, tip and trick.
Especially Thankful to Dieter too.

Gamo
01-18-2018, 08:18 AM (This post was last modified: 01-18-2018 08:23 AM by Dieter.)
Post: #9
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (11C) "Hi-Lo" Game
(01-17-2018 11:39 PM)Gerson W. Barbosa Wrote:  Very nice to play it on my very first HP-15C, thanks! Yes, those were the days (1983 or so).

Add a new feature: let the user decide about the largest number to guess. :-)

Code:
LBL E INT 9 x≤y? X<>Y 9 9 9 x>y? X<>Y STO 0 RTN

Then change the original program at LBL A and LBL B:

Code:
LBL A RCL 0 RAN# * INT ... LBL B CLX STO I RCL 0 1 STO 2 + STO 3 LBL 3 ...

Enter the max. number to guess (between 9 and 999) and press f [E].
Input out of this range is automatically corrected.
Then start a new game with f [A] or f [B].

If you want to make sure that the program can be run without a max. number input, simply add a GSB E after each of the two RCL 0 instructions. Whatever happens to be in R0 then is adjusted to an integer between 9 and 999.

Dieter
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)