Simulation.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from intelligine.simulation.molecule.Evaporation import Evaporation
  2. from synergine.core.Core import Core
  3. from synergine.synergy.Simulation import Simulation as BaseSimulation
  4. from synergine_xyz.cst import POSITIONS
  5. class Simulation(BaseSimulation):
  6. _smells = []
  7. @classmethod
  8. def add_smell(cls, smell):
  9. if smell not in cls._smells:
  10. cls._smells.append(smell)
  11. @classmethod
  12. def get_smells(cls):
  13. return cls._smells
  14. def end_cycle(self, context):
  15. clean_each_cycle = Core.get_configuration_manager().get('engine.clean_each_cycle', 100)
  16. evaporate_each_cycle = Core.get_configuration_manager().get('stigmergy.molecule.evaporate_each_cycle', 100)
  17. if context.get_cycle() % clean_each_cycle is 0:
  18. context.metas.list.clean(POSITIONS)
  19. if context.get_cycle() % evaporate_each_cycle is 0:
  20. self._evaporate(context)
  21. def _evaporate(self, context):
  22. evaporation_increment = Core.get_configuration_manager().get('stigmergy.molecule.evaporate_decrement', 5)
  23. evaporation_min_age = Core.get_configuration_manager().get('stigmergy.molecule.evaporate_min_age', 100)
  24. evaporation = Evaporation(context,
  25. evaporation_increment,
  26. molecules_exclude_types=self.get_smells(),
  27. molecule_minimum_age=evaporation_min_age)
  28. evaporation.evaporate()