TL;DR
Random shooting is a way to pick the next action for a robot without solving an optimisation problem. It draws many random sequences of future actions, runs each one forward through a model of the system, adds up the predicted cost of each, and keeps the first action from the sequence with the lowest cost. The next step, it does the whole thing again from the new state.
It needs nothing from the model except the ability to simulate it, so it works with models that are not smooth, such as a neural network or a physics simulator. Its weakness is that random guesses become sparse quickly as the plan gets longer.
Where you'll see it: model-based reinforcement learning on legged and arm robots, where a learned dynamics model is too complicated to differentiate cheaply, and as a simple baseline for Model Predictive Control in research code.
Intuition
Throw darts, keep the best
Imagine you need to drive a cart to a target and you may choose any push over the next second. You cannot see the best push directly, so you try many. Pick ten thousand random push sequences, imagine each one playing out with a physics model, and score how close each one ends up to the target while using little effort. Then take the best-scoring sequence and do only its first push. Once the cart has moved, pick a fresh batch of random sequences from the new position and repeat.
The name comes from this shooting: each random sequence is a shot at the target, and the best shot wins. Nothing clever is going on in each shot. The cleverness is in the repetition. Because you re-plan after every step, a bad guess early on is corrected at the next step, and the plan is always built from where the robot actually is.
flowchart LR S[measure state x_t] --> R[draw K random action sequences] R --> P[simulate each through the model] P --> C[add up the cost of each rollout] C --> B[pick the lowest-cost sequence] B --> A[apply only its first action] A --> S
The loop is the same as Model Predictive Control. What changes is how the best plan is found. MPC usually solves a constrained optimisation with a gradient-based solver. Random shooting replaces that solver with sampling.
The math
Setup
Take a discrete-time system with state and action . A model predicts the next state, . Over a horizon of steps, an action sequence is . Starting from the measured state , the model rolls out a predicted state trajectory. We score the rollout with a running cost at each step and a terminal cost at the end of the plan:
Here is the predicted total cost of a plan, and is the state the model predicts after steps. The running cost penalises distance from a goal and the size of the actions. The terminal cost scores where the plan ends. This is the same cost that Optimal Control and MPC use.
The algorithm
Random shooting approximates the minimisation over by sampling. At each time :
- Draw independent candidate sequences from a proposal distribution . A common choice is uniform on a box that respects the action limits.
- For each candidate, roll out the model from the measured state and compute .
- Select .
- Apply the first action to the real system. Discard the rest of the plan.
- Measure the next state and repeat from step 1.
Because the plan is only a set of samples, the best predicted cost satisfies , where is the true minimum over all sequences. The gap closes as grows and the proposal covers the region where good plans live.
How many samples are enough
Suppose the good plans make up a fraction of the proposal's probability mass. The chance that a single draw is good is , so the chance that none of independent draws is good is . The chance that at least one is good is
This is the central trade-off. For a fixed , the success probability rises towards 1 as grows, but slowly. For that is small, which happens when the horizon is long, you need very many samples. Each sample also needs a full rollout, so the cost of a plan is model evaluations per control step.
- ε = 0.01
- ε = 0.001
Worked examples
Use the same system as in the MPC lesson. The state moves by the action, . The running cost is , the terminal cost is , the horizon is , and the measured state is . Actions are limited to , so the unconstrained optimum is allowed. For a plan , the rollout gives and , and the cost is
Suppose four candidate sequences were drawn. These are chosen by hand, to show the arithmetic.
- Candidate : , . Cost .
- Candidate : , . Cost .
- Candidate : , . Cost .
- Candidate : , . Cost .
- The lowest cost is candidate 2, with 6.50. Apply its first action, . The state becomes , and the controller samples again from there.
- The exact optimum for this problem is , with cost 6.40, as the MPC lesson shows. None of the four draws hit it exactly, so the sampled answer is worse by 0.10.
Interpretation: four samples are enough to get a sensible first action, but not the best one. The error is small here because the cost surface is smooth and the good region is large. In a problem with more dimensions the good region shrinks, and the same four draws would miss it.
Suppose a good plan is one whose total cost lies within a band that holds 1 percent of the proposal's probability mass, so .
- With samples, the chance of at least one good plan is .
- With samples, it is .
- Tripling the samples takes the chance from about 63 percent to about 95 percent, so the cost is paid in model rollouts, roughly as many per step.
- Now suppose the horizon is ten times longer, and the good fraction drops to because the plan has more freedom to go wrong. With , the chance is , about 3 percent.
- To recover a 95 percent chance at the smaller fraction, you need with , so samples.
Interpretation: a fixed budget of samples works for short plans and fails for long ones. This is why random shooting is usually paired with a short horizon, a warm start from the previous plan, or a more focused proposal that concentrates samples where good plans are likely. The numbers above are analytic, not from an experiment.
Tradeoffs and failure modes
| Situation | What goes wrong | Better choice |
|---|---|---|
| Model is smooth and differentiable | Random shooting wastes samples that a gradient would find directly | Gradient-based shooting or direct optimisation, such as iLQR or direct collocation |
| Long horizon with few samples | Good plans are almost never drawn, so the chosen action is poor | Shorter horizon, warm start from the last plan, or a refined proposal |
| Tight constraints that carve out a small feasible set | Uniform draws almost always violate a constraint and get discarded | Sample from a projected or learned proposal, or add penalty terms to the cost |
| Model is inaccurate far from the data | The lowest predicted cost can belong to a plan that exploits model error | Ensembles of models, with disagreement added as a penalty, and short horizons |
| Real-time control on a robot | The sample count must fit the control period | Parallel rollouts on a GPU, or fewer samples per step |
| Sample-to-sample noise matters | Two runs can pick different plans, so behaviour looks jittery | Fix the random seed for evaluation, or average the top few plans |
Random shooting is the simplest member of a family. The cross-entropy method refits a Gaussian to the best samples and repeats, so the proposal moves towards good plans. MPPI weights each sample by an exponential of its cost, which gives a smooth average rather than a single winner. Both keep the same rollout-and-score core. Random shooting is easier to implement and reason about, and it is usually the right first baseline.
History
Choosing control inputs by simulating many candidate futures is much older than the name. Model predictive control was developed in the process industries from the 1970s, where a model of a plant was used to plan a few steps ahead at each sample time. The optimisation at each step was usually done with a numerical solver. Using random candidate sequences in place of a solver is a natural shortcut that appears throughout the stochastic-optimisation and robotics literature, where it is a standard baseline.
The method gained attention in learning-based robotics. In 2017, Nagabandi and colleagues trained neural network dynamics models for robots and used random shooting with those models to choose actions, then fine-tuned a policy on top. The paper showed that a simple sampling planner, combined with a learned model, could control real robots with few samples of experience. Its value came from how little it asked of the model. The planner needed only forward simulation, which a neural network provides cheaply, and no derivatives.
Check yourself
QuestionWhy does random shooting re-plan at every step, even though it computed a whole plan of H actions?Show answer
The model is an approximation, and the real system drifts from the prediction because of noise and model error. Only the first action is applied, and then the robot measures its actual state. Re-planning from that state corrects the drift and keeps the plan tied to reality. Using the whole predicted plan open loop would let errors compound over the horizon.
QuestionWith and samples, what is the probability that at least one sample is good?Show answer
The chance that no sample is good is . Since , this is . So the probability that at least one sample is good is , about 95 percent.
QuestionA planner with a learned neural network model needs gradients through the model, but the network is large and the cost is not differentiable at the goal. Is random shooting a good fit?Show answer
Random shooting needs only forward rollouts, so a non-differentiable cost is not a problem, and a large network is fine as long as each forward pass is fast enough for the sample budget. It is a reasonable fit for that setting. The weakness is that it needs many rollouts for long horizons, so a short horizon, a warm start, or parallel evaluation may be needed to meet the control period.
QuestionIn the four-candidate cart example, suppose the exact optimum had also been drawn. Which plan would random shooting apply, and what does this show?Show answer
That plan costs 6.40, which is lower than the 6.50 of the best drawn candidate, so random shooting would apply its first action, . The planner can only return a plan it has sampled, so the quality of the result depends on how many of the draws land near the good region. The more candidates that cover it, the closer the applied action is to the optimum.