A policy trained only on human driving never sees the states its own mistakes lead to. comma.ai trains on-policy instead: actors drive the current policy in a simulator, a future-anchored plan model labels every visited state with the action that would bring the car back to the recorded future position, and a learner fits the policy to those labels. Implement a one-dimensional version (lateral offset from the lane).
The state is the lateral offset (meters). The policy is linear, (lateral velocity, m/s). The vehicle moves as , where is an injected disturbance. The future anchor says the car must be back at offset goal at step f_s.
plan_label(y, t, f_s, dt, goal=0.0)
goal exactly at step f_s from step t < f_s: .rollout(w, y0, f_s, dt, noise)
noise: length f_s disturbances. For t = 0 .. f_s - 1: record the state y and its label plan_label(y, t, f_s, dt), then step .(states, labels), two lists of length f_s.fit_policy(states, labels)
0.0 if ).train(w0, starts, noises, f_s, dt, iterations)
i runs rollout(w, starts[i], f_s, dt, noises[i]) with the current w; the learner pools all their states and labels and sets w = fit_policy(...).w after each iteration, rounded to 4 decimals.