Browse Source

clear code

Bastien Sevajol 7 years ago
parent
commit
8411113b30
1 changed files with 11 additions and 10 deletions
  1. 11 10
      intelligine/simulation/object/brain/part/move/MoveBrainPart.py

+ 11 - 10
intelligine/simulation/object/brain/part/move/MoveBrainPart.py View File

@@ -21,17 +21,18 @@ class MoveBrainPart(BrainPart):
21 21
         if blocked_since <= 3:  #TODO: config
22 22
             try:
23 23
                 previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, object_id)
24
-                # TODO: Faut mettre ca en plus propre (proba d'aller tou droit, config, etc)
25
-                if randrange(100) < 75:  # 75% de change d'aller tout droit
26
-                    # Dans le futur: les fourmis vont moins tout droit quand elle se croient et se touche
27
-                    return previous_direction
28
-
29
-                directions_list = directions_slighty[previous_direction]
30
-                # TODO: TMP tant que 1 niveau (z)
31
-                directions_list = [direction for direction in directions_list if 9 < direction < 19]
32
-                return choice(directions_list)
33 24
             except KeyError:
34
-                pass
25
+                # No previous direction
26
+                return cls._get_random_direction(context, object_id)
27
+            # TODO: Faut mettre ca en plus propre (proba d'aller tou droit, config, etc)
28
+            if randrange(100) < 75:  # 75% de change d'aller tout droit
29
+                # Dans le futur: les fourmis vont moins tout droit quand elle se croient et se touche
30
+                return previous_direction
31
+
32
+            directions_list = directions_slighty[previous_direction]
33
+            # TODO: TMP tant que 1 niveau (z)
34
+            directions_list = [direction for direction in directions_list if 9 < direction < 19]
35
+            return choice(directions_list)
35 36
 
36 37
         raise DirectionException()
37 38