Lunar Porter, rung three and a half: fuel

Every thruster costs a unit every tick it fires, so holding two at once
costs two - the honest price, and it makes a drift you corrected expensive
in a way a drift you avoided is not.

AN EMPTY TANK IS NOT AN ENDING. There is no message and nothing stops: a
lander with no fuel is still flying, it just cannot do anything about
where. What happens next is gravity, and gravity is patient. The test for
it holds the thruster from the first frame to the last and crashes anyway,
which is what says the fuel is real - a lander that could hold Up for ever
would land every time, and the economy this is the first half of would
have nothing to buy.

The gauge is in the window, which is what the window was built for two
commits ago: a bar at a SCREEN position, so the moon turning underneath
does not carry it off. Thirty five cells after a label, redrawn whole
every frame because seventy bytes out of one port is cheaper than working
out which of them changed.

A byte of fuel, and a byte is enough. Over eight it is a bar of up to
thirty one cells - a shift, because there is no divide - and at a unit a
thruster a tick it is about forty seconds of holding the engine open.
Sixteen bits would be more arithmetic for a number nobody reads to the
unit.

Cargo and the bases are the other half.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-03 00:35:34 -04:00
co-authored by Claude Opus 5
parent 17c8da111f
commit 2274be4b68
17 changed files with 199 additions and 12 deletions
+32
View File
@@ -1707,6 +1707,38 @@ EOT
&& result ok "a held thruster keeps lifting" "row $EARLY early, row $LATE later" \
|| result no "a held thruster keeps lifting" "row $EARLY early, row $LATE later"
# ---- The fuel gauge, in the window ----
#
# A bar in the window layer, which is at a SCREEN position - so the moon turning underneath it
# does not move it, which is the whole reason the window exists and the reason this is not
# drawn in the map like the terrain is.
#
# Two captures with the thruster held throughout. The bar has to be SHORTER in the later one,
# because a thruster costs a unit of fuel every tick it fires: a gauge that did not shrink
# would be a tank that was not being spent.
python3 -c "open('$BUILD/burn.pad','wb').write(b'\x08' * 4000)"
for when in 1500000 6000000; do
timeout 30 "$EMU" --fast --cycles $when --keyboard "$BUILD/lander.keys" \
--pad "$BUILD/burn.pad" --screen "$BUILD/burn$when.ppm" \
--disk "$ROOT/Tests/build/disks/cosmos.img" --ram-disk 2048 \
"$BUILD/cosmos.bin" > "$BUILD/burn.out" 2>&1 || true
done
read -r GAUGEEARLY GAUGELATE <<EOT
$(python3 -c "
def gauge(path):
d = open(path, 'rb').read()
px = d[d.index(b'255\n') + 4:]
green = bytes.fromhex('50c050')
at = [i % 320 for i in range(len(px) // 3)
if px[i * 3:i * 3 + 3] == green and i // 320 == 3]
return max(at) if at else -1
print(gauge('$BUILD/burn1500000.ppm'), gauge('$BUILD/burn6000000.ppm'))
" 2>/dev/null || echo "-1 -1")
EOT
[ "$GAUGEEARLY" -gt 0 ] && [ "$GAUGELATE" -gt 0 ] && [ "$GAUGELATE" -lt "$GAUGEEARLY" ] \
&& result ok "a held thruster spends the tank" "the gauge ran to $GAUGEEARLY, then to $GAUGELATE" \
|| result no "a held thruster spends the tank" "$GAUGEEARLY early, $GAUGELATE later"
# ---- The drift bar, which is a scaled sprite doing a job ----
#
# A moon has no air, so a sideways drift never stops by itself and stopping one means