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