Browse Source

clea code of todo

Bastien Sevajol 8 years ago
parent
commit
9c2ae93e67

+ 1 - 3
TODO View File

@@ -1,5 +1,3 @@
1 1
 * Fourmis (map.tmx) pas en mode nurse (-> algo de choix d'activité plus tard)
2
-* Pygame: smell, pheromons: rendre + generique
3
-* Smell: Calcul de la distance max
4 2
 * Ant: MOVE_MODE_HOME && rien à faire (pas de truc à stocker, switch to mode EXPLO)
5
-* Plus de molecule deposer a l'explo !
3
+* Nourriture posé: Comme oeufs, plus de debug. Implique algo pour pas remplir couloirs. Implique ne plus travailler a xplo de nourriture si plus de place ? etc ...

+ 4 - 1
config.py View File

@@ -56,6 +56,9 @@ config = {
56 56
     'ant': {
57 57
         'take': {
58 58
             'cant_put_still': 5
59
+        },
60
+        'put': {
61
+            'max_objects_at_same_position': 5
59 62
         }
60 63
     }
61
-}
64
+}

+ 11 - 15
intelligine/simulation/object/brain/part/transport/AntPutBrainPart.py View File

@@ -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)

+ 5 - 0
intelligine/synergy/event/transport/PutableAction.py View File

@@ -1,4 +1,5 @@
1 1
 from intelligine.synergy.event.move.MoveAction import MoveAction
2
+from intelligine.synergy.object.Food import Food
2 3
 from synergine.synergy.event.Action import Action
3 4
 from intelligine.synergy.event.transport.PutableEvent import PutableEvent
4 5
 from intelligine.cst import CANT_CARRY_STILL, BRAIN_PART_PUT
@@ -22,3 +23,7 @@ class PutableAction(Action):
22 23
         context.metas.value.set(CANT_CARRY_STILL, obj.get_id(), 5)
23 24
 
24 25
         obj.get_brain().get_part(BRAIN_PART_PUT).done(obj_transported)
26
+
27
+        # TODO: DEBUG
28
+        if isinstance(obj_transported, Food):
29
+            obj_transported.set_position((-1, 0, 0))