Unit 3 of 11 · about 4 hours · implement

Random shooting and cross-entropy planning against a known-dynamics oracle

Planning bugs and modeling errors look identical downstream. An oracle planner isolates the first, so later failures belong to the model.

You'll be able to

  • Implement random shooting against a known-dynamics oracle and report its best return with the sample budget stated.
  • Implement the cross-entropy method (sample, elite refit, repeat) and show it beating shooting on equal samples.
  • Defend the oracle-plus-simple-controller as the baseline every learned-model result must beat.

Covers

Random shooting and cross-entropy method planningKnown-dynamics oracle and simple-controller baseline
1

Read

In this order, only the parts listed

0 of 3 done

  1. Lecture 16: Model-Based RL Part 2, shooting and CEM slidesBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Model-Based RL

    Part 1 (Planning with models: random shooting as guess and check, CEM with a Gaussian, CMA-ES pointer, MCTS and trajectory-optimization pointers)

  2. PETS, CEM versus random shootingDeep Reinforcement Learning in a Handful of Trials using Probabilistic Dynamics Models (PETS)

    arXiv:1805.12114v2, Sections 5 to 6 with Appendix A.8: CEM with 5 iterations of 500 samples (2500 in total) against random shooting with 2500 samples on the true half-cheetah simulator, so the optimizers are compared without model error (Figure A.11), and the horizon note (Figure A.8)

  3. Lecture 11: Model-Based RL, planning example slideStanford CS224R Spring 2026 - Model-Based RL

    Slide 28: Nagabandi et al. 2019 (ensemble of 3 nets, short-horizon shaped reward, iterative CEM, 30-trajectory alternation)

2

Focus on

  • Random shooting samples sequences and keeps the best. CEM fits the next Gaussian to the elite fraction and repeats, so later samples concentrate where returns were high.
  • The comparison is only fair on equal model queries. CEM with 5 iterations of 500 samples (2500 in total) beats shooting with 2500 samples because it reallocates them, not because it uses more.
  • The oracle uses true dynamics. Its return is the planner ceiling: a learned model that scores below a simple controller on the oracle has a planning problem, not a modeling problem.
Common mistakes · 3
  • Refitting CEM to all samples instead of the elites. The mean then barely moves and the method degrades to shooting with extra steps.
  • Letting the elite fraction collapse the variance to zero in one iteration. Keep a small variance floor so later iterations can still search.
  • Presenting the oracle return as a model-based result. It used no learning; it is the baseline, not the achievement.
3

Try it yourself

Closed-book, before checking anything

From a blank file with one np.random.default_rng(0) stream, plan with reward from over with actions in . Draw 200 uniform sequences for random shooting: the best scores -1.4964 at . Continue the same stream for CEM from mean 0 and standard deviation 1: each iteration draws 200 Gaussian sequences clipped to , keeps the top 20 percent, and refits the mean and per-step standard deviation to them. The mean return of the elites is -2.4868, -1.2234 and -1.0640 across 3 iterations, against an optimum of about -1.02 near . CEM spent 600 samples, so rerun shooting with 600 before claiming a win on equal samples. Run on CPU.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does CEM beat random shooting on the same total sample budget?Answer

    It spends later samples near the best sequences found so far by refitting the sampling distribution to the elites, while shooting spreads every sample over the initial broad distribution.

  2. 2.What does PETS Figure A.11 establish, exactly?Answer

    On the true half-cheetah simulator, CEM with 5 iterations of 500 samples (2500 in total) plans significantly better than random shooting with 2500 samples. It is the paper's planning comparison on the paper's setup, not a learner target.

  3. 3.Your learned-model planner scores below random shooting on the true dynamics. What is broken?Answer

    The planner or its budget, not the model: the oracle test removes modeling error, so the gap must come from planning.

  4. 4.Should the executed action be the first element of the CEM mean or the full mean sequence?Answer

    Under MPC, only the first action, followed by replanning. Executing the full sequence is open loop and forfeits feedback.

You're done when

Your shooting and CEM implementations match the four seed-0 numbers, and you can state the oracle return as the planner ceiling for your later model.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 5 more in the section
  • Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Model-Based RLUC Berkeley · primary

    Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lectures 15 and 16 (model-based RL: learned dynamics, open-loop and closed-loop planning, random shooting and CEM, MPC, model-based policy learning). There is no model-based homework, so build the planner yourself on a small environment with known dynamics first.

  • Stanford CS224R Spring 2026 - Model-Based RLStanford University · support

    Use Lecture 11 (model-based RL) and its MBPO reading as a second treatment of model error, uncertainty and short model rollouts.

  • Deep Reinforcement Learning in a Handful of Trials using Probabilistic Dynamics Models (PETS)Chua et al. (NeurIPS 2018) · support

    Read the split between aleatoric uncertainty (probabilistic networks) and epistemic uncertainty (ensembles) and the trajectory-sampling planner. Implement an ensemble on a small task and show where the members disagree.

Also in this section

  • Reinforcement Learning: An Introduction (2nd ed.) - Chapter 8Richard Sutton and Andrew Barto · required

    The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 8.1 to 8.3 (models, Dyna-Q, when the model is wrong) and Sections 8.8 to 8.11 (decision-time planning, rollout algorithms and Monte Carlo Tree Search). Reproduce the Dyna-Q versus Dyna-Q+ ranking on the blocking or shortcut maze.

  • When to Trust Your Model: Model-Based Policy OptimizationJanner et al. · required

    Study the model-error analysis and short model-rollout design. Reproduce a reduced real-plus-imagined-data comparison and retain the horizon where model bias reverses the gain.

  • Mastering Diverse Domains through World ModelsDeepMind · depth

    Read DreamerV3 only after the small explicit dynamics and planning path passes. Trace representation, latent dynamics, imagination and actor-critic state, but do not make a large benchmark reproduction part of the exit gate.

  • Hands-on Modern RL - Model-Based and World-Model SectionsWalking Labs · support

    Use Sections 9.3 and 9.4 as concept maps for model-based RL, search and world models. No runnable dynamics or planner script exists, so reproduce its error-recursion numbers by hand and verify algorithm claims against the original papers. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its code/chapterNN folders do not follow the site chapter numbers.

  • Reinforcement Learning Control Laboratory - Model-Based StretchRoadmap-Final · support

    Add a learned-dynamics stretch with a known-dynamics sanity case, prediction and planning tests, horizon sweeps, model-exploitation failure and matched model-free comparison.