Ver código fonte

Fix home_fail_count

Bastien Sevajol 9 anos atrás
pai
commit
b5069e4b81

+ 4 - 2
intelligine/synergy/event/transport/PutableEvent.py Ver arquivo

@@ -1,5 +1,6 @@
1 1
 from intelligine.core.exceptions import NearNothingFound, CantFindWhereToPut
2 2
 from intelligine.shorcut.brain import get_brain_part
3
+from intelligine.simulation.object.brain.part.move.AntMoveBrainPart import AntMoveBrainPart
3 4
 from intelligine.synergy.event.src.NearEvent import NearEvent
4 5
 from synergine.core.exceptions import NotConcernedEvent
5 6
 from intelligine.cst import CANT_PUT_STILL, COL_TRANSPORTER_CARRYING, TRANSPORTABLE, BRAIN_SCHEMA, BRAIN_PART_PUT
@@ -31,6 +32,7 @@ class PutableEvent(NearEvent):
31 32
         brain_part = get_brain_part(context, object_id, BRAIN_PART_PUT)
32 33
         parameters[self.PARAM_PUT] = []
33 34
         parameters[self.PARAM_PUT_TO] = []
35
+        parameters[self.PARAM_HOME_FAIL] = False
34 36
 
35 37
         for object_near_id in parameters[self._near_name]:
36 38
             if brain_part.can_put(context, object_id, object_near_id):
@@ -38,13 +40,13 @@ class PutableEvent(NearEvent):
38 40
                     put_position = brain_part.get_put_position(context, object_id, object_near_id)
39 41
                     parameters[self.PARAM_PUT].append(object_near_id)
40 42
                     parameters[self.PARAM_PUT_TO].append(put_position)
41
-                    parameters[self.PARAM_HOME_FAIL] = False
42 43
                     return parameters  # Si a terme on veut tous les calculer a l'avance, ne pas retourner ici
43 44
                 except CantFindWhereToPut:
44 45
                     pass  # On continu la booucle
45 46
 
46 47
         # Si a terme on veut tous les calculer a l'avance, raise que si rien trouve
47
-        parameters[self.PARAM_HOME_FAIL] = True
48
+        if AntMoveBrainPart._on_home_smell(context, object_id):  # TODO: Reanger code (._ acces protege)
49
+            parameters[self.PARAM_HOME_FAIL] = True
48 50
         return parameters
49 51
 
50 52
     @staticmethod

+ 1 - 1
intelligine/tests/simulation/bypass/TestByPass.py Ver arquivo

@@ -6,7 +6,7 @@ from intelligine.tests.src.simulation.SimpleTestWorld1Simulation import SimpleTe
6 6
 class TestByPass(SimpleTestWorld1Simulation):
7 7
 
8 8
     _ant_move_history = []
