|
@@ -6,7 +6,7 @@ from intelligine.synergy.event.move.direction import directions_modifiers, get_p
|
6
|
6
|
from synergine_xyz.cst import POSITION
|
7
|
7
|
from intelligine.core.exceptions import NoMolecule
|
8
|
8
|
from intelligine.cst import MOLECULE_SEARCHING, MOVE_MODE_EXPLO, MOVE_MODE_HOME, MOVE_MODE, MOVE_MODE_GOHOME, \
|
9
|
|
- EXPLORATION_VECTOR, MOLECULES_DIRECTION, SMELL_FOOD, SMELL_EGG, BRAIN_SCHEMA, BRAIN
|
|
9
|
+ EXPLORATION_VECTOR, MOLECULES_DIRECTION
|
10
|
10
|
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
11
|
11
|
|
12
|
12
|
|
|
@@ -103,22 +103,16 @@ class AntMoveBrainPart(MoveBrainPart):
|
103
|
103
|
movement_mode = self._host_brain.get_movement_mode()
|
104
|
104
|
|
105
|
105
|
if movement_mode == MOVE_MODE_GOHOME and self._on_home_smell(self._context, self._host.get_id()):
|
106
|
|
- self._host_brain.switch_to_mode(MOVE_MODE_HOME)
|
107
|
|
- ant_star = self._get_by_pass_brain(self._context, self._host.get_id())
|
108
|
|
- ant_star.erase()
|
109
|
|
- # TODO: on change les molecule recherché (Food => SmellFood, definis dans Take, en fct de ce qui est take)
|
|
106
|
+ self._arrived_at_home()
|
110
|
107
|
|
111
|
108
|
elif movement_mode == MOVE_MODE_HOME and not self._on_home_smell(self._context, self._host.get_id()):
|
112
|
|
- self._host_brain.switch_to_mode(MOVE_MODE_EXPLO)
|
113
|
109
|
self._start_new_exploration()
|
114
|
110
|
|
115
|
111
|
elif movement_mode == MOVE_MODE_EXPLO and self._on_home_smell(self._context, self._host.get_id()):
|
116
|
|
- self._start_new_exploration() # TODO: rename en reinit_explo
|
|
112
|
+ self._init_exploration_vector()
|
117
|
113
|
|
118
|
114
|
# TODO: sitch explo si rien a faire (rien a poser par exemple) et HOME
|
119
|
115
|
|
120
|
|
- # TODO: Poser sur StockedFood
|
121
|
|
-
|
122
|
116
|
@classmethod
|
123
|
117
|
def _on_home_smell(cls, context, object_id):
|
124
|
118
|
current_position = context.metas.value.get(POSITION, object_id)
|
|
@@ -146,7 +140,17 @@ class AntMoveBrainPart(MoveBrainPart):
|
146
|
140
|
self._update_exploration_vector()
|
147
|
141
|
|
148
|
142
|
def _start_new_exploration(self):
|
|
143
|
+ self._reinit_exploration_vector()
|
|
144
|
+ self._host_brain.switch_to_mode(MOVE_MODE_EXPLO)
|
|
145
|
+
|
|
146
|
+ def _init_exploration_vector(self):
|
149
|
147
|
# On vient de rentrer dans le monde exterieur, le vecteur de départ pointe vers la case précedente
|
150
|
148
|
# qui est une case dans la forteresse.
|
151
|
149
|
init_exploration_vector = get_position_with_direction_decal(self.get_host().get_previous_direction())
|
152
|
150
|
self._set_exploration_vector(init_exploration_vector)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+ def _arrived_at_home(self):
|
|
154
|
+ self._host_brain.switch_to_mode(MOVE_MODE_HOME)
|
|
155
|
+ ant_star = self._get_by_pass_brain(self._context, self._host.get_id())
|
|
156
|
+ ant_star.erase()
|