Re: Moon Landing Simulator for HP12c again Message #2 Posted by tony (nz) on 5 Oct 2005, 2:13 a.m., in response to message #1 by Kalevipoeg
Kalevipoeg , thank you! This is brilliant. Lines 1224 create the VV.0hhh very elegantly. Also I believe you are the first to calculate the correct crash velocity when the first iteration gives a new height as negative  you reverse time and bring us back to the surface with the correct speed!! Please move onto TicTactoe now:)
Gene's page has an ingenious program that uses 3 by 3 magic square space to facilitate win/block calculations.
Cheers,
Tony
Slightly less intense digit,.,EEX, alternatives might be:
5 lines 1418: RCL1 % % RCL2 X<>Y
12 lines 4455: ENTER + 5  STO4 RCL2 X<>Y STO+2 2 / + STO+1
One could even shave 1 line off this, if I count correctly<G>:
STO4 STO+4 5 STO4 RCL2 RCL4 STO+2 2 / + STO+1
Down to 78 lines and falling<G>. This is fun. From the quality of your code and clarity of exposition I feel I know you from somewhere ;)
Now I'm onto my third edit. It seems possible to remove more lines by allowing an empty craft to recycle once more. One could have 5 chs sto4 up at line 12. Then we can remove the 5 sto4, and change the start to STO+4 STO+4 above in my last feeble attempt to shave lines  but that part is now down to 9 where it was 12.
Instead we can do the rcl3 x=0? test by "inserting" x=0 gto "67" after the rcl 3 at line 39.
Overall this may save us another 3 lines, but I admit the operation will be slightly different  we get to "see" an empty craft just one more time before the freefall with R4=5. Of course we could save another 2 by not testing for R3=0 at all  just keep seeing the freefall second by second until we go underground at the end :)
But that is too slow ... although one can burn the 60 and see oneself travel out into space before returning. But, too slow to watch. The best place for the R3=0 test is probably after it is displayed  before the burn countdown  then one at least gets to see the final VV.0hhh begore the freefall. Yup, it seems to work fine here at 75 lines. Good night all. Thanks for the fun :)
Here it is, in case anyone wants to try/tweak/untweak it.
Thanks again to Kalevipoeg  whoever he/she is  maybe an exastronaut :) And also thanks to Gene for these game challenges.
Keystrokes Display  Comments
[f][P/R]  
[f]CLEAR[PRGM] 00 
5 01 5 
0 02 0 
0 03 0 
[STO]1 04 44 1  h=500ft
5 05 5 
0 06 0 
[CHS] 07 16 
[STO]2 08 44 2  V=50ft/sec
6 09 6 
0 10 0 
[STO]3 11 44 3  Fuel=60
5 12 5 
[CHS] 13 16 
[STO]4 14 44 4  accel=5ft/sec/sec
1 15 1 
[CHS] 16 16 
[RCL]1 17 45 1 
[%] 18 25 
[%] 19 25  +hE4=.0hhh
[RCL]2 20 45 2 
[x<>y] 21 34 
[] 22 30 
[g][x<=y] 23 43 34 
[g][GTO]28 24 43,33 28 
[RCL]2 25 45 2 
[g][LSTx] 26 43 36 
[+] 27 40 
[f]4 28 42 4 
[g][PSE] 29 43 31  VV.0hhh
[g][PSE] 30 43 31 
[RCL]3 31 45 3  Fuel
[f]0 32 42 0 
[g][PSE] 33 43 31 
[g][x=0] 34 43 35  no fuel left?
[g][GTO]63 35 43,33 63  free fall
3 36 3  count down
[g][PSE] 37 43 31 
2 38 2 
[g][PSE] 39 43 31 
1 40 1 
[g][PSE] 41 43 31 
0 42 0 
[g][PSE] 43 43 31 
[RCL]3 44 45 3 
[g][x<=y] 45 43 34 
[x<>y] 46 34 
[RDN] 47 33 
[STO][]3 48 44 30 3  update Fuel
[STO][+]4 49 44 40 4  update
[STO][+]4 50 44 40 4  acceleration
[RCL]2 51 45 2 
[RCL]4 52 45 4 
[STO][+]2 53 44 40 2  update V
2 54 2 
[/] 55 10 
[+] 56 40 
[STO][+]1 57 44 40 1  update h
0 58 0 
[RCL]1 59 45 1 
[g][x<=y] 60 43 34  underground?
[g][GTO]63 61 43,33 63  'recalc' crash velocity
[g][GTO]12 62 43,33 12  burn again
[RCL]2 63 45 2 
[ENTER] 64 36 
[x] 65 20  v0^2
[RCL]4 66 45 4 
[RCL]1 67 45 1 
[x] 68 20 
[ENTER] 69 36 
[+] 70 40  2*a*h
[] 71 30 
[g][SQRT] 72 43 21 
[CHS] 73 16  V at h=0
[g][PSE] 74 43 31 
[g][GTO]74 75 43,33 74 
[f][P/R]  
To find a final freefall time in seconds, stop &:
[RCL]2 [] [RCL]4 [/]
eg, if all 60 is burnt on first cycle, we obtain a final crash v of
96ft/sec and time=32 sec. This is the longest trip and worst
crash :)
Edited: 5 Oct 2005, 7:09 a.m.
