|
@@ -0,0 +1,57 @@
|
|
1
|
+from antstar.GlueWallAntBrain import GlueWallAntBrain
|
|
2
|
+from intelligine.cst import EXPLORATION_VECTOR, MOVE_BYBASS, MOVE_BYBASS_DISTANCE, MOVE_BYBASS_MEMORY, MOVE_BYBASS_WALL, MOVE_BYBASS_RE_WALKING
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+class ByPass(GlueWallAntBrain):
|
|
6
|
+
|
|
7
|
+ def __init__(self, host, home_vector, context, object_id):
|
|
8
|
+ """
|
|
9
|
+
|
|
10
|
+ Note: We broke Liskov principle here.
|
|
11
|
+
|
|
12
|
+ :param host:
|
|
13
|
+ :param home_vector:
|
|
14
|
+ :param context:
|
|
15
|
+ :param object_id:
|
|
16
|
+ :return:
|
|
17
|
+ """
|
|
18
|
+ super().__init__(host, home_vector)
|
|
19
|
+ self._context = context
|
|
20
|
+ self._object_id = object_id
|
|
21
|
+ self._memory_since_blocked = context.metas.value.get(MOVE_BYBASS_MEMORY, object_id, allow_empty=True,
|
|
22
|
+ empty_value=[])
|
|
23
|
+ self._by_passing = context.metas.value.get(MOVE_BYBASS, object_id, allow_empty=True, empty_value=False)
|
|
24
|
+ self._distance_when_blocked = context.metas.value.get(MOVE_BYBASS_DISTANCE, object_id, allow_empty=True,
|
|
25
|
+ empty_value=None)
|
|
26
|
+ self._current_wall_square_position = context.metas.value.get(MOVE_BYBASS_WALL,
|
|
27
|
+ object_id,
|
|
28
|
+ allow_empty=True,
|
|
29
|
+ empty_value=None)
|
|
30
|
+ self._is_re_walking = context.metas.value.get(MOVE_BYBASS_RE_WALKING,
|
|
31
|
+ object_id,
|
|
32
|
+ allow_empty=True,
|
|
33
|
+ empty_value=False)
|
|
34
|
+
|
|
35
|
+ def _set_home_vector(self, home_vector):
|
|
36
|
+ super()._set_home_vector(home_vector)
|
|
37
|
+ self._context.metas.value.set(EXPLORATION_VECTOR, self._object_id, home_vector)
|
|
38
|
+
|
|
39
|
+ def _set_memory_since_blocked(self, memory_since_blocked):
|
|
40
|
+ super()._set_memory_since_blocked(memory_since_blocked)
|
|
41
|
+ self._context.metas.value.set(MOVE_BYBASS_MEMORY, self._object_id, memory_since_blocked)
|
|
42
|
+
|
|
43
|
+ def _set_by_passing(self, by_passing):
|
|
44
|
+ super()._set_by_passing(by_passing)
|
|
45
|
+ self._context.metas.value.set(MOVE_BYBASS, self._object_id, by_passing)
|
|
46
|
+
|
|
47
|
+ def _set_distance_when_blocked(self, distance):
|
|
48
|
+ super()._set_distance_when_blocked(distance)
|
|
49
|
+ self._context.metas.value.set(MOVE_BYBASS_DISTANCE, self._object_id, distance)
|
|
50
|
+
|
|
51
|
+ def _set_current_wall_square(self, position_of_square):
|
|
52
|
+ super()._set_current_wall_square(position_of_square)
|
|
53
|
+ self._context.metas.value.set(MOVE_BYBASS_WALL, self._object_id, position_of_square)
|
|
54
|
+
|
|
55
|
+ def _set_is_re_walking(self, is_re_walking):
|
|
56
|
+ super()._set_is_re_walking(is_re_walking)
|
|
57
|
+ self._context.metas.value.set(MOVE_BYBASS_RE_WALKING, self._object_id, is_re_walking)
|