code: def ModelBasedVacuumAgent():
      "An agent that keeps track of what locations are clean or dirty."
      model = {loc_A: None, loc_B: None}
      def program((location, status)):
          "Same as ReflexVacuumAgent, except if everything is clean, do NoOp."
          model[location] = status ## Update the model here
          if model[loc_A] == model[loc_B] == 'Clean': return 'NoOp'
          elif status == 'Dirty': return 'Suck'
          elif location == loc_A: return 'Right'
          elif location == loc_B: return 'Left'
      return Agent(programf ModelBasedVacuumAgent():
      "An agent that keeps track of what locations are clean or dirty."
      model = {loc_A: None, loc_B: None}
      def program((location, status)):
          "Same as ReflexVacuumAgent, except if everything is clean, do NoOp."
          model[location] = status ## Update the model here
          if model[loc_A] == model[loc_B] == 'Clean': return 'NoOp'
          elif status == 'Dirty': return 'Suck'
          elif location == loc_A: return 'Right'
          elif location == loc_B: return 'Left'
      return Agent(program)
docs: An agent that keeps track of what locations are clean or dirty.