|
@@ -3,7 +3,7 @@ from intelligine.simulation.object.brain.part.move.AntStar.Host import Host
|
3
|
3
|
from intelligine.simulation.object.brain.part.move.MoveBrainPart import MoveBrainPart
|
4
|
4
|
from intelligine.synergy.event.move.direction import directions_modifiers, get_position_with_direction_decal
|
5
|
5
|
from synergine_xyz.cst import POSITION
|
6
|
|
-from intelligine.core.exceptions import NoMolecule, NoTypeInMolecule
|
|
6
|
+from intelligine.core.exceptions import NoMolecule
|
7
|
7
|
from intelligine.cst import MOLECULE_SEARCHING, MOVE_MODE_EXPLO, MOVE_MODE_HOME, MOVE_MODE, MOVE_MODE_GOHOME, \
|
8
|
8
|
EXPLORATION_VECTOR, MOLECULES_DIRECTION, SMELL_FOOD, SMELL_EGG
|
9
|
9
|
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
|
@@ -17,10 +17,9 @@ class AntMoveBrainPart(MoveBrainPart):
|
17
|
17
|
|
18
|
18
|
def _set_exploration_vector(self, new_vector):
|
19
|
19
|
self._exploration_vector = new_vector
|
20
|
|
- # TODO: On devrais donner le context aux brain parts
|
21
|
|
- self._host_brain.get_context().metas.value.set(EXPLORATION_VECTOR,
|
22
|
|
- self._host_brain.get_host().get_id(),
|
23
|
|
- new_vector)
|
|
20
|
+ self._context.metas.value.set(EXPLORATION_VECTOR,
|
|
21
|
+ self._host_brain.get_host().get_id(),
|
|
22
|
+ new_vector)
|
24
|
23
|
|
25
|
24
|
@classmethod
|
26
|
25
|
def get_direction(cls, context, object_id):
|
|
@@ -79,18 +78,17 @@ class AntMoveBrainPart(MoveBrainPart):
|
79
|
78
|
return ByPass(ant_host, home_vector, context, object_id)
|
80
|
79
|
|
81
|
80
|
# TODO: obj pas necessaire, il est dans _host
|
82
|
|
- def done(self, obj, context):
|
83
|
|
- super().done(obj, context)
|
84
|
|
- self._appose_molecule(obj)
|
85
|
|
- self._check_context(obj, context)
|
86
|
|
- self._apply_context(obj, context)
|
|
81
|
+ def done(self):
|
|
82
|
+ super().done()
|
|
83
|
+ self._appose_molecule()
|
|
84
|
+ self._check_context()
|
|
85
|
+ self._apply_context()
|
87
|
86
|
|
88
|
|
- @staticmethod
|
89
|
|
- def _appose_molecule(obj):
|
90
|
|
- if obj.get_movement_molecule_gland().is_enabled():
|
91
|
|
- obj.get_movement_molecule_gland().appose()
|
|
87
|
+ def _appose_molecule(self):
|
|
88
|
+ if self._host.get_movement_molecule_gland().is_enabled():
|
|
89
|
+ self._host.get_movement_molecule_gland().appose()
|
92
|
90
|
|
93
|
|
- def _check_context(self, obj, context):
|
|
91
|
+ def _check_context(self):
|
94
|
92
|
"""
|
95
|
93
|
|
96
|
94
|
If was in exploration, and just found home smell;
|
|
@@ -104,17 +102,17 @@ class AntMoveBrainPart(MoveBrainPart):
|
104
|
102
|
"""
|
105
|
103
|
movement_mode = self._host_brain.get_movement_mode()
|
106
|
104
|
|
107
|
|
- if movement_mode == MOVE_MODE_GOHOME and self._on_home_smell(context, obj.get_id()):
|
|
105
|
+ if movement_mode == MOVE_MODE_GOHOME and self._on_home_smell(self._context, self._host.get_id()):
|
108
|
106
|
self._host_brain.switch_to_mode(MOVE_MODE_HOME)
|
109
|
|
- ant_star = self._get_by_pass_brain(context, obj.get_id())
|
|
107
|
+ ant_star = self._get_by_pass_brain(self._context, self._host.get_id())
|
110
|
108
|
ant_star.erase()
|
111
|
109
|
# TODO: on change les molecule recherché (Food => SmellFood, definis dans Take, en fct de ce qui est take)
|
112
|
110
|
|
113
|
|
- elif movement_mode == MOVE_MODE_HOME and not self._on_home_smell(context, obj.get_id()):
|
|
111
|
+ elif movement_mode == MOVE_MODE_HOME and not self._on_home_smell(self._context, self._host.get_id()):
|
114
|
112
|
self._host_brain.switch_to_mode(MOVE_MODE_EXPLO)
|
115
|
113
|
self._start_new_exploration()
|
116
|
114
|
|
117
|
|
- elif movement_mode == MOVE_MODE_EXPLO and self._on_home_smell(context, obj.get_id()):
|
|
115
|
+ elif movement_mode == MOVE_MODE_EXPLO and self._on_home_smell(self._context, self._host.get_id()):
|
118
|
116
|
self._start_new_exploration() # TODO: rename en reinit_explo
|
119
|
117
|
|
120
|
118
|
# TODO: sitch explo si rien a faire (rien a poser par exemple) et HOME
|
|
@@ -140,7 +138,7 @@ class AntMoveBrainPart(MoveBrainPart):
|
140
|
138
|
self._set_exploration_vector((self._exploration_vector[0] + just_move_vector[1],
|
141
|
139
|
self._exploration_vector[1] + just_move_vector[2]))
|
142
|
140
|
|
143
|
|
- def _apply_context(self, obj, context):
|
|
141
|
+ def _apply_context(self):
|
144
|
142
|
movement_mode = self._host_brain.get_movement_mode()
|
145
|
143
|
if movement_mode == MOVE_MODE_EXPLO or movement_mode == MOVE_MODE_GOHOME:
|
146
|
144
|
self._update_exploration_vector()
|