# Path: intelligine/cst.py
# MOLECULES = IncrementedNamedInt.get('intelligine.molecules')
# 
# MOLECULES_DIRECTION = IncrementedNamedInt.get('intelligine.mol.direction')
# 
# Path: intelligine/synergy/stigmergy/MoleculesManager.py
# class MoleculesManager():
# 
#     def __init__(self, context):
#         self._context = context
# 
#     def get_flavour(self, position):
#         point_molecules = self._context.metas.value.get(MOLECULES_INFOS,
#                                                         position,
#                                                         allow_empty=True,
#                                                         empty_value={})
#         return MoleculeFlavour.new_from_raw_data(point_molecules)
# 
#     def set_flavour(self, position, flavour):
#         self._context.metas.value.set(MOLECULES_INFOS, position, flavour.get_raw_data())
# 
#     def get_molecule(self, position, category, type, allow_empty=False):
#         flavour = self.get_flavour(position)
#         try:
#             return flavour.get_molecule(category, type)
#         except NoMolecule:
#             if allow_empty:
#                 return Molecule()
#             raise
# 
#     def increment_with_molecule(self, position, apposed_molecule, cycle_age):
#         flavour = self.get_flavour(position)
#         try:
#             position_molecule = flavour.get_molecule(apposed_molecule.get_category(), apposed_molecule.get_type())
#         except NoMolecule:
#             position_molecule = Molecule(apposed_molecule.get_category(),
#                                          apposed_molecule.get_type(),
#                                          distance=apposed_molecule.get_distance(),
#                                          cycle_age=cycle_age)
# 
#         position_molecule.increment_intensity(apposed_molecule.get_intensity())
#         position_molecule.set_cycle_age(cycle_age)
# 
#         if apposed_molecule.get_distance() < position_molecule.get_distance():
#             position_molecule.set_distance(apposed_molecule.get_distance())
# 
#         flavour.set_molecule(position_molecule)
#         self.set_flavour(position, flavour)
# 
#         if apposed_molecule.get_distance() > position_molecule.get_distance():
#             raise BestMoleculeHere(position_molecule.get_distance())


from intelligine.cst import MOLECULES, MOLECULES_DIRECTION
from intelligine.synergy.stigmergy.MoleculesManager import MoleculesManager


class Evaporation:

    def __init__(self, context,
                 intensity_decrement=1,
                 molecule_minimum_age=0,
                 molecules_exclude_types=None,
                 molecules_include_types=None):
        self._context = context
        self._intensity_decrement = intensity_decrement
        self._molecules_manager = MoleculesManager(context)
        self._molecule_minimum_age = molecule_minimum_age
        self._molecules_exclude_types = molecules_exclude_types
        self._molecules_include_types = molecules_include_types

    def evaporate(self):
        for position, flavour in self._get_flavours():
            self._decrease_flavour(flavour)
            self._molecules_manager.set_flavour(position, flavour)

    def remove(self):
        for position, flavour in self._get_flavours():
            self._remove_molecule(flavour)
            self._molecules_manager.set_flavour(position, flavour)

    def _get_flavours(self):

# Path: intelligine/cst.py
# MOLECULES = IncrementedNamedInt.get('intelligine.molecules')
# 
# MOLECULES_DIRECTION = IncrementedNamedInt.get('intelligine.mol.direction')
# 
# Path: intelligine/synergy/stigmergy/MoleculesManager.py
# class MoleculesManager():
# 
#     def __init__(self, context):
#         self._context = context
# 
#     def get_flavour(self, position):
#         point_molecules = self._context.metas.value.get(MOLECULES_INFOS,
#                                                         position,
#                                                         allow_empty=True,
#                                                         empty_value={})
#         return MoleculeFlavour.new_from_raw_data(point_molecules)
# 
#     def set_flavour(self, position, flavour):
#         self._context.metas.value.set(MOLECULES_INFOS, position, flavour.get_raw_data())
# 
#     def get_molecule(self, position, category, type, allow_empty=False):
#         flavour = self.get_flavour(position)
#         try:
#             return flavour.get_molecule(category, type)
#         except NoMolecule:
#             if allow_empty:
#                 return Molecule()
#             raise
# 
#     def increment_with_molecule(self, position, apposed_molecule, cycle_age):
#         flavour = self.get_flavour(position)
#         try:
#             position_molecule = flavour.get_molecule(apposed_molecule.get_category(), apposed_molecule.get_type())
#         except NoMolecule:
#             position_molecule = Molecule(apposed_molecule.get_category(),
#                                          apposed_molecule.get_type(),
#                                          distance=apposed_molecule.get_distance(),
#                                          cycle_age=cycle_age)
# 
#         position_molecule.increment_intensity(apposed_molecule.get_intensity())
#         position_molecule.set_cycle_age(cycle_age)
# 
#         if apposed_molecule.get_distance() < position_molecule.get_distance():
#             position_molecule.set_distance(apposed_molecule.get_distance())
# 
#         flavour.set_molecule(position_molecule)
#         self.set_flavour(position, flavour)
# 
#         if apposed_molecule.get_distance() > position_molecule.get_distance():
#             raise BestMoleculeHere(position_molecule.get_distance())


# Path: intelligine/simulation/molecule/Evaporation.py
from intelligine.cst import MOLECULES, MOLECULES_DIRECTION
from intelligine.synergy.stigmergy.MoleculesManager import MoleculesManager



class Evaporation:

    def __init__(self, context,
                 intensity_decrement=1,
                 molecule_minimum_age=0,
                 molecules_exclude_types=None,
                 molecules_include_types=None):
        self._context = context
        self._intensity_decrement = intensity_decrement
        self._molecules_manager = MoleculesManager(context)
        self._molecule_minimum_age = molecule_minimum_age
        self._molecules_exclude_types = molecules_exclude_types
        self._molecules_include_types = molecules_include_types

    def evaporate(self):
        for position, flavour in self._get_flavours():
            self._decrease_flavour(flavour)
            self._molecules_manager.set_flavour(position, flavour)

    def remove(self):
        for position, flavour in self._get_flavours():
            self._remove_molecule(flavour)
            self._molecules_manager.set_flavour(position, flavour)

    def _get_flavours(self):

        molecules_points = self._context.metas.list.get(MOLECULES, MOLECULES, allow_empty=True)