|
@@ -26,32 +26,32 @@ class DirectionPheromone():
|
26
|
26
|
|
27
|
27
|
point_intensity = pheromone_info[1]
|
28
|
28
|
point_distance = pheromone_info[0]
|
29
|
|
- arround_points = context.get_arround_points_of(point)
|
|
29
|
+ around_points = context.get_around_points_of(point)
|
30
|
30
|
|
31
|
|
- arround_pheromones_points = []
|
32
|
|
- for arround_point in arround_points:
|
33
|
|
- arround_pheromone_info = context.pheromones().get_info(arround_point,
|
|
31
|
+ around_pheromones_points = []
|
|
32
|
+ for around_point in around_points:
|
|
33
|
+ around_pheromone_info = context.pheromones().get_info(around_point,
|
34
|
34
|
[PHEROMON_DIRECTION, pheromone_type],
|
35
|
35
|
allow_empty=True,
|
36
|
36
|
empty_value={})
|
37
|
|
- if arround_pheromone_info and arround_pheromone_info[0] < point_distance:
|
38
|
|
- arround_pheromones_points.append((arround_point, arround_pheromone_info))
|
|
37
|
+ if around_pheromone_info and around_pheromone_info[0] < point_distance:
|
|
38
|
+ around_pheromones_points.append((around_point, around_pheromone_info))
|
39
|
39
|
|
40
|
|
- if not arround_pheromones_points:
|
|
40
|
+ if not around_pheromones_points:
|
41
|
41
|
raise NoPheromone()
|
42
|
42
|
|
43
|
|
- shuffle(arround_pheromones_points)
|
44
|
|
- arround_pheromones_sorted = sorted(arround_pheromones_points, key=lambda x: x[1][1], reverse=True)
|
45
|
|
- max_intensity = arround_pheromones_sorted[0][1][1]
|
|
43
|
+ shuffle(around_pheromones_points)
|
|
44
|
+ around_pheromones_sorted = sorted(around_pheromones_points, key=lambda x: x[1][1], reverse=True)
|
|
45
|
+ max_intensity = around_pheromones_sorted[0][1][1]
|
46
|
46
|
|
47
|
|
- arround_pheromones_max = []
|
48
|
|
- for arround_pheromone_sorted in arround_pheromones_sorted:
|
49
|
|
- if arround_pheromone_sorted[1][1] == max_intensity:
|
50
|
|
- arround_pheromones_max.append(arround_pheromone_sorted)
|
|
47
|
+ around_pheromones_max = []
|
|
48
|
+ for around_pheromone_sorted in around_pheromones_sorted:
|
|
49
|
+ if around_pheromone_sorted[1][1] == max_intensity:
|
|
50
|
+ around_pheromones_max.append(around_pheromone_sorted)
|
51
|
51
|
|
52
|
|
- arround_pheromones_sorted_by_distance = sorted(arround_pheromones_max, key=lambda x: x[1][0], reverse=False)
|
|
52
|
+ around_pheromones_sorted_by_distance = sorted(around_pheromones_max, key=lambda x: x[1][0], reverse=False)
|
53
|
53
|
|
54
|
|
- go_to_point = arround_pheromones_sorted_by_distance[0][0]
|
|
54
|
+ go_to_point = around_pheromones_sorted_by_distance[0][0]
|
55
|
55
|
|
56
|
56
|
direction_degrees = get_degree_from_north(point, go_to_point)
|
57
|
57
|
direction = get_direction_for_degrees(direction_degrees)
|
|
@@ -74,21 +74,21 @@ class DirectionPheromone():
|
74
|
74
|
|
75
|
75
|
@staticmethod
|
76
|
76
|
def get_best_pheromone_direction_in(context, reference_point, points, pheromone_type):
|
77
|
|
- arround_pheromones_points = []
|
78
|
|
- for arround_point in points:
|
79
|
|
- arround_pheromone_info = context.pheromones().get_info(arround_point,
|
|
77
|
+ around_pheromones_points = []
|
|
78
|
+ for around_point in points:
|
|
79
|
+ around_pheromone_info = context.pheromones().get_info(around_point,
|
80
|
80
|
[PHEROMON_DIRECTION, pheromone_type],
|
81
|
81
|
allow_empty=True,
|
82
|
82
|
empty_value={})
|
83
|
|
- if arround_pheromone_info:
|
84
|
|
- arround_pheromones_points.append((arround_point, arround_pheromone_info))
|
|
83
|
+ if around_pheromone_info:
|
|
84
|
+ around_pheromones_points.append((around_point, around_pheromone_info))
|
85
|
85
|
|
86
|
|
- if not arround_pheromones_points:
|
|
86
|
+ if not around_pheromones_points:
|
87
|
87
|
raise NoPheromone()
|
88
|
88
|
|
89
|
|
- shuffle(arround_pheromones_points)
|
90
|
|
- arround_pheromones_sorted = sorted(arround_pheromones_points, key=lambda x: x[1][1], reverse=True)
|
91
|
|
- go_to_point = arround_pheromones_sorted[0][0]
|
|
89
|
+ shuffle(around_pheromones_points)
|
|
90
|
+ around_pheromones_sorted = sorted(around_pheromones_points, key=lambda x: x[1][1], reverse=True)
|
|
91
|
+ go_to_point = around_pheromones_sorted[0][0]
|
92
|
92
|
|
93
|
93
|
direction_degrees = get_degree_from_north(reference_point, go_to_point)
|
94
|
94
|
direction = get_direction_for_degrees(direction_degrees)
|