Просмотр исходного кода

update antStar host position after moved

Bastien Sevajol 9 лет назад
Родитель
Сommit
462c04fc95

+ 13 - 1
intelligine/display/Pygame.py Просмотреть файл

@@ -2,7 +2,8 @@ from intelligine.core.exceptions import NoMolecule
2 2
 from intelligine.synergy.object.ant.Ant import Ant
3 3
 from synergine_xyz.display.Pygame import Pygame as XyzPygame
4 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 7
 from intelligine.display.pygame.visualisation import SURFACE_PHEROMONE_EXPLORATION, SURFACE_PHEROMONE_HOME, \
7 8
     SURFACE_SMELL_EGG, SURFACE_SMELL_FOOD
8 9
 
@@ -78,6 +79,17 @@ class Pygame(XyzPygame):
78 79
             myfont = pygame.font.SysFont("monospace", 15)
79 80
             label = myfont.render(str(obj.get_id()), 1, (255,255,0))
80 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 94
     def start_of_cycle(self):
83 95
         super().start_of_cycle()

+ 4 - 2
intelligine/simulation/object/brain/part/move/AntStar/Host.py Просмотреть файл

@@ -1,4 +1,5 @@
1 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 3
 from synergine_xyz.cst import POSITION
3 4
 
4 5
 
@@ -9,16 +10,17 @@ class Host:
9 10
         self._object_id = object_id
10 11
         self._feeler = HostFeeler(context, object_id)
11 12
         self._moved_to_direction = None
13
+        self._position_3d = self._context.metas.value.get(POSITION, self._object_id)
12 14
 
13 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 18
     def get_feeler(self):
18 19
         return self._feeler
19 20
 
20 21
     def move_to(self, direction):
21 22
         self._moved_to_direction = direction
23
+        self._position_3d = get_position_with_direction_decal(direction, self._position_3d)
22 24
 
23 25
     def get_moved_to_direction(self):
24 26
         return self._moved_to_direction