subject.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # coding: utf-8
  2. from sandbox.engulf.behaviour import GrowUp, SearchFood, Eat, Explore
  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. class Grass(XYZSubjectMixin, Subject):
  19. collections = [
  20. COLLECTION_EATABLE,
  21. COLLECTION_GRASS,
  22. ]
  23. behaviours_classes = [
  24. GrowUp,
  25. ]
  26. def __init__(self, *args, density=100.0, **kwargs):
  27. super().__init__(*args, **kwargs)
  28. self._density = density
  29. @property
  30. def density(self) -> float:
  31. return self._density
  32. @density.setter
  33. def density(self, value: float) -> None:
  34. if value > 100:
  35. self._density = 100
  36. elif value < 0:
  37. self._density = 0
  38. else:
  39. self._density = value