|
@@ -1,5 +1,6 @@
|
1
|
1
|
from intelligine.simulation.object.brain.Brain import Brain
|
2
|
2
|
from intelligine.cst import MOVE_MODE, MOVE_MODE_EXPLO, MOVE_MODE_GOHOME, PHEROMON_DIR_HOME, PHEROMON_DIR_EXPLO
|
|
3
|
+from intelligine.cst import PHEROMONE_SEARCHING
|
3
|
4
|
|
4
|
5
|
|
5
|
6
|
class AntBrain(Brain):
|
|
@@ -8,12 +9,14 @@ class AntBrain(Brain):
|
8
|
9
|
super().__init__(context, host)
|
9
|
10
|
self._movement_mode = MOVE_MODE_EXPLO
|
10
|
11
|
self._distance_from_objective = 0 # TODO rename: distance_since_objective
|
|
12
|
+ self._pheromone_searching = PHEROMON_DIR_EXPLO
|
11
|
13
|
|
12
|
14
|
def switch_to_mode(self, mode):
|
13
|
15
|
self._movement_mode = mode
|
14
|
16
|
self._update_pheromone_gland(mode)
|
15
|
17
|
self._context.metas.value.set(MOVE_MODE, self._host.get_id(), mode)
|
16
|
18
|
self._distance_from_objective = 0
|
|
19
|
+ self._update_pheromone_searching(mode)
|
17
|
20
|
|
18
|
21
|
def _update_pheromone_gland(self, mode):
|
19
|
22
|
if mode == MOVE_MODE_EXPLO:
|
|
@@ -24,6 +27,16 @@ class AntBrain(Brain):
|
24
|
27
|
raise NotImplementedError()
|
25
|
28
|
self._host.get_movement_pheromone_gland().set_pheromone_type(pheromone_direction_type)
|
26
|
29
|
|
|
30
|
+ def _update_pheromone_searching(self, mode):
|
|
31
|
+ if mode == MOVE_MODE_EXPLO:
|
|
32
|
+ pheromone_searching = PHEROMON_DIR_EXPLO
|
|
33
|
+ elif mode == MOVE_MODE_GOHOME:
|
|
34
|
+ pheromone_searching = PHEROMON_DIR_HOME
|
|
35
|
+ else:
|
|
36
|
+ raise NotImplementedError()
|
|
37
|
+ self._pheromone_searching = pheromone_searching
|
|
38
|
+ self._context.metas.value.set(PHEROMONE_SEARCHING, self._host.get_id(), pheromone_searching)
|
|
39
|
+
|
27
|
40
|
def get_movement_mode(self):
|
28
|
41
|
return self._movement_mode
|
29
|
42
|
|