▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
I have now developed an hp12c platinum version of an old game which I hope to type up and post here soon.
It plays 4-digit bagels on the 12c platinum. Program is 258 or so lines long, so it won't run on the black/gold 12c.
Is anyone going to care if I post it to the group or not? :-)
Might as well have a game in the 12cp...after all, who would ever believe someone was playing games on that financial calculator. ;-)
Gene
▼
Posts: 1,278
Threads: 44
Joined: Jul 2007
But does it GRAPH?!?!?!?!
;-)
TW
Posts: 1,755
Threads: 112
Joined: Jan 2005
Hi, Gene:
Gene posted:
"I have now developed an hp12c platinum version of an old game which [...] after all, who would ever believe someone was playing games on that financial calculator. ;-)"
Do post it, please. I don't have an HP-12CP but it's always nice to have a look at HP-12C program code because of its serious limitations as a programming environment.
As for HP-12C games, here's another one I wrote specifically for the
HP-12C a while ago.
Best regards from V.
▼
Posts: 1,545
Threads: 168
Joined: Jul 2005
I'll get it typed up shortly.
And, Valentin, your game is what made me want to write this one. I certainly don't claim that it is elegantly written :-) but I did try a trick or two. Mostly, it's just brute force. Each digit of the secret number is computed separately (no subroutines) and each possible combination of a digit in the guess showing up in the secret number is checked individually. Ugh!
But, with 400 steps and only two conditionals, that's the approach I saw.
What I really would like is a tic-tac-toe game for the 12cp and a lunar lander. Anyone want to try those?
▼
Posts: 1,193
Threads: 43
Joined: Jul 2005
Gene:
I'm very busy, so I have not time to put in practice any Lunar Lander migration to the HP12c/cp. I have no 12c either. But a simple lunar lander as featured on the HP25 Applications Handbook, or even a slightly more sophisticated one like the one that came in the HP67 manuals should not be very difficult to port.
The question may be if 12c users will found it interesting/enjoyable; since the combination of a bare numeric display like [-50.0500 00] and Newtonian physics may not suit those users' taste.
Now, for my HP41/42 Space Shuttle Landing Simulator... well, I don't think the HP12c/cp may cut it!
Regards
PS: In real life and business, you can often consider TVM as a "game" (not always for fun, indeed!).
▼
Posts: 1,545
Threads: 168
Joined: Jul 2005
Regarding the lunar lander...the version I'd be happy to have would just be the one with a display of -50.0500 as you start your fall to the surface.
The 12cp gives a challenge with only 2 conditionals and no subroutines. :-) That's what makes putting games on it fun.
I hope to post the 4 digit bagels game shortly.
▼
Posts: 1,193
Threads: 43
Joined: Jul 2005
The HP25 Lunar Lander version uses some 45 steps, just four registers, and no trigs or logs. It uses conditionals just three times: x<0 for display formatting, x<y for checking if fuel is enough, and x<0 to see if altitude is still positive. With some recoding and eventual use of extra registers and steps, it should be almost line-by-line portable to the 12C. Further, the Applications Handbook gives comments at various steps to clarify things.
The next sophistication level comes with spaceship mass correction as the fuel is used; and you can also use a random number to cause minor variations in altitude or thrust (say 1%), just to make the game not as deterministic. After all, the moon surface is rough, so a little randomness may well be due.
Posts: 2,448
Threads: 90
Joined: Jul 2005
Quote: after all, who would ever believe someone was playing games on that financial calculator. ;-)
That's the best part ;-)
Posts: 1,545
Threads: 168
Joined: Jul 2005
Here it is...all 258 lines of it. PLEASE feel free to help correct any mistakes or suggest improvements. My goal is not to have any programming pride left :-) but to have a good workable Bagels game for the 12cp.
Couple of notes: 1) the g prefix is not included for the comparison tests, the x^2 and SQRT (square root) functions, and not for the FRAC and INT functions. ROLL DOWN is pretty self explanatory. Line 62 is "gold shift 1" to set the display to 1 decimal point.
The steps which compare each digit of the secret and guessed number work like this: I subtract the digits which will either give me a 0, or -3 through -1 or a 3 through 1. I then take the absolute value by squaring and then square rooting the result. That means I have a 0 (indicating a matched number) or a positive 1, 2, or 3. I then put a 1 on the stack and test this 1 to the previous result (which is either a 0, 1, 2, or 3 in the Y-register). If this 1 is <= the number in Y, I do not have a match and I replace the 1 with a 0. Otherwise, the 1 stays. I then add the number in X (which is a 1 if it was a match or a 0 if it was not a match) to the appropriate counter for guesses (Memory 0 is for correct guesses and 1 is for incorrect).
Memory usage: 0 is the correct digit counter, 1 is the wrong place but in the secret number counter, 2 through 5 hold one digit of the secret number (don't peek!), 6 through 9 hold one digit of the entered guess number, memory .0 holds the seed, memory .1 holds the input guess number as a 4 digit value (which is destroyed as the digits are separated), and memory .2 holds the guess count.
How to use: 1) Key in a decimal seed for each game and press GTO 000 then R/S. The calculator will generate the secret number and stop displaying 0.0. 2) Enter a 4 digit guess and press R/S. 3) The calculator will return a number of the form X.Y, where X is the count of digits in your guess that are in right place in the secret number and Y is the count of digits in your guess that occur in the secret number, but are in the wrong location. 4) Continue entering 4 digit guesses and pressing R/S until you have guessed the secret number. 5) When you guess the number correctly, the display will show 4.0. The number of guesses you took is in the Y-register and can be viewed by pressing X<>Y.
Example game:
1) Seed 0.123456789 GTO 000 R/S --- calculator shows 0.0 in about 3-4 seconds.
2) Guess 1234 R/S --- calculator shows 2.1 in about 5-6 seconds. We have 2 digits correctly guessed and 1 digit right but in the wrong spot.
3) Guess 9134 R/S --- calculator shows 0.3, so we have 3 numbers right but in the wrong spot.
4) Guess 1263 R/S --- calculator shows 3.0, so we have 3 numbers in the right spots.
5) Guess 1293 R/S --- calculator shows 4.0 -- only took 4 guesses. That's good!
For a new game, enter a new seed, press GTO 000 and then R/S.
Note: The game will generate a secret number that may have duplicate digits.
Known issues: Of course, as I typed up the instructions, I noticed a couple of things. 1) If the secret number is 2222 and you guess 2222, the display does not show 4.0, but 5.2 of all things. Why? I'm thinking through that one. 2) If the secret number is 1292 and you guess 1294, you'll get 3.1 shown, since the "2" you guess will be correct for digit 2 and in the wrong place for digit 4 of the secret number. I'm sure this could be fixed (if desired), but at what step expense?
So, there you have it. I'd like for this to be viewed as the start of a few more games for the 12cp. Improvements are welcomed! :-)
1 STO . 0 55 STO 7 109 RCL 6 163 RCL 7 217 RCL 9
2 9 56 STO 8 110 RCL 3 164 RCL 5 218 RCL 3
3 9 57 STO 9 111 - 165 - 219 -
4 7 58 STO . 1 112 X^2 166 X^2 220 X^2
5 X 59 STO . 2 113 SQRT 167 SQRT 221 SQRT
6 FRAC 60 STO 0 114 1 168 1 222 1
7 STO . 0 61 STO 1 115 X<=Y 169 X<=Y 223 X<=Y
8 9 62 f 1 116 0 170 0 224 0
9 X 63 R/S 117 STO + 1 171 STO + 1 225 STO + 1
10 1 64 STO . 1 118 RCL 6 172 RCL 8 226 RCL 9
11 + 65 1 119 RCL 4 173 RCL 2 227 RCL 4
12 INT 66 0 120 - 174 - 228 -
13 STO 2 67 / 121 X^2 175 X^2 229 X^2
14 RCL . 0 68 ENTER 122 SQRT 176 SQRT 230 SQRT
15 9 69 INT 123 1 177 1 231 1
16 9 70 STO . 1 124 X<=Y 178 X<=Y 232 X<=Y
17 7 71 - 125 0 179 0 233 0
18 X 72 1 126 STO + 1 180 STO + 1 234 STO + 1
19 FRAC 73 0 127 RCL 6 181 RCL 8 235 RCL 9
20 STO . 0 74 X 128 RCL 5 182 RCL 3 236 RCL 5
21 9 75 STO 9 129 - 183 - 237 -
22 X 76 RCL . 1 130 X^2 184 X^2 238 X^2
23 1 77 1 131 SQRT 185 SQRT 239 SQRT
24 + 78 0 132 1 186 1 240 1
25 INT 79 / 133 X<=Y 187 X<=Y 241 X<=Y
26 STO 3 80 ENTER 134 0 188 0 242 0
27 RCL . 0 81 INT 135 STO + 1 189 STO + 1 243 STO + 0
28 9 82 STO . 1 136 RCL 7 190 RCL 8 244 RCL . 2
29 9 83 - 137 RCL 2 191 RCL 4 245 1
30 7 84 1 138 - 192 - 246 +
31 X 85 0 139 X^2 193 X^2 247 STO . 2
32 FRAC 86 X 140 SQRT 194 SQRT 248 RCL 1
33 STO . 0 87 STO 8 141 1 195 1 249 1
34 9 88 RCL . 1 142 X<=Y 196 X<=Y 250 0
35 X 89 1 143 0 197 0 251 /
36 1 90 0 144 STO + 1 198 STO + 0 252 RCL 0
37 + 91 / 145 RCL 7 199 RCL 8 253 +
38 INT 92 ENTER 146 RCL 3 200 RCL 5 254 0
39 STO 4 93 INT 147 - 201 - 255 STO 1
40 RCL . 0 94 STO 6 148 X^2 202 X^2 256 STO 0
41 9 95 - 149 SQRT 203 SQRT 257 ROLL DOWN
42 9 96 1 150 1 204 1 258 GTO 063
43 7 97 0 151 X<=Y 205 X<=Y
44 X 98 X 152 0 206 0
45 FRAC 99 STO 7 153 STO + 0 207 STO + 1
46 STO . 0 100 RCL 6 154 RCL 7 208 RCL 9
47 9 101 RCL 2 155 RCL 4 209 RCL 2
48 X 102 - 156 - 210 -
49 1 103 X^2 157 X^2 211 X^2
50 + 104 SQRT 158 SQRT 212 SQRT
51 INT 105 1 159 1 213 1
52 STO 5 106 X<=Y 160 X<=Y 214 X<=Y
53 0 107 0 161 0 215 0
54 STO 6 108 STO + 0 162 STO + 1 216 STO + 1
▼
Posts: 1,545
Threads: 168
Joined: Jul 2005
Ok, the 5.2 result is finding all 4 digits correct but also counting the other 3 locations as correct number but wrong location. 3 x 4 = 12 (which is 1.2 since it is shown as the tenths place). 4 + 1.2 = 5.2, which is shown if you guess 2222 for a secret number of 2222.
So, how should the program go about that stuff?
Posts: 2,761
Threads: 100
Joined: Jul 2005
Hello Gene,
I remember there was a game like this in the TI-59 owner's manual. However, repeated numbers were not allowed, as well "0". This makes the game easier to play.
This game was one of the things I missed when my 59C was stolen, so as soon as I finished reading the manual of the 15C I had bought as a replacement, I ported the game to the new calculator. Actually, this was my first RPN program, so the TI influence may show a little.
Of course, the 15C made things quite easier. Even today I wouldn't try it on the 12CP. Congratulations!
Now, just one question: I heard the old Platinum had a bug which didn't allow more than 255 programming lines. I see your program has 258 lines. Is this issue resolved?
Regards,
Gerson.
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv014.cgi?read=68346
Edited: 22 Sept 2005, 6:47 p.m.
▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
I have a fix for the 5.2 problem programmed. I'll test it for obvious problems and post an update shortly.
And, the step count is now well above 255 and it works perfectly. :-)
▼
Posts: 93
Threads: 2
Joined: Jul 2005
Bilbo Baggins of Bag End burgled not only his precious ring
but also a 12C which made him invisible while he programmed
it. His BEG key was of course marked BAG, being next to END.
While blowing smoke rings he used to think of bagels. After
many years he came up with a program for 1 to 6 bagels, with
the number being stored in [FV] (Food Value). Then along came
Gandalf and showed him how to make room for 7
bagels...but one mustn't input anything past line 92!
4 [FV] sets us up for 4 bagels.
[FV] is preserved, until changed by the user.
Before running the first time a seed should be stored in [i].
For example:
.123456789 [i]
The seed is modified by the program but the latest seed remains
in [i], so for subsequent games it is not necessary to
re-seed.
All guesses are fractions, which of course appear with an
initial bagel before the decimal point.
The source is below. All digits from 0-9 are allowed and
digits can be repeated in the hidden target.
To run with [i] and [FV] as above:
[f][PRGM][R/S] -> 4.0 (your target)
.123 (read as .1230) R/S -> 1.1 so 2 digits are correct but
one is misplaced.
.4567 R/S -> 0.1
.5813 R/S -> 3.0
.5810 R/S -> 4.0
Now try the next random game like this:
[f][PRGM][R/S] -> 4.0 (your target)
.0123 R/S -> 0.2
.4567 R/S -> 0.2
.1653 R/S -> 2.2 Yeah we have all digits! 2 need swapping.
.3651 R/S -> 4.0
All available 12C resources are used when FV=7.
Keystrokes |Display | Comments
[f][P/R] | |
[f]CLEAR[PRGM] |00- |
0 |01- 0 | generate hidden#
[n] |02- 11 |
1 |03- 1 |
0 |04- 0 |
[RCL][i] |05- 45 12 |
9 |06- 9 |
9 |07- 9 |
7 |08- 7 |
[x] |09- 20 |
[g][FRAC] |10- 43 24 |
[i] |11- 12 |
[x] |12- 20 |
[g][INTG] |13- 43 25 |
[g][CFj] |14- 43 14 | N.B. pre-increments n *and*
0 |15- 0 | automatically stores 1 in Nj
[g][Nj] |16- 43 15 | We want 0 in the Nj.
[RCL][n] |17- 45 11 |
[RCL][FV] |18- 45 15 |
[g][x<=y] |19- 43 34 |
[g][GTO]23 |20- 43,33 23 |
[g][GTO]03 |21- 43,33 03 |
[RDN] |22- 33 |
[R/S] |23- 31 |
[PV] |24- 13 | Guess entry
[RCL][FV] |25- 45 15 |
[STO]0 |26- 44 0 | outer loop counter
1 |27- 1 |
0 |28- 0 | get next digit from guess
[RCL][PV] |29- 45 13 |
[x] |30- 20 |
[g][INTG] |31- 43 25 |
[PMT] |32- 14 | store it in PMT
[g][LSTx] |33- 43 36 |
[g][FRAC] |34- 43 24 |
[PV] |35- 13 | save rest of digits in PV
[RCL]0 |36- 45 0 | test the big damage first
[n] |37- 11 | N.B.:RCL Cfj post-decrements n
[RCL][g][CFj] |38- 45,43 14 |
[RCL][PMT] |39- 45 14 |
[-] |40- 30 |
[g][x=0] |41- 43 35 |
[g][GTO]65 |42- 43,33 65 | ahha, a big hit.
[RCL][FV] |43- 45 15 | Now go after misplaced chappies
[n] |44- 11 |
[RCL][n] |45- 45 11 | save old n
[RCL][g][CFj] |46- 45,43 14 | post-decrements n
[RCL][PMT] |47- 45 14 |
[-] |48- 30 |
[g][x=0] |49- 43 35 |
[g][GTO]55 |50- 43,33 55 | found one!
[RCL][n] |51- 45 11 | already decremented
[g][x=0] |52- 43 35 |
[g][GTO]69 |53- 43,33 69 | get next guess digit
[g][GTO]45 |54- 43,33 45 | keep sweeping
[RDN] |55- 33 |
[n] |56- 11 | re-store old n
[RCL][g][Nj] |57- 45,43 15 |
[g][x=0] |58- 43 35 |
[g][GTO]62 |59- 43,33 62 | OK we can count this one
[RCL][g][CFj] |60- 45,43 14 | otherwise, keep on truckin
[g][GTO]51 |61- 43,33 51 |
1 |62- 1 |
0 |63- 0 |
[g][GTO]68 |64- 43,33 68 |
[RCL]0 |65- 45 0 | re-store old n
[n] |66- 11 |
1 |67- 1 |
[g][Nj] |68- 43 15 |
1 |69- 1 | exit test
[STO][-]0 |70- 44 30 0 |
[RCL]0 |71- 45 0 |
[g][x=0] |72- 43 35 |
[g][GTO]75 |73- 43,33 75 |
[g][GTO]27 |74- 43,33 27 |
[RCL][FV] |75- 45 15 | create result
[n] |76- 11 | by backward sweep
0 |77- 0 |
[RCL][g][Nj] |78- 45,43 15 |
[g][x=0] |79- 43 35 |
[g][GTO]82 |80- 43,33 82 |
[1/x] |81- 22 |
[+] |82- 40 |
0 |83- 0 |
[g][Nj] |84- 43 15 | re-initialize the Nj
[RDN] |85- 33 |
[RCL][g][CFj] |86- 45,43 14 |
[RDN] |87- 33 |
[RCL][n] |88- 45 11 |
[g][x=0] |89- 43 35 |
[g][GTO]22 |90- 43,33 22 | finished!
[RDN] |91- 33 |
[g][GTO]78 |92- 43,33 78 |
[f][P/R] | |
Long live FERMI.PICO & BAGELS!!!
Edited: 26 Sept 2005, 6:24 a.m. after one or more responses were posted
▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
Show off. :-)
Seriously, this is great. I'd much rather have a smaller program than a bigger one. Good to see use of the cash flow registers to store things.
Now, how about a lunar lander game?
▼
Posts: 93
Threads: 2
Joined: Jul 2005
Quote:
Show off. :-)
LOL! It was a lot of fun.
Quote:
Seriously, this is great. I'd much rather have a smaller program than a bigger one. Good to see use of the cash flow registers to store things.
I'd never tried using/abusing both the CFj and the Nj before.
It's easier to keep things constant in the CFj - as soon as one does a [g][CFj] the associated Nj gets set to 1 - it can be preserved of course but takes a few lines more in this case. Maybe someone can knock 10 lines off it though - it's pretty ugly in parts - most of it seems to be housekeeping.
Quote:
Now, how about a lunar lander game?
Well here is something that may be OK. It's early morning here and I've only been awake for an hour but this does seem to work. If I do nothing I crash like a lunatic<G> going at 90 feet/sec, after about 8-9 sequences!
--------------------
Follows 29moonld.htm here on www.hpmuseum.org - 92 lines
that become 94 on the 12C. The instructions are the same
except that [f][PRGM][R/S] restarts instead of GSB 1.
Here Regs 1-4 are used instead of 6-9.
It's indeed a pretty good little model.
I never played it before but I can see how it became so popular,
as google attests :-)
To burn fuel I press "f" at the end of the countdown :-)
Very very tricky to land with zeros flashing.
Keystrokes |Display | Comments
[f][P/R] | |
[f]CLEAR[PRGM] |00- |
5 |01- 5 |
0 |02- 0 |
0 |03- 0 |
[STO]1 |04- 44 1 |
5 |05- 5 |
0 |06- 0 |
[CHS] |07- 16 |
[STO]2 |08- 44 2 |
6 |09- 6 |
0 |10- 0 |
[STO]3 |11- 44 3 |
[RCL]1 |12- 45 1 |
[f]4 |13- 42 4 |
[EEX] |14- 26 |
4 |15- 4 |
[/] |16- 10 |
[RCL]2 |17- 45 2 |
[g][x=0] |18- 43 35 |
[g][GTO]27 |19- 43,33 27 |
[ENTER] |20- 36 |
[ENTER] |21- 36 |
[x] |22- 20 |
[g][SQRT] |23- 43 21 |
[/] |24- 10 |
[x] |25- 20 |
[RCL]2 |26- 45 2 |
[+] |27- 40 |
[g][PSE] |28- 43 31 | display VV.0hhh
[g][PSE] |29- 43 31 |
[f]0 |30- 42 0 |
[RCL]3 |31- 45 3 |
[g][PSE] |32- 43 31 |
3 |33- 3 |
[g][PSE] |34- 43 31 |
2 |35- 2 |
[g][PSE] |36- 43 31 |
1 |37- 1 |
[g][PSE] |38- 43 31 |
0 |39- 0 |
[g][PSE] |40- 43 31 | accept input
[ENTER] |41- 36 |
[ENTER] |42- 36 |
[RCL]3 |43- 45 3 |
[-] |44- 30 |
[g][x=0] |45- 43 35 |
[g][GTO]51 |46- 43,33 51 | ok burn the lot
[RDN] |47- 33 |
[g][LSTx] |48- 43 36 |
[g][x<=y] |49- 43 34 |
[g][GTO]75 |50- 43,33 75 | don't have that much fuel ->crash
[x<>y] |51- 34 |
[STO][-]3 |52- 44 30 3 |
2 |53- 2 |
[x] |54- 20 |
5 |55- 5 |
[-] |56- 30 |
[STO]4 |57- 44 4 |
2 |58- 2 |
[/] |59- 10 |
[RCL]1 |60- 45 1 |
[+] |61- 40 |
[RCL]2 |62- 45 2 |
[+] |63- 40 |
[RCL]4 |64- 45 4 |
[STO][+]2 |65- 44 40 2 | new V
[RDN] |66- 33 |
[STO]1 |67- 44 1 | new h
[g][INTG] |68- 43 25 | if more than 1 foot away
1 |69- 1 | we are
[g][x<=y] |70- 43 34 | allowed to go
[g][GTO]12 |71- 43,33 12 | off for another burn
[RCL]2 |72- 45 2 | otherwise crash
[g][PSE] |73- 43 31 | velocity flashes
[g][GTO]73 |74- 43,33 73 |
[RCL]3 |75- 45 3 | free-fall
2 |76- 2 |
[.] |77- 48 |
5 |78- 5 |
[-] |79- 30 |
[STO][+]1 |80- 44 40 1 | adjust h
2 |81- 2 |
[x] |82- 20 |
[STO][+]2 |83- 44 40 2 | adjust V
[RCL]1 |84- 45 1 |
1 |85- 1 |
0 |86- 0 |
[x] |87- 20 |
[RCL]2 |88- 45 2 |
[ENTER] |89- 36 |
[x] |90- 20 |
[+] |91- 40 |
[g][SQRT] |92- 43 21 |
[CHS] |93- 16 | final V
[g][GTO]73 |94- 43,33 73 |
[f][P/R] | |
On the platinums we could use the x^2 on lines 21&22 and 89&90.
Cheers,
Tony
Edited: 24 Sept 2005, 3:22 p.m.
▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
Tony, you are the master! :-) I bet you get your name in an hp12c platinum owners manual some day. ;-)
Ok...folks...which OTHER games do we want for the 12cp?
How about:
a) a tic-tac-toe program that uses the keyboard as the playing area?
b) a jive-turkey game (a variation on the high/low game where the calculator "lies" at times).
c) or a basic craps game.
Some samples of these (for the HP25 and HP65) can be found (of course) at:
http://www.rskey.org/gene/hpgene/index.html
Personally, I've always wondered what a full TVM program would look like written on the hp12cp. Why do that? To learn better how to program the 12cp!
Without subroutines, with only 2 comparisons, I think it would be a challenge to fit it all in.
Thanks again Tony!
Perhaps these two are good candidates for a future Datafile article?
Gene
▼
Posts: 93
Threads: 2
Joined: Jul 2005
Quote:
Tony, you are the master! :-) I bet you get your name in an hp12c platinum owners manual some day. ;-)
hehe. I do cheat quite a lot - I do the programming on a palmtop and run it through a formatter and usually type it in just once.
Quote:
How about:
a) a tic-tac-toe program that uses the keyboard as the playing area?
b) a jive-turkey game (a variation on the high/low game where the calculator "lies" at times).
There are some really nice touches in that one. I couldn't resist it. Listing below.
Quote:
c) or a basic craps game.
Some samples of these (for the HP25 and HP65) can be found (of course) at:
http://www.rskey.org/gene/hpgene/index.html
Thanks for this great resource Gene!
hehe your Jive Turkey really jives - it has a GSB 4 in line 7 but there is no target for that. GSB 1 fits.
Quote:
Personally, I've always wondered what a full TVM program would look like written on the hp12cp. Why do that? To learn better how to program the 12cp!
Without subroutines, with only 2 comparisons, I think it would be a challenge to fit it all in.
Yup the challenge is what makes it worthwhile really. I don't know why they put TWO tests on the 12C - one would have been enough<G>
Quote:
Thanks again Tony!
My pleasure.
Quote:
Perhaps these two are good candidates for a future Datafile article?
Gene
Your idea about doing the games is great. I found an old "Super bagels" for the 67 today - quite impressive.
Jive Turkey for the 12C
-----------------------
Originally by Maurice E.T.Swinnen founder and Editor of TI PPC
Notes (1980-1982). Transcribed for HP-67 in PPC Journal Jan
1978 by Terry Mickelson(PPC #1926). The HP-67 has flags and
subroutines. Here we use FV as a flag and replicate
the 63 line HP-67 version in 66 lines.
'Jive Turkey' was famous. Nowadays Maurice dedicates his free
time to ballroom dancing. Still jivin' :-)
Setup (no need to clear registers)
-----
1. Seed (0-199,017) [n]
2. %Truth (0-100) [i]
3. [R/S]->0 (ready for first guess)
4. Input guess(0-99) [R/S]
5. See +-1 (plus/minus indicates high/low)
6. Repeat 4 till you see not +-1 but your total number of
guesses. This means you won't know what a +1 means after your
first guess. Just re-run with the same guess and if you were
right you'll see a 2 :-)
7. To play a second game: [f][PRGM][R/S]
It is not necessary to input a new [n] or [i], unless you want
to. [n] automatically has a new seed for each game. They can
be changed at any time. Lower [i] if you are getting j[i]ved
too much. i=0 is nice and simple :-)
Keystrokes |Display | Comments
[f][P/R] | |
[f]CLEAR[PRGM] |00- |
0 |01- 0 |
[STO]0 |02- 44 0 |
[FV] |03- 15 | special flag
[g][GTO]13 |04- 43,33 13 |
[RDN] |05- 33 |
[STO]1 |06- 44 1 | initialization finished.
[RCL]0 |07- 45 0 | will show 0 as no guesses yet
[R/S] |08- 31 |
[STO]2 |09- 44 2 | guess entry
1 |10- 1 |
[STO][+]0 |11- 44 40 0 | increment guess count
[FV] |12- 15 | set hi/lo flag
2 |13- 2 |
4 |14- 4 |
2 |15- 2 |
9 |16- 9 |
8 |17- 8 |
[RCL][n] |18- 45 11 |
[x] |19- 20 |
[EEX] |20- 26 |
5 |21- 5 |
[ENTER] |22- 36 |
9 |23- 9 |
[-] |24- 30 | 100,000 - 9
[+] |25- 40 |
1 |26- 1 |
9 |27- 9 |
9 |28- 9 |
0 |29- 0 |
1 |30- 1 |
7 |31- 7 |
[/] |32- 10 |
[g][LSTx] |33- 43 36 |
[x<>y] |34- 34 |
[g][FRAC] |35- 43 24 |
[x] |36- 20 |
[n] |37- 11 | new seed
[g][LSTx] |38- 43 36 |
[EEX] |39- 26 |
2 |40- 2 |
[x] |41- 20 |
[g][INTG] |42- 43 25 | first time=target, then truth test.
[RCL][FV] |43- 45 15 |
[g][x=0] |44- 43 35 |
[g][GTO]05 |45- 43,33 05 |
[RDN] |46- 33 |
[RCL][i] |47- 45 12 |
[g][x<=y] |48- 43 34 | exceedingly true?
[g][GTO]53 |49- 43,33 53 | leave flag
1 |50- 1 | clear flag
[CHS] |51- 16 |
[FV] |52- 15 |
[RCL]1 |53- 45 1 |
[RCL]2 |54- 45 2 |
[-] |55- 30 |
[g][x=0] |56- 43 35 |
[g][GTO]07 |57- 43,33 07 |
[RCL]2 |58- 45 2 |
[RCL]1 |59- 45 1 |
[g][x<=y] |60- 43 34 | high?
[g][GTO]65 |61- 43,33 65 |
[RCL][FV] |62- 45 15 |
[CHS] |63- 16 | toggled flag
[g][GTO]08 |64- 43,33 08 |
[RCL][FV] |65- 45 15 |
[g][GTO]08 |66- 43,33 08 |
[f][P/R] | |
Hats off to Maurice and all originators of these
old games!
Edited: 26 Sept 2005, 6:20 a.m.
Posts: 28
Threads: 10
Joined: Jun 2007
I think there has been a formula error in calculation of crash velocity since 1976 (HP-67 Moon Rocket Lander) and it’s here again.
Background:
In this game acceleration a = 2*burn-5
From Physics book:
x = x0 + v0*t + 0.5*a*t^2 and when t = 1 => x = x0 + v0 + 0.5*a
=> x = x0 + v0 + burn - 2.5
v = v0 + a*t and when t =1 => v = v0 + a => v = v0 + 2*burn - 5
But see lines 75-83:
75 RCL 3
76 2
77 .
78 5
79 -
80 STO+1
81 2
82 *
83 ST0+2
As you see in lines 75-80 a new height x is calculated as x = x0 + burn - 2.5.
What happened to v0? This should be x = x0 + v0 + burn - 2.5
Therefore I would like to add two lines 75 and 76:
75 RCL 2
76 STO+1
77 RCL 3
78 2
79 .
80 5
81 -
82 STO+1
83 2
84 *
85 STO+2
etc.
Do you agree? I’m not a physicist.
▼
Posts: 93
Threads: 2
Joined: Jul 2005
I agree :-)
The final crash involves 2 steps - the rest of the fuel is burned, and then we have another cycle under the 5 ft/sec/sec acceleration.
You're right - the distance has to be fully updated after the burn.
Cheers,
Tony
Posts: 1,545
Threads: 168
Joined: Jul 2005
When I run it with the input seed of 0.123456789 i and 4 in FV, I get these results:
0.123 -> 1.2
0.4567 -> 0.0
0.5813 -> 2.0
0.5810 -> 3.0
I've checked my listing and it all appears ok. Typo in the instructions? :-)
▼
Posts: 93
Threads: 2
Joined: Jul 2005
Thanks for testing on the new 12c platinum Gene! It converts the .123456789 seed into a guess with one digit different to that produced by the 12C. The platinum has a "2" instead of the 12C "5".
The platinum has 2 extra digits - and this has an effect when we are using the 997 * FRAC 10 *.
I see the answer now. The Solutions Handbook "Random Number Generator" uses a 7 digit seed on purpose - the .5284163. If we use .1234567 instead of .123456789 then the 12C and new 12c platinum agree 100% :-)
It only takes a couple of lines to make it run like yours - with no zeros chosen, and with integral input. But then the .123456789 seed it gives 1286 - not the 1293 you got on the new platinum - same issue with the extra 2 digits held in the new one.
Oh I see a great 223 line "Super bagels" in an old 67-97 Games Pac book here. It's like mine (variable secret number length from 1-8 digits, mine is now only 1-6 again) uses integral input and you can specify a maximum digit - yup we can do that too - 99 lines. That is my final version :-) I see other great progs in the book - many suitable for the platinum - the craps game has a .528461 in - we know where that comes from :-)
Cheers, Tony
Edited: 27 Sept 2005, 6:40 a.m.
Posts: 68
Threads: 1
Joined: Jul 2005
Hi Tony,
I had a look at your program. Nice use of the financial registers - I've learned a lot about how they work from your program. I have a HP-12C, but I had only ever learned how to use the TVM formula, and do some simple programming on it.
Unfortunately, there seems to be a error in your logic for generating the response to the user input for certain secret numbers and corresponding guesses. This can be seen with the number of bagels set to 4 (in FV) and an initial seed of 0.14 (in i). This results in a secret number of .3225. If you enter a guess of .2235, the calculator responds with 2.1 and not the expected 2.2. A guess of .3522 does return 2.2, and a guess of .3225 returns 4.0, as expected. I see where the error in the logic is, but I don't have a fix.
After looking at your program, I have a few of questions about the HP-12C that you or someone else may be able to answer.
- Are the n, i, PV, PMT and FV registers permanently allocated in addition to the other registers?
- Where are the values for the Nj registers stored? I see that they can only be in the range 0 to 99, but I don't see where they are stored. Does the calculator borrow a couple of BCD digits from the corresponding CFj regitser?
Best Regards,
Eamonn.
▼
Posts: 93
Threads: 2
Joined: Jul 2005
Eamonn - thanks you are of course 100% correct. I always suspected my logic :-) Am sketching a fix as I write. All the big hits need to be completed first. You came up with a brilliant example to show the flaw - many thanks!
later ... lucky the extra little loop was there for accessing ... 7 more lines. Fits but can probably be shrunk. I want to preserve new features making it like the HP-67 "Super Bagels" - variable max digit and plain integer entry instead of the decimal. Interesting logical flaw - almost worth leaving in ;-)
Re your other questions - yes the TVM registers are permanently allocated. FV does double as the very top Cfj though. All I know about the Nj is that every available Cfj has one. Sure looks like they borrow "part of" the corresponding storage register.
Cheers,
Tony
Edited: 29 Sept 2005, 6:41 a.m.
|