FixTheRobot Explore Robotics / Robot Learning / M5 / M5-L3

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

Robot Learning · Reward Design · M5-L3 · Intermediate

Balance Reward Terms

Experiment log · Scout at Meridian General Hospital

Experiment log, Meridian General Hospital. Facilities have asked for three things from Scout at once: get to the pharmacy quickly, never fall down the stairwell, and stop weaving between the supply carts like a shopping trolley. Each wish became a term in the reward: a cost per step, a penalty for stepping onto the stairwell edge, and a penalty for every change of heading. Nobody said how large each term should be.

You will not write any learning code in this lab. You set the weights; the page solves the resulting decision problem exactly with value iteration, then measures what Scout does with it: expected steps, the probability of a fall and the expected number of turns. A trade-off curve shows how those quantities move as one weight is swept, and a final stage asks for one setting that meets all three limits on wards you have not seen.

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 trades time against risk: how large must the stairwell penalty be, and why does the answer depend on the step cost? Stage 2 adds a comfort term and shows that it changes the price of everything else: asking for smoother driving can quietly buy a much higher fall rate. Stage 3 states the requirement the way a hospital would, as three limits, and asks for one set of weights that meets them on every hidden ward, so that tuning on a single example is not enough.

    Every route is the exact optimum of the weighted reward (value iteration on a table that remembers the last action, so that a turn is well defined), and every figure shown is computed exactly from the policy's state distribution, not from a lucky run. The limits are this lab's own acceptance limits, not universal constants.

    Theory for this lab

    Reward Design labs

    1. M5-L1: Shape a Reward Without Changing the Task
    2. M5-L2: Find the Reward Hack
    3. M5-L3: Balance Reward Terms: this lab.

    Educational simplification: one family of wards, slip as the only source of noise, a turn defined as a change of the intended action, discount 0.99, and exact optimal policies with no learning noise. Real systems balance more terms, measure them from logged data, and usually need a constrained formulation or a safety layer rather than a hand-tuned weight.

    Get the next lab

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