HP Forums
(42S/DM42/Free42/Plus42) Classic Moon Simulator - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (42S/DM42/Free42/Plus42) Classic Moon Simulator (/thread-18945.html)



(42S/DM42/Free42/Plus42) Classic Moon Simulator - Eddie W. Shore - 10-10-2022 03:10 AM

Variables:

X: Position
V: Velocity
F: Fuel
G: Gravity
B: Amount of Fuel to burn

Initial Values (from the HP-33E Applications):
X = 500
V = -50
F = 120
G = 5

I wasn't sure about the win condition (X = 0, V = 0?).

I show the position, velocity, and fuel after each successful turn. Enter the amount of units to burn at the burn prompt.


Download here (raw file): https://drive.google.com/file/d/1YsYzIMxALuRx_MHSSzGFFEQJdrN656DS/view?usp=sharing


Code:
00 { 184-Byte Prgm }
01▸LBL "MOON"
02 500
03 STO "X"
04 -50
05 STO "V"
06 120
07 STO "F"
08 5
09 STO "G"
10▸LBL 01
11 "POS:"
12 ARCL "X"
13 AVIEW
14 STOP
15 "VEL:"
16 ARCL "V"
17 AVIEW
18 STOP
19 "FUEL:"
20 ARCL "F"
21 AVIEW
22 STOP
23 RCL "X"
24 X=0?
25 GTO 07
26▸LBL 02
27 "BURN?"
28 PROMPT
29 STO "B"
30 RCL "F"
31 X<Y?
32 GTO 05
33▸LBL 03
34 RCL "B"
35 STO- "F"
36 RCL- "G"
37 STO "A"
38 RCL "V"
39 RCL+ "X"
40 RCL "A"
41 2
42 ÷
43 +
44 STO "X"
45 X≥0?
46 GTO 04
47 GTO 06
48▸LBL 04
49 RCL "V"
50 RCL+ "A"
51 STO "V"
52 GTO 01
53▸LBL 05
54 2
55 RCL× "G"
56 RCL "V"
57 X↑2
58 +
59 SQRT
60 +/-
61 STO "V"
62▸LBL 06
63 "VEL:"
64 ARCL "V"
65 AVIEW
66 "YOU LOSE"
67 AVIEW
68 RTN
69▸LBL 07
70 "SUCCESS!"
71 AVIEW
72 .END.


Source:

HP-33 Applications. Hewlett Packard. Corvallis, OR. March 1979