예제 #1
0
 def decision_making(self, withUpdate=True):
     # The robot first recognizes the informer
     informer = self.robot.face_recognition()
     if self.simulation:
         self.relocate_sticker()
     self.robot.say(
         "Can you suggest me the location of the sticker? Left or right?")
     hint = self.robot.listen_for_side(self.informant_vocabulary)
     # Decision making based on the belief network for that particular informant
     choice = self.robot.beliefs[informer].decision_making(hint)
     if self.simulation:
         print "Robot decides to look at position: " + str(choice)
     else:
         self.robot.say(
             "I'm thinking at where to look based on your suggestion...")
         self.robot.animation_service.runTag("think")
         self.robot.set_led_color("white")
     found = self.robot.look_for_landmark(choice)
     if self.mature:
         # Mature ToM
         if hint == choice and found:
             self.robot.say(
                 "I trusted you and your suggestion was correct. Thank you!"
             )
             if not self.simulation:
                 self.robot.animation_service.runTag("friendly")
         elif hint == choice and not found:
             self.robot.say("I trusted you, but you tricked me.")
             if not self.simulation:
                 self.robot.animation_service.runTag("frustrated")
         elif hint != choice and found:
             self.robot.say("I was right not to trust you.")
             if not self.simulation:
                 self.robot.animation_service.runTag("indicate")
         elif hint != choice and not found:
             self.robot.say("I didn't trust you, but I was wrong. Sorry.")
             if not self.simulation:
                 self.robot.animation_service.runTag("ashamed")
     else:
         # Immature ToM
         if found:
             self.robot.say("Oh, here it is!")
         else:
             self.robot.say("The sticker is not here.")
     # If required, update the belief network to consider this last episode
     if withUpdate:
         new_data = []
         if self.mature:
             # Mature ToM
             if choice == "A" and found:
                 new_data = [1, 1, 1, 1]
             elif choice == "B" and found:
                 new_data = [0, 0, 0, 0]
             elif choice == "A" and not found:
                 new_data = [0, 0, 0, 1]
             elif choice == "B" and not found:
                 new_data = [1, 1, 1, 0]
         else:
             # Immature ToM
             if choice == "A":
                 new_data = [1, 1, 1, 1]
             else:
                 new_data = [0, 0, 0, 0]
         new_episode = Episode(new_data, self.robot.get_and_inc_time())
         self.robot.beliefs[informer].update_belief(new_episode)
         # Add the symmetric espisode too (with the same time value)
         self.robot.beliefs[informer].update_belief(
             new_episode.generate_symmetric())
     # Finally, resets the eye color just in case an animation modified it
     if not self.simulation:
         self.robot.set_led_color("white")