SmellAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 4
c 4
b 0
f 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A cycle_pre_run() 0 4 1
A run() 0 13 3
1
from intelligine.core.exceptions import BestMoleculeHere
2
from intelligine.cst import POINT_SMELL, POINTS_SMELL, MOLECULES_INFOS, MOLECULES_DIRECTION, SMELL_FOOD, SMELL_EGG, \
3
    PHEROMON_DIR_EXPLO
4
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
5
from intelligine.simulation.molecule.Evaporation import Evaporation
6
from intelligine.simulation.molecule.Molecule import Molecule
7
from intelligine.synergy.event.move.MoveAction import MoveAction
8
from intelligine.synergy.event.smell.SmellEvent import SmellEvent
9
from synergine.synergy.event.Action import Action
10
11
12
class SmellAction(Action):
13
14
    _listen = SmellEvent
15
    _depend = [MoveAction]
16
17
    @classmethod
18
    def cycle_pre_run(cls, context, synergy_manager):
19
        evaporation = Evaporation(context, molecules_include_types=[SMELL_FOOD, SMELL_EGG])
20
        evaporation.remove()
21
22
    def run(self, obj, context, synergy_manager):
23
24
        points_distances = self._parameters['points_distances']
25
        smell_type = obj.get_smell()
26
27
        for smell_point in points_distances:
28
            distance = points_distances[smell_point]
29
            molecule = Molecule(MOLECULES_DIRECTION, smell_type, distance)
30
31
            try:
32
                DirectionMolecule.appose(context, smell_point, molecule)
33
            except BestMoleculeHere:
34
                pass
35