|
@@ -5,6 +5,7 @@ from xyzworld.cst import POSITION
|
5
|
5
|
from intelligine.cst import PREVIOUS_DIRECTION, BLOCKED_SINCE, MOVE_MODE, MOVE_MODE_EXPLO
|
6
|
6
|
from intelligine.cst import COL_TRANSPORTER_NOT_CARRYING, COL_TRANSPORTER_CARRYING
|
7
|
7
|
from intelligine.synergy.event.move.direction import directions_same_level, directions_modifiers, directions_slighty
|
|
8
|
+from intelligine.synergy.event.move.direction import get_position_with_direction_decal
|
8
|
9
|
from intelligine.core.exceptions import NoPheromone, BestPheromoneHere
|
9
|
10
|
from intelligine.simulation.pheromone.DirectionPheromone import DirectionPheromone
|
10
|
11
|
|
|
@@ -26,7 +27,7 @@ class MoveAction(Action):
|
26
|
27
|
except NoPheromone:
|
27
|
28
|
direction = self._get_random_direction(context)
|
28
|
29
|
|
29
|
|
- move_to_point = self._get_point_for_direction(object_point, direction)
|
|
30
|
+ move_to_point = get_position_with_direction_decal(direction, object_point)
|
30
|
31
|
if self._direction_point_is_possible(context, move_to_point):
|
31
|
32
|
self._move_to_point = move_to_point
|
32
|
33
|
self._move_to_direction = direction
|
|
@@ -35,13 +36,15 @@ class MoveAction(Action):
|
35
|
36
|
pass
|
36
|
37
|
|
37
|
38
|
def _get_direction_with_pheromones(self, context, object_point):
|
38
|
|
-
|
39
|
39
|
object_movement_mode = context.metas.value.get(MOVE_MODE, self._object_id)
|
40
|
40
|
pheromone_type = DirectionPheromone.get_pheromone_type_for_move_mode(object_movement_mode)
|
41
|
41
|
try:
|
42
|
42
|
direction = self._get_pheromone_direction_for_point(context, object_point, pheromone_type)
|
43
|
43
|
except NoPheromone:
|
44
|
|
- direction = self._get_direction_of_pheromone(context, object_point, pheromone_type)
|
|
44
|
+ try:
|
|
45
|
+ direction = self._get_direction_of_pheromone(context, object_point, pheromone_type)
|
|
46
|
+ except NoPheromone:
|
|
47
|
+ raise
|
45
|
48
|
return direction
|
46
|
49
|
|
47
|
50
|
@staticmethod
|
|
@@ -50,10 +53,8 @@ class MoveAction(Action):
|
50
|
53
|
|
51
|
54
|
@staticmethod
|
52
|
55
|
def _get_direction_of_pheromone(context, point, pheromone_type):
|
53
|
|
- search_pheromone_distance = 1
|
54
|
|
- search_pheromone_in_points = context.get_arround_points_of(point, distance=search_pheromone_distance)
|
|
56
|
+ search_pheromone_in_points = context.get_arround_points_of(point, distance=1)
|
55
|
57
|
try:
|
56
|
|
-
|
57
|
58
|
best_pheromone_direction = DirectionPheromone.get_best_pheromone_direction_in(context,
|
58
|
59
|
point,
|
59
|
60
|
search_pheromone_in_points,
|
|
@@ -62,13 +63,6 @@ class MoveAction(Action):
|
62
|
63
|
except NoPheromone as err:
|
63
|
64
|
raise err
|
64
|
65
|
|
65
|
|
-
|
66
|
|
-
|
67
|
|
-
|
68
|
|
-
|
69
|
|
-
|
70
|
|
-
|
71
|
|
-
|
72
|
66
|
def _get_random_direction(self, context):
|
73
|
67
|
try:
|
74
|
68
|
blocked_since = context.metas.value.get(BLOCKED_SINCE, self._object_id)
|
|
@@ -96,21 +90,12 @@ class MoveAction(Action):
|
96
|
90
|
return direction_name
|
97
|
91
|
|
98
|
92
|
@staticmethod
|
99
|
|
- def _get_point_for_direction(reference_point, direction):
|
100
|
|
-
|
101
|
|
- z, x, y = reference_point
|
102
|
|
- directions_modifier = directions_modifiers[direction]
|
103
|
|
- return z + directions_modifier[0], x + directions_modifier[1], y + directions_modifier[2]
|
104
|
|
-
|
105
|
|
- @staticmethod
|
106
|
93
|
def _direction_point_is_possible(context, direction_point):
|
107
|
94
|
return context.position_is_penetrable(direction_point)
|
108
|
95
|
|
109
|
96
|
def run(self, obj, context, synergy_manager):
|
110
|
97
|
if self._move_to_point is not None and self._move_to_direction != 14:
|
111
|
98
|
obj.set_position(self._move_to_point)
|
112
|
|
-
|
113
|
|
-
|
114
|
99
|
context.metas.value.set(PREVIOUS_DIRECTION, self._object_id, self._move_to_direction)
|
115
|
100
|
context.metas.value.set(BLOCKED_SINCE, self._object_id, 0)
|
116
|
101
|
self._appose_pheromone(obj, context)
|
|
@@ -122,18 +107,8 @@ class MoveAction(Action):
|
122
|
107
|
obj.put_carry(obj_transported, (-1, 0, 0))
|
123
|
108
|
obj.get_brain().switch_to_mode(MOVE_MODE_EXPLO)
|
124
|
109
|
context.metas.collections.add_remove(obj.get_id(),
|
125
|
|
- COL_TRANSPORTER_NOT_CARRYING, COL_TRANSPORTER_CARRYING)
|
126
|
|
-
|
127
|
|
-
|
128
|
|
-
|
129
|
|
-
|
130
|
|
-
|
131
|
|
-
|
132
|
|
-
|
133
|
|
-
|
134
|
|
-
|
135
|
|
-
|
136
|
|
-
|
|
110
|
+ COL_TRANSPORTER_NOT_CARRYING,
|
|
111
|
+ COL_TRANSPORTER_CARRYING)
|
137
|
112
|
else:
|
138
|
113
|
try:
|
139
|
114
|
blocked_since = context.metas.value.get(BLOCKED_SINCE, self._object_id)
|
|
@@ -141,61 +116,8 @@ class MoveAction(Action):
|
141
|
116
|
blocked_since = 0
|
142
|
117
|
context.metas.value.set(BLOCKED_SINCE, self._object_id, blocked_since+1)
|
143
|
118
|
|
144
|
|
-
|
145
|
|
-
|
146
|
|
-
|
147
|
|
-
|
148
|
|
-
|
149
|
|
-
|
150
|
|
-
|
151
|
|
-
|
152
|
|
-
|
153
|
|
-
|
154
|
|
-
|
155
|
|
-
|
156
|
|
-
|
157
|
|
-
|
158
|
|
-
|
159
|
|
-
|
160
|
|
-
|
161
|
|
-
|
162
|
|
-
|
163
|
|
-
|
164
|
|
-
|
165
|
|
-
|
166
|
|
-
|
167
|
|
-
|
168
|
|
-
|
169
|
|
-
|
170
|
|
-
|
171
|
|
-
|
172
|
|
-
|
173
|
|
-
|
174
|
|
-
|
175
|
|
-
|
176
|
|
-
|
177
|
|
-
|
178
|
|
-
|
179
|
|
-
|
180
|
|
-
|
181
|
|
-
|
182
|
|
-
|
183
|
|
-
|
184
|
|
-
|
185
|
|
-
|
186
|
|
-
|
187
|
|
-
|
188
|
|
-
|
189
|
|
-
|
190
|
|
-
|
191
|
|
-
|
192
|
|
-
|
193
|
|
-
|
194
|
|
-
|
195
|
|
-
|
196
|
|
-
|
197
|
|
-
|
198
|
|
- def _appose_pheromone(self, obj, context):
|
|
119
|
+ @staticmethod
|
|
120
|
+ def _appose_pheromone(obj, context):
|
199
|
121
|
|
200
|
122
|
obj.get_brain().host_moved()
|
201
|
123
|
try:
|