PheromoneGland.py 989B

12345678910111213141516171819202122232425
  1. from intelligine.core.exceptions import BestPheromoneHere
  2. from intelligine.simulation.pheromone.DirectionPheromone import DirectionPheromone
  3. class PheromoneGland():
  4. def __init__(self, host, context):
  5. self._pheromone_type = None
  6. self._host = host
  7. self._context = context
  8. def set_pheromone_type(self, pheromone_type):
  9. self._pheromone_type = pheromone_type
  10. def get_pheromone_type(self):
  11. if self._pheromone_type is None:
  12. raise Exception("pheromone_type not specified")
  13. return self._pheromone_type
  14. def appose(self):
  15. try:
  16. DirectionPheromone.appose(self._context,
  17. self._host.get_position(),
  18. self._host.get_movement_pheromone_gland().get_movement_molecules())
  19. except BestPheromoneHere as best_pheromone_here:
  20. self._host.get_brain().set_distance_from_objective(best_pheromone_here.get_best_distance())