def update(self):
        if has_fallen():
            return "fallen"
        
        self.current_head_position=robotbody.get_head_position()
        
        if like(self.wanted_head_position,self.current_head_position):

            if self.ending:
                return "focus one"
            
            elif len(self.angles)==0:
                if vision.has_new_goal_observation():
                    self.get_goal_observation()
                    self.searching_for_next()
                    
                elif like(self.current_head_position[0],pi/2):
                    return "fail"
                
                else:
                    self.set_next_head_position()
            
            elif len(self.angles)==1:
                if vision.has_new_goal_observation():
                    self.get_goal_observation()
                    self.focus_middle()
                    
                else:
                    self.set_next_head_position()
            
            else:
                return "focus middle"
 def update(self):
     
     #Tests if the robot has fallen
     if has_fallen():
         return "fallen"
     
     #Stores the current time for tests and updates
     self.current_time=time.time()
     
     #Tests if the robot has lost the ball
     if self.has_lost_ball():
             print("lost ball")
             return "lost ball"
     
     #Test if the robot is standing in front of the ball
     self.distance_to_ball=distance_to_ball()
     if self.distance_to_ball>0 and self.distance_to_ball<self.distance:
         robotbody.set_eyes_led(0, 31, 0)
         print ("standing in front of ball")
         return "done"
     
     #Updates the position of the head
     self.update_head_position()
     
     #Updates the walking direction
     self.update_walk_direction()
 def update(self):
     if has_fallen():
         return "fallen"
     if self.get_state()==self._done:
         return "done"
     
     super(Program,self).update()
 def update(self):
     
     if has_fallen():
         return("fallen")
     
     self.update_head_position()
     
     if vision.has_new_ball_observation():
         return ("done")
 def update(self):
     if has_fallen():
         return "fallen"
     
     if self.timer<time.time():
         
         if vision.has_new_line_observation() and self.get_pitch_angle()<=pi/3:
             walk.set_velocity(0, 0, 0)
             return "standing on line"
    def update(self):
        
        #Tests if it has fallen
        if has_fallen():
            return "fallen"
        
        #Stores current time
        self.current_time=time.time()
        
        #Stores whether it has found a new ball observation
        self.has_new_ball_observation=vision.has_new_ball_observation()
        
        #Stores whether it has found a new goal observation
        self.has_new_goal_observation=vision.has_new_goal_observation()
        
        #Stores the distance to the ball
        self.distance_to_ball=distance_to_ball()
        
        #Stores the new angle and type if it has new observation of the goal
        if self.has_new_goal_observation:
            self.goal_angle,self.goal_type=goal_angle_and_type()
        
        #Tests if it has lost the ball
        if self.has_lost_ball() or self.to_long_distance():
            print ("lost the ball")
            return "lost ball"
        
        #Tests the adjustment timer
        if self.adjustment_timer and self.current_time>=self.adjustment_timer:
            robotbody.set_eyes_led(0, 31, 0)
            print("probably looking at goal")
            return "done"
        
        #Test if it has found a goal post
        if (self.has_new_goal_observation and self.looking_at_goal())\
            or self.changed_speed and self.current_time>self.start_time:
            robotbody.set_eyes_led(0, 31, 0)
            print("found goal, " + self.which_goal_type)
            return "done"
        
        #Tests if it is time to abandon the search for a goal
        if self.current_time > self.start_time + self.max_circling_time:
            robotbody.set_eyes_led(0, 0, 31)
            print("lucky shot")
            return "fail"

        
        #Updates the head position
        self.update_head_position()
        
        #Updates the walking speed for the robot
        self.update_speed()
 def update(self):
     #Tests if the robot has fallen
     if has_fallen():
         return "fallen"
     
     #Test if the last vision of a goal was the opponents
     if self.opponents_goal():
         robotbody.set_eyes_led(0, 31, 0)
         print("fire at opponents goal")
         return "fire"
     else:
         robotbody.set_eyes_led(0, 0, 31)
         print ("turning towards opponents goal")
         return "turn"
 def update(self):
     
     if has_fallen():
         return "fallen"
     
     if self.get_state()==self._done:
         print ("looking at goal")
         return "done"
     
     if self.get_state()==self._lost_ball:
         print("lost ball")
         return "lost ball"
     
     super(Program,self).update()
 def update(self):
     
     #Tests if the robot has fallen
     if has_fallen():
         return "fallen"
     
     #Tests if the robot hasn't kicked yet.
     #If it hasn't it will move sideways or kick the ball
     if not self.time_since_kick:
         self.move_or_kick()
     
     #Test if the time since the last kick is enough for it to
     #have returned to standing position
     if self.time_since_kick and time.time()>self.time+self.time_since_kick:
         return "done"
 def update(self):
     if has_fallen():
         return("fallen")
     
     self.update_traveled_time()
     
     self.update_head_position()
             
     if vision.has_new_ball_observation():
         self.update_last()
         self.left_or_right()
         
     elif self.last_observation+self.accepted_out_of_sight_time<time.time():
         return ("out of sight")
             
     self.walk_sideways()
 def update(self):
     
     if has_fallen():
         return "fallen"
     
     if vision.has_new_goal_observation():
         
         if like(goal_angle()[0],0):
             return "done"
         else:
             return "standing in front of the goal"
     
     self.current_head_position=robotbody.get_head_position()
     
     if like(self.current_head_position,pi/2):
         return "can't find the goal"
     
     if like(self.wanted_head_position,self.current_head_position):
         self.update_head_position()
 def update(self):
     #Testing if it has fallen
     if has_fallen():
         return "fallen"
     
     #Storing the current time for the update
     self.current_time=time.time()
     
     #Testing if it has lost the ball
     if self.has_lost_ball():
         print ("lost the ball")
         return "lost ball"
     
     #Test if it has finished it's turn
     if self.current_time > self.start_time + self.time:
         print("aiming away from our goal")
         return "done"
     
     #Updating the speed at which the robot moves
     self.update_speed()
 def update(self):
     
     #Tests if it has fallen
     if has_fallen():
         return "fallen"
     
     #Stores the current time for further tests
     self.current_time=time.time()
     
     #Updates the lost ball timer if it has a new ball observation
     if vision.has_new_ball_observation():
         self.lost_ball_timer=self.current_time+2
     
     #Test if it has lost the ball
     elif self.current_time>self.lost_ball_timer:
         return "lost ball"
     
     #Test if it is close enought to the ball
     if distance_to_ball()<=self.distance_to_ball:
         return "done"
 def update(self):
     if has_fallen():
         return "fallen"
     
     if like(robotbody.get_head_position()[0],0):
         return "done"
 def update(self):
     if has_fallen():
         return "fallen"
     if time.time() > self.start_time + self.time:
         return "timeout"
 def update(self):
     if has_fallen():
         return "fallen"
     if imu.get_angle()[2] > self.start_angle + self.angle:
         return "done"