ColonyConfiguration.py 825B

123456789101112131415161718192021222324252627
  1. from synergine.synergy.collection.Configuration import Configuration
  2. from intelligine.synergy.object.ant.Ant import Ant
  3. from intelligine.cst import ALIVE, COLONY
  4. from synergine_xyz.cst import POSITION
  5. class ColonyConfiguration(Configuration):
  6. _start_position = (0, 20, 20)
  7. _ant_class = Ant
  8. _ant_count = 50
  9. @classmethod
  10. def get_start_position(cls):
  11. return cls._start_position
  12. def get_start_objects(self, collection, context):
  13. context.metas.value.set(POSITION, collection.get_id(), self._start_position)
  14. ants = []
  15. for i in range(self._ant_count):
  16. ant = self._ant_class(collection, context)
  17. context.metas.value.set(COLONY, ant.get_id(), collection.get_id())
  18. ant.set_position(self._start_position)
  19. ants.append(ant)
  20. return ants