Browse Source

update antStar host position after moved

Bastien Sevajol 9 years ago
parent
commit
462c04fc95

+ 13 - 1
intelligine/display/Pygame.py View File

2
 from intelligine.synergy.object.ant.Ant import Ant
2
 from intelligine.synergy.object.ant.Ant import Ant
3
 from synergine_xyz.display.Pygame import Pygame as XyzPygame
3
 from synergine_xyz.display.Pygame import Pygame as XyzPygame
4
 import pygame
4
 import pygame
5
-from intelligine.cst import PHEROMON_DIR_EXPLO, MOLECULES, SMELL_EGG, SMELL_FOOD, MOLECULES_DIRECTION
5
+from intelligine.cst import PHEROMON_DIR_EXPLO, MOLECULES, SMELL_EGG, SMELL_FOOD, MOLECULES_DIRECTION, \
6
+    MOVE_BYBASS_MEMORY
6
 from intelligine.display.pygame.visualisation import SURFACE_PHEROMONE_EXPLORATION, SURFACE_PHEROMONE_HOME, \
7
 from intelligine.display.pygame.visualisation import SURFACE_PHEROMONE_EXPLORATION, SURFACE_PHEROMONE_HOME, \
7
     SURFACE_SMELL_EGG, SURFACE_SMELL_FOOD
8
     SURFACE_SMELL_EGG, SURFACE_SMELL_FOOD
8
 
9
 
78
             myfont = pygame.font.SysFont("monospace", 15)
79
             myfont = pygame.font.SysFont("monospace", 15)
79
             label = myfont.render(str(obj.get_id()), 1, (255,255,0))
80
             label = myfont.render(str(obj.get_id()), 1, (255,255,0))
80
             self._draw_callbacks.append(lambda: self._screen.blit(label, point))
81
             self._draw_callbacks.append(lambda: self._screen.blit(label, point))
82
+            label2 = myfont.render(',', 1, (0,0,0))
83
+
84
+            ant_mem = self._context.metas.value.get(MOVE_BYBASS_MEMORY, obj.get_id(), allow_empty=True,
85
+                                                             empty_value=[])
86
+
87
+            def print_mem(points):
88
+                for m in points:
89
+                    real_point = self._get_real_pixel_position_of_position((0, m[0], m[1]))
90
+                    self._screen.blit(label2, real_point)
91
+
92
+            self._draw_callbacks.append(lambda: print_mem(ant_mem) )
81
 
93
 
82
     def start_of_cycle(self):
94
     def start_of_cycle(self):
83
         super().start_of_cycle()
95
         super().start_of_cycle()

+ 4 - 2
intelligine/simulation/object/brain/part/move/AntStar/Host.py View File

1
 from intelligine.simulation.object.brain.part.move.AntStar.HostFeeler import HostFeeler
1
 from intelligine.simulation.object.brain.part.move.AntStar.HostFeeler import HostFeeler
2
+from intelligine.synergy.event.move.direction import get_position_with_direction_decal
2
 from synergine_xyz.cst import POSITION
3
 from synergine_xyz.cst import POSITION
3
 
4
 
4
 
5
 
9
         self._object_id = object_id
10
         self._object_id = object_id
10
         self._feeler = HostFeeler(context, object_id)
11
         self._feeler = HostFeeler(context, object_id)
11
         self._moved_to_direction = None
12
         self._moved_to_direction = None
13
+        self._position_3d = self._context.metas.value.get(POSITION, self._object_id)
12
 
14
 
13
     def get_position(self):
15
     def get_position(self):
14
-        current_position = self._context.metas.value.get(POSITION, self._object_id)
15
-        return current_position[1], current_position[2]
16
+        return self._position_3d[1], self._position_3d[2]
16
 
17
 
17
     def get_feeler(self):
18
     def get_feeler(self):
18
         return self._feeler
19
         return self._feeler
19
 
20
 
20
     def move_to(self, direction):
21
     def move_to(self, direction):
21
         self._moved_to_direction = direction
22
         self._moved_to_direction = direction
23
+        self._position_3d = get_position_with_direction_decal(direction, self._position_3d)
22
 
24
 
23
     def get_moved_to_direction(self):
25
     def get_moved_to_direction(self):
24
         return self._moved_to_direction
26
         return self._moved_to_direction