code: def TraceAgent(agent):
      
      old_program = agent.program
      def new_program(percept):
          action = old_program(percept)
          print '%s perceives %s and does %s' % (agent, percept, action)
          return action
      agent.program = new_program
      return agent
docs: Wrap the agent's program to print its input and output. This will let
      you see what the agent is doing in the environment.