コード例 #1
0
 def what_landmarks(self):
     # return self.map.landmarks
     return [
         landmark
         for landmark in self.map.landmarks
         if general_tools.calculate_distance(landmark.center, self.position) < vision
     ]
コード例 #2
0
ファイル: ants_grid.py プロジェクト: Zebreu/landmarkfinding
 def translate_path(self):
     position = (self.position[0]*ant_vision, self.position[1]*ant_vision)
     near = None
     shortest = walking_agent.vision
     for landmark in self.map.landmarks:
         distance = general_tools.calculate_distance(position, landmark.center)
         if distance < shortest:
             near = landmark
             shortest = distance
     if near != None:
         step = dict()
         step["action"] = "go"
         step["landmark"] = near
         step["orientation"] = "toward"
         if self.route_counter < 1:
             self.route[self.route_counter] = step
             self.route_counter += 1
         elif not step == self.route[self.route_counter-1]:
             self.route[self.route_counter] = step
             self.route_counter += 1
コード例 #3
0
ファイル: ants_grid.py プロジェクト: Zebreu/landmarkfinding
def fitness(ant):
    position = (ant.position[0]*ant_vision, ant.position[1]*ant_vision)
    distance = general_tools.calculate_distance(position, (90,10))
    return distance
コード例 #4
0
 def is_final_destination(self):
     distance = general_tools.calculate_distance(self.position, self.destination)
     if distance < tolerance:
         return (True, distance)
     else:
         return (False, distance)