HP Forums
(12C) Hi-Lo Game - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Hi-Lo Game (/thread-20276.html)



(12C) Hi-Lo Game - Peet - 08-06-2023 03:13 PM

Hi-Lo game, guess a number between 2 and 999 - usage: <NUMBER> R/S

Start with R/S - Diplay: 0
<guess> R/S - Diplay: -1 (guess to low), 1 (to high) or Number of attempts if guess was right

Code:

01 RCL 0           RAND / in advance save a seed between 0 and 1 to STO 0
02 9
03 LN
04 +
05 5
06 Y^X
07 FRAC            "random" number between 0 and 1
08 STO 0           save as new seed to STO 0
09 9
10 9
11 8
12 *
13 INTG
14 2
15 +               choose a number between 2-999 (because infos are -1/0/1)
16 STO 1           number to guess
17 CLX
18 STO 2           set counter to 0
19 R/S             <input>
20 1
21 STO + 2         increase counter
22 R down          input to x
23 RCL 1
24 -
25 x=0             0: guess is right
26 GTO 33          GOTO <OK>
27 ENTER
28 ENTER
29 *
30 SQRT            SQR / SQRT -> ABS(x)
31 /               -1: Assumption to low / +1: guessed to high
32 GTO 19          GOTO <input> - new guess
33 RCL 2           <OK> (show the number of attempts)
34 GTO 00

Note: the platinum requires 3 digits for the goto, i.e. gto 033 instead of gto 33


RE: (12C) Hi-Lo Game - Gamo - 12-06-2023 05:40 AM

Very interesting program for a Hi-Lo Game especially for the HP-12C

Thank for this great program again and I try it already with my best guest count for 9 times.

Gamo


RE: (12C) Hi-Lo Game - lvt - 12-06-2023 08:53 PM

Wow, this game fits the last 34 lines on my 12C, starting at line 65.

Now the program memory is full Smile