Ver código fonte

Direction molecules: Now we include reference point, consider it when test if molecules found

Bastien Sevajol 9 anos atrás
pai
commit
183d15a518

+ 4 - 2
intelligine/simulation/molecule/DirectionMolecule.py Ver arquivo

@@ -24,7 +24,8 @@ class DirectionMolecule():
24 24
         around_molecules_points = cls._get_around_molecules(context, point, molecule_type,
25 25
                                                             molecule_filter=around_molecule_filter)
26 26
 
27
-        if not around_molecules_points:
27
+        if not around_molecules_points \
28
+           or (len(around_molecules_points) == 1 and around_molecules_points[0][0] == point):
28 29
             raise NoMolecule()
29 30
 
30 31
         shuffle(around_molecules_points)
@@ -74,7 +75,8 @@ class DirectionMolecule():
74 75
             except NoMolecule:
75 76
                 pass  # Ok, no molecule, continue to sniff around
76 77
 
77
-        if not around_molecules_points:
78
+        if not around_molecules_points \
79
+           or (len(around_molecules_points) == 1 and around_molecules_points[0][0] == reference_point):
78 80
             raise NoMolecule()
79 81
 
80 82
         shuffle(around_molecules_points)