Monte Carlo Exploring Starts
A control method that starts every practice run from a random situation with a random first move, so even a stubborn greedy policy ends up testing everything.
Why Does This Exist?
A greedy policy has a blind spot: it only visits what it already likes. If early estimates are wrong, the truly best action never gets tried, so its value never improves, so it never gets tried. The loop seals shut. This is the classic exploration problem in Monte Carlo control, where values are learned from full episodes with no model to query about untried branches.
Exploring starts breaks the loop at the root. Sutton and Barto (Chapter 5) assume every state action pair has nonzero probability of opening an episode. After that forced first step, the agent follows its deterministic greedy policy all the way to termination. Randomize the opening, keep everything else greedy, and every choice gets sampled infinitely often in the limit, which is what lets plain averaging converge to optimal values in episodic tasks. When forced openings are impossible, the successor is on-policy first-visit MC control, which explores with soft policies instead.
The one idea you need first
Values here are action values : the expected return after taking action in state . Returns are discounted sums of rewards to the end of the episode, , with discounting later rewards. The full treatment of estimating them from episodes is in Monte Carlo action values.
Think of It Like This
A food critic with a forced first bite
A critic reviews restaurants but has a rut: they always order the pasta, so the kitchen's brilliant fish never gets judged. Their editor imposes one rule: each visit opens with a random dish drawn from the menu, first bite mandatory. After that, the critic eats the rest of the meal by their usual habits and writes the review.
Over many visits every dish gets a fair hearing without changing how the critic normally eats. Random opening dishes are exploring starts, usual habits are the greedy policy, and the published reviews are the averaged returns.
Where it stops: no editor can force a real first bite everywhere, and the math needs every pair to keep a nonzero chance forever plus episodes that actually end. Real kitchens also change menus, while this method assumes fixed dynamics.
How It Actually Works
Initialize arbitrarily and as any deterministic policy. Then repeat:
Open. Draw and so that every pair keeps positive probability, for all and .
Roll. From onward act greedily, , until termination at time .
Score. Walk backward accumulating .
Update. For the first visit of each pair in the episode, with counting visits so far:
Improve. For each visited state, set .
No exploration parameter appears anywhere after step zero. The policy stays fully greedy because the opening carries the whole exploration burden.
Worked example
Two states, actions Left and Right, . Current values at : , , so . Exploring starts forces the opening . The episode runs: into , then the greedy policy earns and terminates.
The pair was seen once before, so goes to :
Now compares against , so flips to Right. One forced opening found a line the greedy policy would never have touched. The diagram draws this exact episode.
Code
This snippet replays the worked example with type hints: accumulate the return backward, then apply the averaging update.
def episode_return(rewards: list[float], gamma: float) -> float: """Discounted return G0 for one episode's reward sequence.""" g = 0.0 for r in reversed(rewards): g = r + gamma * g return g
def mc_update(q: float, n: int, g: float) -> tuple[float, int]: """Fold one first-visit return into the running average.""" n_new = n + 1 return q + (g - q) / n_new, n_new
g0 = episode_return([4.0, 10.0], 0.90)print(f"G0={g0:.4f}") # -> G0=13.0000q_new, n_new = mc_update(1.0, 1, g0)print(f"Q={q_new:.4f} N={n_new}") # -> Q=7.0000 N=2The printout matches the hand computation: and moves to , flipping the greedy choice.
Watch Out For
Assuming you can start anywhere in the real world
In a simulator, opening at any state and action is one line of code. In a plant or on a road, it means teleporting a reactor into an explosive regime or a car sideways into traffic. The method then quietly stops exploring and the policy stagnates, with no error raised. Symptom: training curves flatline outside simulation. Fix: switch to epsilon soft policies that explore from natural starts, as in on-policy first-visit control.
Applying it where episodes never end
Monte Carlo updates need a terminal reward to score the episode. In continuing tasks there is no , so the backward pass has nothing to accumulate and the update never fires. Symptom: values stay at initialization while the agent keeps acting. Fix: use temporal difference methods, which bootstrap from the next estimate instead of waiting for termination.
The Quick Version
- Exploring starts forces every state action pair to keep a nonzero chance of opening an episode.
- After the forced first step the policy is purely greedy and deterministic, with no exploration parameter.
- Episodes are scored backward into returns , and first visits update with a running average.
- Each visited state's policy is reset to the current greedy best, which is what drives improvement.
- It fits simulators and episodic tasks, not physical systems with unsafe starts or tasks that never terminate.