|
@@ -1,19 +1,19 @@
|
|
1
|
+from synergine.core.Core import Core
|
1
|
2
|
from intelligine.core.exceptions import CantFindWhereToPut
|
2
|
3
|
from intelligine.cst import MODE_EXPLO, TYPE_RESOURCE_EXPLOITABLE, CARRIED, MODE_NURSE, TYPE_NURSERY, \
|
3
|
|
- MODE_HOME, TYPE_RESOURCE_EATABLE, TYPE, MODE, MODE_GOHOME
|
|
4
|
+ MODE_HOME, TYPE_RESOURCE_EATABLE, MODE_GOHOME
|
4
|
5
|
from intelligine.simulation.object.brain.part.transport.TransportBrainPart import TransportBrainPart
|
5
|
|
-from intelligine.synergy.object.Food import Food
|
6
|
6
|
from synergine_xyz.cst import POSITION, POSITIONS
|
7
|
7
|
|
8
|
8
|
|
9
|
9
|
class AntPutBrainPart(TransportBrainPart):
|
10
|
10
|
|
11
|
|
- # TODO: methode __nit_ pour la classe ?
|
12
|
|
- _mode_matches = {
|
|
11
|
+ _mode_matches = TransportBrainPart._mode_matches.copy()
|
|
12
|
+ _mode_matches.update({
|
13
|
13
|
MODE_NURSE: [TYPE_NURSERY],
|
14
|
14
|
MODE_HOME: [TYPE_RESOURCE_EATABLE],
|
15
|
15
|
MODE_GOHOME: []
|
16
|
|
- }
|
|
16
|
+ })
|
17
|
17
|
|
18
|
18
|
_types_matches = {
|
19
|
19
|
TYPE_RESOURCE_EXPLOITABLE: [TYPE_RESOURCE_EATABLE]
|
|
@@ -54,18 +54,14 @@ class AntPutBrainPart(TransportBrainPart):
|
54
|
54
|
|
55
|
55
|
@staticmethod
|
56
|
56
|
def _is_available_position(context, position):
|
57
|
|
- # TODO: Pour le moment on ne regarde pas si ce sont tous des obj identique
|
|
57
|
+ if not context.position_is_penetrable(position):
|
|
58
|
+ return False
|
|
59
|
+
|
58
|
60
|
count_obj_here = len(context.metas.list.get(POSITIONS, position, allow_empty=True))
|
59
|
|
- # TODO: 5 est hardcode; de plus cette cntrainte (not brain) devrait dependre de l'objet, du contexte ...
|
60
|
|
- if count_obj_here <= 5 and (context.position_is_penetrable(position) or position == (0, 0, 0)): # TODO TEST !!!
|
|
61
|
+ if count_obj_here <= Core.get_configuration_manager().get('ant.put.max_objects_at_same_position', 5):
|
61
|
62
|
return True
|
62
|
63
|
return False
|
63
|
64
|
|
64
|
65
|
def done(self, puted_object):
|
65
|
|
- # TODO: Il faut refact/logique qqpart pour ca !! Genre Brain.done(PUT, ??)
|
66
|
|
- if isinstance(puted_object, Food):
|
67
|
|
- # TODO: Quel mode ? On vient de poser (ps forcement dans la colonie) cls._mode_swicth ?
|
68
|
|
- self._host.get_brain().switch_to_mode(MODE_EXPLO)
|
69
|
|
- # TODO: TEST Depose au -1 pour des raisons de test. Plus tard ce sera des tas comme un autre !
|
70
|
|
- puted_object.set_position((-1, 0, 0))
|
71
|
|
-
|
|
66
|
+ # TODO: lancer le choix d'un nouveau mode dans le brain.
|
|
67
|
+ self._host.get_brain().switch_to_mode(MODE_EXPLO)
|