FixTheRobot Explore Robotics / Robot Learning / M4 / M4-L1

This lab works on phones, but writing code is much easier on a laptop.

Robot Learning · Reinforcement Learning Foundations · M4-L1 · Intermediate

Solve an MDP by Value Iteration

Experiment log · Scout at Meridian General Hospital

Experiment log, Meridian General Hospital, east ward. Scout must carry a medication tray from the nurses' station to the pharmacy. The ward is a small grid: some cells are walls, one is the pharmacy, and the open stairwell has no railing. After the night shift cleaned the floors, they are slippery: about one move in five turns sideways.

The map and the slip are known, so Scout does not need to learn anything by trial and error. You will turn the transition table into the optimal value of every cell with value iteration, then read the best route off those values. On the way you will meet the two bugs that sink most first attempts: a terminal cell that leaks future reward, and a route chosen by looking only where Scout means to go.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and heapq. Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 writes the Bellman backup for one action: the expected reward plus the discounted value of the next cell, averaged over the slip outcomes, with the terminal case handled. Stage 2 repeats the backup over the whole grid until the values stop changing and compares your table with the exact one on a heat map. Stage 3 turns the values into a policy by one-step lookahead and asks whether following it earns the optimal return.

    Grading is result-based: your functions run on the practice ward and on other grids with different slip and discount, which you do not see. Stage 2 is compared with the exact optimal values and checked for convergence; stage 3 is scored by exact policy evaluation, so a route that merely looks plausible does not pass.

    Theory for this lab

    Reinforcement Learning Foundations labs

    1. M4-L1: Solve an MDP by Value Iteration: this lab.
    2. M4-L2: Implement Q-Learning
    3. M4-L3: Tune Exploration
    4. M4-L4: Debug a Q-Learning Agent

    Educational simplification: a few small grids with a known transition table, one reward scale, and a stairwell that is either deadly (episode ends) or sends Scout back to the start. A real ward has many more states, and Scout would have to learn the table; Modules 4 and 5 relax that step by step.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.