Monte Carlo has to wait until an episode ends before it can learn anything. Temporal-difference learning updates after every single step, by comparing its current estimate with a slightly better one: the reward just received plus its estimate of where it landed.
Implement td0_update(V, state, reward, next_state, alpha, gamma, done=False), returning a new value table with only V[state] updated.
V is a float array indexed by integer state. Do not modify it; return an updated copy.reward + gamma * V[next_state], or just reward if done is true (a terminal state has no future value).V[state] towards the target by a fraction alpha of the gap.Open one at a time. Each gives away a little more than the last.
Compute the target, then the TD error target - V[state].
Add alpha * error to V[state].
No results yet
Run your code to check it against the examples, or submit to run every test.