visualisation.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from xyworld.display.object.pygame.PygameImage import PygameImage
  2. from xyworld.display.object.pygame.DirectionnedImage import DirectionnedImage
  3. from socialintengine.synergy.object.Bug import Bug
  4. from socialintengine.synergy.object.ant.Ant import Ant
  5. from socialintengine.synergy.object.Rock import Rock
  6. from os import getcwd
  7. from synergine.metas import metas
  8. from socialintengine.cst import PREVIOUS_DIRECTION
  9. ant = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/ant.png')
  10. bug = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/ant.png')
  11. rock = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/rock.png')
  12. directions_ant = DirectionnedImage(ant)
  13. def bug_direction(bug):
  14. try:
  15. previous_direction = metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
  16. except KeyError:
  17. previous_direction = 14
  18. return directions_ant.get_for_direction(previous_direction)
  19. visualisation = {
  20. 'window': {},
  21. 'objects': {
  22. Ant: {
  23. 'default': ant,
  24. 'callbacks': [bug_direction]
  25. },
  26. Bug: {
  27. 'default': bug,
  28. 'callbacks': [bug_direction]
  29. },
  30. Rock: {
  31. 'default': rock
  32. }
  33. }
  34. }