Lesson 5-4 · The Pathfinding Functions — Knowledge ChecksAnswer key
Why must a planner be TOLD the robot's position instead of remembering it?
The driving code owns the position. Two copies of the same fact is how a planner ends up planning from an intersection the robot left three steps ago.
Why does add_blocked() not need `global BLOCKED`, when set_threshold() in Lesson 2-7 needed `global THRESHOLD`?
`global` is needed only to reassign a module-level name. Appending to a list changes the list that BLOCKED already names; the name itself is untouched.
(1,1) is blocked. Someone wrote build_graph with the first `in blocked` check but forgot the second. What is wrong with the result?
The first check removes (1,1) as a key. Only the second check removes it from the lists of (0,1), (1,0), (1,2) and (2,1). Without it, a search could step into the wall.