Context.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from synergine_xyz.Context import Context as XyzContext
  2. from intelligine.cst import IMPENETRABLE
  3. from synergine_xyz.cst import POSITIONS
  4. from intelligine.synergy.stigmergy.PheromonesManager import PheromonesManager
  5. class Context(XyzContext):
  6. def __init__(self):
  7. super().__init__()
  8. self._pheromones = PheromonesManager(self)
  9. def pheromones(self):
  10. return self._pheromones
  11. def position_is_penetrable(self, position):
  12. """
  13. Return True if position is empty or occuped by non physical impenetrable object.
  14. :param position:
  15. :return:
  16. """
  17. objects_ids_on_this_point = self.metas.list.get(POSITIONS, position, allow_empty=True)
  18. for object_id_on_this_point in objects_ids_on_this_point:
  19. if self.metas.states.have(object_id_on_this_point, IMPENETRABLE):
  20. return False
  21. return True
  22. def position_can_be_odorus(self, position):
  23. """
  24. Return True if position can smell
  25. :param position:
  26. :return:
  27. """
  28. return self.position_is_penetrable(position)