subject.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. behaviours_classes = [
  13. SearchFood,
  14. Eat,
  15. Explore,
  16. ]
  17. class Grass(XYZSubjectMixin, Subject):
  18. collections = [
  19. COLLECTION_EATABLE,
  20. COLLECTION_GRASS,
  21. ]
  22. behaviours_classes = [
  23. GrowUp,
  24. ]
  25. def __init__(self, *args, density=100.0, **kwargs):
  26. super().__init__(*args, **kwargs)
  27. self._density = density
  28. @property
  29. def density(self) -> float:
  30. return self._density
  31. @density.setter
  32. def density(self, value: float) -> None:
  33. if value > 100:
  34. self._density = 100
  35. elif value < 0:
  36. self._density = 0
  37. else:
  38. self._density = value