← All 96 breakdowns
LANDER

LANDER: the step-by-step breakdown

From Adam Rosler. The thing you commented LANDER for: train an agent that lands on the Moon tonight, then turn it into a project worth putting on your resume.

What the reel showed

Gymnasium's LunarLander-v3 is a free simulator. The agent sees 8 numbers (position, speed, tilt, spin, two leg contacts), presses one of 4 buttons (nothing, left, main, right engine) and gets points: closer and slower is good, tilting and fuel cost a little, +100 for landing, -100 for crashing, 200 counts as solved. Nobody tells it how to fly. Our run on a CPU: untrained it crashed 20 of 20; at 300,000 steps it still crashed 18 of 20; after 1,000,000 steps (8 min 27 s) it landed 20 of 20, averaging 255 points. The algorithm, PPO, is the one OpenAI used to fine-tune InstructGPT on human feedback.

Build it (about an hour, no GPU)

  1. Install. pip install "gymnasium[box2d]" stable-baselines3 (Python 3.10+; on Windows you may need swig).
  2. Watch it fail. python -c "import gymnasium as gym; e=gym.make('LunarLander-v3', render_mode='human'); e.reset(); [e.step(e.action_space.sample()) for _ in range(300)]"
  3. Train. Run land.py (this page, 10 lines). It saves lander.zip. On a laptop CPU, 1M steps takes roughly 10-30 minutes.
  4. Watch it land. Load it and render: model = PPO.load("lander"); obs, _ = env.reset(); action, _ = model.predict(obs, deterministic=True) in a loop with render_mode="human".
  5. Measure it. Average the score over 20 episodes with fixed seeds; 200 or more is solved. train_and_record.py does this at checkpoints and saves frames and per-step data for your before/after clips.

Make it a resume project, not a tutorial

  • Change the reward and explain why: charge more for fuel, punish tilting harder, add wind (gym.make("LunarLander-v3", enable_wind=True)), and show what the agent does differently.
  • Show the before and after: the untrained crash, the trained landing (clips), and the learning curve.
  • Write one paragraph: what you changed, what you expected, what happened, and one thing that surprised you (ours: at 300,000 steps it still crashed most of the time; then it got good fast).
  • Put the code, the clips and the curve in a public repo with a short README.

Sources: Gymnasium LunarLander-v3 documentation (Farama Foundation); Stable-Baselines3 and the RL Baselines3 Zoo hyperparameters; Ouyang et al. 2022, arXiv:2203.02155. Our run's numbers are kept with the reel's project files.

Files for this breakdown

FREE ONE-TIME UNLOCK

Unlock the full LANDER breakdown + downloadable runnable scripts

Drop your email once to read the complete step-by-step guide, grab the files, and unlock all 96 Reel breakdowns on this device forever.

✓ Instant reveal right here✓ No spam, unsubscribe any time