Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LunarLander

State space

The SVector<f32, 8> observation is normalized horizontal and vertical displacement from the helipad, scaled horizontal and vertical velocity, angle, scaled angular velocity, and left/right leg-contact flags. Its declared bounds are \([-2.5,2.5]^2\), \([-10,10]^2\), \([-2\pi,2\pi]\), \([-10,10]\), and \([0,1]^2\).

Action space

  • Discrete: 0 idle, 1 left orientation engine, 2 main engine, 3 right orientation engine.
  • Continuous: \([a_m,a_s]\in[-1,1]^2\). The main engine activates for \(a_m>0\) with power \(0.5\operatorname{clip}(a_m,0,1)+0.5\). The side engine activates for \(|a_s|>0.5\), with direction sign(a_s) and power \(\operatorname{clip}(|a_s|,0.5,1)\).

Dynamics and reward

Engine impulses are applied at offset points, creating both translation and torque; gravity and optional wind/turbulence act before a Rapier step of \(1/\text{fps}\). For observation \(s\), shaping is

\[ H(s)=-100\sqrt{s_0^2+s_1^2}-100\sqrt{s_2^2+s_3^2}-100|s_4|+10s_6+10s_7. \]

\[ r_t=H(s_{t+1})-H(s_t)-0.30p_{main}-0.03p_{side}. \]

A successful landing overrides reward to \(+100\); a crash or leaving the horizontal screen overrides it to \(-100\). In the current collision handler, any started collision whose colliders both have parent bodies sets the crash flag; this is broader than hull-only collision and is an implementation difference to keep in mind when comparing with Gymnasium.

Episode end

Termination occurs when the current crash flag is set, when the lander leaves the horizontal screen, or on a settled two-leg landing with near-zero linear and angular velocity. Truncation occurs at max_steps.

Configuration

FieldsDefaultsMeaning
scale, fps, max_steps30, 50, 1000Geometry scale, simulation rate, horizon
main_engine_force, side_engine_force13, 0.6Engine impulse scales
side_engine_offset_x/y12, 14Side-thruster application offset
main_engine_y_position4Main-thruster offset
leg_offset_x/y20, 18Leg attachment geometry
leg_width/length2, 8Leg collider size
leg_spring_torque40Leg-joint motor strength
gravity-10Vertical acceleration
continuousfalseSelect action representation
wind_strengthNoneOptional horizontal wind amplitude
turbulence_strength1.5Angular disturbance amplitude
initial_random1000Initial random force magnitude
viewport_width/height600, 400World scaling and normalization

All fields are public and common values have builders. Info is ().

Reference: Gymnasium LunarLander.