Discounted Return From Scratch
Difficulty: Easy · Concept: RL Fundamentals — Markov Decision Processes (MDPs)
An RL agent doesn't just care about the very next reward — it cares about the total reward it can expect going forward, the return. Future rewards are discounted by a factor per timestep, so a reward steps away counts for of its face value:
close to 1 means the agent is nearly as concerned with far-future rewards as immediate ones ("far-sighted"); close to 0 means it barely looks past the next step ("short-sighted"). This return, not any single reward, is what value functions (Policies and Value Functions) are actually trying to predict.
Your task: implement discounted_return(rewards, gamma), where rewards is a list [r_0, r_1, ..., r_T] in time order.
Next: Full Return-to-Go Sequence (a harder variant)