From 456f228e17a8396ae676e0e231ffe5032afbd92e Mon Sep 17 00:00:00 2001 From: Martin Martin Date: Fri, 31 May 2024 14:00:46 -0400 Subject: [PATCH 1/2] Add explanation of variables and code structure. --- 59_Lunar_LEM_Rocket/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/59_Lunar_LEM_Rocket/README.md b/59_Lunar_LEM_Rocket/README.md index c0ec8df0..98db7aed 100644 --- a/59_Lunar_LEM_Rocket/README.md +++ b/59_Lunar_LEM_Rocket/README.md @@ -35,3 +35,33 @@ http://www.vintage-basic.net/games.html #### Porting Notes (please note any difficulties or challenges in porting here) + +### LUNAR + +Variables: + +`A`: Altitude in miles. Up is positive. +`V`: Velocity in miles / sec. Down is positive. + +`M`: Weight of capsule in pounds, both fuel and machine +`N`: Empty weight of capsule in pounds. So, weight of fuel is M - N. + +`G`: Gravity in miles / sec^2, down is positive. +`Z`: Exhaust velocity in miles / sec + +`L`: time in seconds since start of simulation. +`K`: Burn rate for this 10 second turn, pounds of fuel per sec +`T`: Time left in this 10 second turn, in seconds. +`S`: Burn time in this 10 second turn, input to subroutine 420. + +Subroutines: + +330, Apply updates from one call to subroutine 420. + +370, If you started descending and ended ascending, figure out whether you hit the surface in between. + +420, Compute new velocity and altitude using the Tsiolkovsky rocket equation for S seconds: + +`Q`: Fraction of initial mass that's burnt, i.e. 1 - mf / mo, exactly what we need for the Taylor series of `ln` in the rocket equation. Local to this subroutine. +`J`: Final velocity after S seconds, down is positive. Return value. +`I`: Altitude after S seconds, up is positive. Return value. From a2215f4f903551fa08debc3efd87c8d035c705a9 Mon Sep 17 00:00:00 2001 From: Martin Martin Date: Fri, 31 May 2024 14:15:52 -0400 Subject: [PATCH 2/2] Revert "Fix bug in Lunar: wrong capsule weight." This reverts commit 52e1bf49984960f0030f81bf968029c78b9729c9. The original commit modified the game away from what was in BASIC Computer Games, replacing it with the value from the original FOCAL version. The difference was intentional, as the introductory text makes clear, which is also in the README.md here: "To make the landing more of a challenge, but more closely approximate the real Apollo LEM capsule, you should make the available fuel at the start (N) equal to 16,000 lbs, and the weight of the capsule (M) equal to 32,500 lbs." Here we bring the value back into line with the BASIC Computer Games book & the README.md text. If we wanted to keep the FOCAL value, we should update the text in the README.md to explain why. See issue #867 --- 59_Lunar_LEM_Rocket/javascript/lunar.js | 2 +- 59_Lunar_LEM_Rocket/lunar.bas | 2 +- 59_Lunar_LEM_Rocket/python/lunar.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/59_Lunar_LEM_Rocket/javascript/lunar.js b/59_Lunar_LEM_Rocket/javascript/lunar.js index 4f693d00..43a0e892 100644 --- a/59_Lunar_LEM_Rocket/javascript/lunar.js +++ b/59_Lunar_LEM_Rocket/javascript/lunar.js @@ -113,7 +113,7 @@ async function main() print("\n"); a = 120; v = 1; - m = 32500; + m = 33000; n = 16500; g = 1e-3; z = 1.8; diff --git a/59_Lunar_LEM_Rocket/lunar.bas b/59_Lunar_LEM_Rocket/lunar.bas index 256eedff..30133615 100644 --- a/59_Lunar_LEM_Rocket/lunar.bas +++ b/59_Lunar_LEM_Rocket/lunar.bas @@ -12,7 +12,7 @@ 110 PRINT: PRINT: PRINT: PRINT "GOOD LUCK" 120 L=0 130 PRINT: PRINT "SEC","MI + FT","MPH","LB FUEL","BURN RATE":PRINT -140 A=120:V=1:M=32500:N=16500:G=1E-03:Z=1.8 +140 A=120:V=1:M=33000:N=16500:G=1E-03:Z=1.8 150 PRINT L,INT(A);INT(5280*(A-INT(A))),3600*V,M-N,:INPUT K:T=10 160 IF M-N<1E-03 THEN 240 170 IF T<1E-03 THEN 150 diff --git a/59_Lunar_LEM_Rocket/python/lunar.py b/59_Lunar_LEM_Rocket/python/lunar.py index fa7da3de..46a06674 100644 --- a/59_Lunar_LEM_Rocket/python/lunar.py +++ b/59_Lunar_LEM_Rocket/python/lunar.py @@ -127,7 +127,7 @@ class SimulationClock: class Capsule: altitude: float = 120 # in miles above the surface velocity: float = 1 # downward - m: float = 32500 # mass_with_fuel + m: float = 33000 # mass_with_fuel n: float = 16500 # mass_without_fuel g: float = 1e-3 z: float = 1.8