States, actions, rewards — the framework for sequential decisions — solved by rippling worth out from the goal.
A Markov Decision Process (MDP) is the standard way to frame a sequential decision problem: an agent in some state takes an action, lands in a new state, and collects a reward. The aim is a policy — a rule for which action to take in each state — that earns the most reward over time.
S — the situations the agent can be in (e.g. which grid cell).A — the choices available in a state (up/down/left/right).P(s' | s, a) — where an action lands you (bumping a wall leaves you put).R — the payoff: +1 at the goal, -1 in the pit, -0.04 per step to discourage wandering.γ — a number in [0, 1) (say 0.9) that makes reward-soon worth slightly more than reward-later.Define V(s) as the best total future reward achievable from state s. The Bellman optimality equation says each state's value equals the best action's immediate reward plus the discounted value of where it leads. Value iteration just applies this update again and again until the numbers stop changing.
V(s) <- max over actions a of:
sum over s' of P(s' | s, a) · [ R(s, a, s') + γ · V(s') ]
# repeat for every state until V stops changing (converges to V*)P and rewards R up front — it plans on a known map. When the agent must *learn* the world from trial and error instead, you reach for model-free methods like Q-learning.