9
-    _assert_ant_move_history = [(0, 21, 20), (0, 21, 19), (0, 21, 18), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 14), (0, 22, 13), (0, 23, 12), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 23, 11), (0, 22, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 22, 12), (0, 23, 13), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 23, 15), (0, 22, 16), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 13), (0, 21, 12), (0, 21, 11), (0, 21, 10), (0, 21, 9), (0, 21, 8), (0, 21, 7), (0, 21, 6), (0, 21, 5), (0, 21, 4), (0, 21, 3), (0, 22, 2), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 22, 1), (0, 21, 1), (0, 20, 1), (0, 19, 1), (0, 18, 1), (0, 17, 1), (0, 16, 1), (0, 15, 1), (0, 14, 1), (0, 13, 1), (0, 12, 1), (0, 11, 1), (0, 10, 1), (0, 9, 1), (0, 8, 2), (0, 7, 2), (0, 6, 3), (0, 5, 4), (0, 4, 5), (0, 3, 5), (0, 2, 5), (0, 1, 5), (0, 2, 6), (0, 3, 7), (0, 4, 8), (0, 5, 9), (0, 6, 10), (0, 7, 11), (0, 8, 12), (0, 9, 13), (0, 10, 14), (0, 11, 15), (0, 12, 16), (0, 13, 17), (0, 14, 17), (0, 15, 17), (0, 16, 17), (0, 17, 17), (0, 18, 17), (0, 19, 17), (0, 19, 16), (0, 19, 15), (0, 19, 14), (0, 19, 13), (0, 19, 12), (0, 19, 11), (0, 19, 10), (0, 19, 9), (0, 18, 9), (0, 17, 9), (0, 16, 9), (0, 15, 9), (0, 14, 9), (0, 13, 9), (0, 13, 10), (0, 13, 11), (0, 13, 12), (0, 13, 13), (0, 14, 13), (0, 15, 13), (0, 16, 13), (0, 17, 13), (0, 17, 14), (0, 16, 15), (0, 15, 15), (0, 14, 15), (0, 13, 15), (0, 12, 15), (0, 11, 14), (0, 11, 13), (0, 11, 12), (0, 11, 11), (0, 11, 10), (0, 11, 9), (0, 11, 8), (0, 11, 7), (0, 12, 7), (0, 13, 7), (0, 14, 7), (0, 15, 7), (0, 16, 7), (0, 17, 7), (0, 18, 7), (0, 19, 7), (0, 20, 7), (0, 21, 7), (0, 21, 8), (0, 21, 9), (0, 21, 10), (0, 21, 11), (0, 21, 12), (0, 21, 13), (0, 21, 14), (0, 21, 15), (0, 21, 16), (0, 21, 17), (0, 21, 18), (0, 21, 19), (0, 21, 20), (0, 21, 21), (0, 20, 22), (0, 19, 22), (0, 18, 23), (0, 19, 24), (0, 18, 23), (0, 19, 22), (0, 20, 22), (0, 21, 21), (0, 21, 20), (0, 21, 19), (0, 21, 18), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 13), (0, 21, 12), (0, 21, 11), (0, 21, 10), (0, 21, 9), (0, 21, 8), (0, 20, 7), (0, 19, 7), (0, 18, 7), (0, 17, 7), (0, 16, 7), (0, 15, 7), (0, 14, 7), (0, 13, 7), (0, 12, 7), (0, 11, 8), (0, 11, 9), (0, 11, 10), (0, 11, 11), (0, 11, 12), (0, 11, 13), (0, 10, 14), (0, 9, 13), (0, 8, 12), (0, 7, 11), (0, 6, 10), (0, 5, 9), (0, 4, 8), (0, 3, 7), (0, 2, 6), (0, 1, 5), (0, 2, 6), (0, 3, 7), (0, 4, 8), (0, 5, 9), (0, 6, 10), (0, 7, 11), (0, 8, 12), (0, 9, 13), (0, 10, 14), (0, 11, 15), (0, 12, 16), (0, 13, 17), (0, 14, 17), (0, 15, 17), (0, 16, 17), (0, 17, 17), (0, 18, 17), (0, 19, 17), (0, 19, 16), (0, 19, 15), (0, 19, 14), (0, 19, 13), (0, 19, 12), (0, 19, 11), (0, 19, 10), (0, 19, 9), (0, 18, 9), (0, 17, 9), (0, 16, 9), (0, 15, 9), (0, 14, 9), (0, 13, 9), (0, 13, 10), (0, 13, 11), (0, 13, 12), (0, 13, 13), (0, 14, 13), (0, 15, 13), (0, 16, 13), (0, 17, 13), (0, 17, 14), (0, 16, 15), (0, 15, 15), (0, 14, 15), (0, 13, 15), (0, 12, 15), (0, 11, 14), (0, 11, 13), (0, 11, 12), (0, 11, 11), (0, 11, 10), (0, 11, 9), (0, 11, 8), (0, 11, 7), (0, 12, 7), (0, 13, 7), (0, 14, 7), (0, 15, 7), (0, 16, 7), (0, 17, 7), (0, 18, 7), (0, 19, 7), (0, 20, 7), (0, 21, 7), (0, 21, 8), (0, 21, 9), (0, 21, 10), (0, 21, 11), (0, 21, 12), (0, 21, 13), (0, 21, 14), (0, 21, 15), (0, 21, 16), (0, 21, 17), (0, 21, 18), (0, 21, 19), (0, 21, 20), (0, 21, 21), (0, 20, 22), (0, 19, 22), (0, 18, 23), (0, 18, 24), (0, 18, 23), (0, 19, 22), (0, 20, 22), (0, 21, 21), (0, 21, 20), (0, 21, 19), (0, 21, 18), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 13), (0, 21, 12), (0, 21, 11), (0, 21, 10), (0, 21, 9), (0, 21, 8)]
9
+    _assert_ant_move_history = [(0, 21, 20), (0, 21, 19), (0, 21, 18), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 14), (0, 22, 13), (0, 23, 12), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 24, 11), (0, 23, 11), (0, 22, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 21, 11), (0, 22, 12), (0, 23, 13), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 24, 14), (0, 23, 15), (0, 22, 16), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 13), (0, 21, 12), (0, 21, 11), (0, 21, 10), (0, 21, 9), (0, 21, 8), (0, 21, 7), (0, 21, 6), (0, 21, 5), (0, 21, 4), (0, 21, 3), (0, 22, 2), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 23, 1), (0, 22, 1), (0, 21, 1), (0, 20, 1), (0, 19, 1), (0, 18, 1), (0, 17, 1), (0, 16, 1), (0, 15, 1), (0, 14, 1), (0, 13, 1), (0, 12, 1), (0, 11, 1), (0, 10, 1), (0, 9, 1), (0, 8, 2), (0, 7, 2), (0, 6, 3), (0, 5, 4), (0, 4, 5), (0, 3, 5), (0, 2, 5), (0, 1, 5), (0, 2, 6), (0, 3, 7), (0, 4, 8), (0, 5, 9), (0, 6, 10), (0, 7, 11), (0, 8, 12), (0, 9, 13), (0, 10, 14), (0, 11, 15), (0, 12, 16), (0, 13, 17), (0, 14, 17), (0, 15, 17), (0, 16, 17), (0, 17, 17), (0, 18, 17), (0, 19, 17), (0, 19, 16), (0, 19, 15), (0, 19, 14), (0, 19, 13), (0, 19, 12), (0, 19, 11), (0, 19, 10), (0, 19, 9), (0, 18, 9), (0, 17, 9), (0, 16, 9), (0, 15, 9), (0, 14, 9), (0, 13, 9), (0, 13, 10), (0, 13, 11), (0, 13, 12), (0, 13, 13), (0, 14, 13), (0, 15, 13), (0, 16, 13), (0, 17, 13), (0, 17, 14), (0, 16, 15), (0, 15, 15), (0, 14, 15), (0, 13, 15), (0, 12, 15), (0, 11, 14), (0, 11, 13), (0, 11, 12), (0, 11, 11), (0, 11, 10), (0, 11, 9), (0, 11, 8), (0, 11, 7), (0, 12, 7), (0, 13, 7), (0, 14, 7), (0, 15, 7), (0, 16, 7), (0, 17, 7), (0, 18, 7), (0, 19, 7), (0, 20, 7), (0, 21, 7), (0, 21, 8), (0, 21, 9), (0, 21, 10), (0, 21, 11), (0, 21, 12), (0, 21, 13), (0, 21, 14), (0, 21, 15), (0, 21, 16), (0, 21, 17), (0, 21, 18), (0, 21, 19), (0, 21, 20), (0, 21, 21), (0, 20, 22), (0, 19, 22), (0, 18, 23), (0, 18, 24), (0, 18, 23), (0, 19, 22), (0, 20, 22), (0, 21, 21), (0, 21, 20), (0, 21, 19), (0, 21, 18), (0, 21, 17), (0, 21, 16), (0, 21, 15), (0, 21, 14), (0, 21, 13), (0, 21, 12), (0, 21, 11), (0, 21, 10), (0, 21, 9), (0, 21, 8), (0, 20, 7), (0, 19, 7), (0, 18, 7), (0, 17, 7), (0, 16, 7), (0, 15, 7), (0, 14, 7), (0, 13, 7), (0, 12, 7), (0, 11, 8), (0, 11, 9), (0, 11, 10), (0, 11, 11), (0, 11, 12), (0, 11, 13), (0, 10, 14), (0, 9, 13), (0, 8, 12), (0, 7, 11), (0, 6, 10), (0, 5, 9), (0, 4, 8), (0, 3, 7), (0, 2, 6), (0, 2, 5), (0, 1, 4), (0, 2, 5), (0, 3, 6), (0, 4, 7), (0, 5, 8), (0, 6, 9), (0, 7, 10), (0, 8, 11), (0, 9, 12), (0, 10, 13), (0, 11, 14), (0, 12, 15), (0, 13, 16), (0, 14, 17), (0, 15, 17), (0, 16, 17), (0, 17, 17), (0, 18, 17), (0, 19, 17), (0, 19, 16), (0, 19, 15), (0, 19, 14), (0, 19, 13), (0, 19, 12), (0, 19, 11), (0, 19, 10), (0, 19, 9), (0, 18, 9), (0, 17, 9), (0, 16, 9), (0, 15, 9), (0, 14, 9), (0, 13, 9), (0, 13, 10), (0, 13, 11), (0, 13, 12), (0, 13, 13), (0, 14, 13), (0, 15, 13), (0, 16, 13), (0, 17, 13), (0, 17, 14), (0, 16, 15), (0, 15, 15), (0, 14, 15), (0, 13, 15), (0, 14, 15), (0, 15, 15), (0, 16, 15), (0, 17, 15), (0, 17, 14), (0, 16, 13), (0, 15, 13), (0, 14, 13), (0, 13, 13), (0, 13, 12), (0, 13, 11), (0, 13, 10), (0, 13, 9), (0, 14, 9), (0, 15, 9), (0, 16, 9), (0, 17, 9), (0, 18, 9), (0, 19, 9), (0, 19, 10), (0, 19, 11), (0, 19, 12), (0, 19, 13), (0, 19, 14), (0, 19, 15), (0, 19, 16), (0, 19, 17), (0, 18, 17), (0, 17, 17), (0, 16, 17), (0, 15, 17), (0, 14, 17), (0, 13, 17), (0, 12, 17), (0, 11, 17), (0, 10, 17), (0, 9, 17), (0, 8, 17), (0, 7, 17), (0, 6, 17), (0, 5, 17), (0, 4, 17), (0, 3, 17), (0, 2, 17), (0, 1, 17), (0, 1, 16), (0, 1, 15), (0, 1, 14), (0, 1, 13), (0, 1, 12), (0, 1, 11), (0, 1, 10), (0, 1, 9)]
10 10
 
11 11
     def setUp(self):
12 12
         super().setUp()