subject.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # coding: utf-8
  2. from sandbox.engulf.behaviour import GrowUp, SearchFood, Eat, Explore, CellBehaviourSelector
  3. from sandbox.engulf.const import COLLECTION_CELL, COLLECTION_ALIVE, COLLECTION_EATABLE, COLLECTION_GRASS
  4. from synergine2.simulation import Subject
  5. from synergine2.xyz import XYZSubjectMixin
  6. class Cell(XYZSubjectMixin, Subject):
  7. collections = [
  8. COLLECTION_CELL,
  9. COLLECTION_ALIVE,
  10. COLLECTION_EATABLE,
  11. ]
  12. # TODO: Mettre en place la "selection/choix": car il y a deux move possible chaque cycle ci-dessous.
  13. behaviours_classes = [
  14. SearchFood,
  15. Eat,
  16. Explore,
  17. ]
  18. behaviour_selector_class = CellBehaviourSelector
  19. class Grass(XYZSubjectMixin, Subject):
  20. collections = [
  21. COLLECTION_EATABLE,
  22. COLLECTION_GRASS,
  23. ]
  24. behaviours_classes = [
  25. GrowUp,
  26. ]
  27. def __init__(self, *args, density=100.0, **kwargs):
  28. super().__init__(*args, **kwargs)
  29. self._density = density
  30. @property
  31. def density(self) -> float:
  32. return self._density
  33. @density.setter
  34. def density(self, value: float) -> None:
  35. if value > 100:
  36. self._density = 100
  37. elif value < 0:
  38. self._density = 0
  39. else:
  40. self._density = value