Browse Source

reorganize libs to run tests without import pygame

Bastien Sevajol 9 years ago
parent
commit
94463a0952

+ 5 - 0
intelligine/display/map.py View File

1
+from synergine_xyz.tmx.TileMapConnector import TileMapConnector
2
+
3
+
4
+def get_map_connector(map_file_path, map_config):
5
+    return TileMapConnector.from_file(map_file_path, dict(map_config))

+ 26 - 0
intelligine/display/pygame/config.py View File

1
+from intelligine.synergy.Colony import Colony
2
+from intelligine.synergy.Environment import Environment
3
+from intelligine.synergy.object.StockedFood import StockedFood
4
+from synergine.synergy.Simulation import Simulation
5
+from intelligine.synergy.object.Food import Food
6
+from intelligine.synergy.object.Rock import Rock
7
+from intelligine.synergy.object.ant.Ant import Ant
8
+from intelligine.synergy.object.ant.Egg import Egg
9
+
10
+
11
+map_config = {
12
+    'simulation': {
13
+        'base': Simulation
14
+    },
15
+    'collection': {
16
+        'ant': Colony,
17
+        'env': Environment
18
+    },
19
+    'object': {
20
+        'ant': Ant,
21
+        'egg': Egg,
22
+        'rock': Rock,
23
+        'food': Food,
24
+        'stocked_food': StockedFood
25
+    }
26
+}

+ 2 - 24
intelligine/display/pygame/visualisation.py View File

1
 import pygame
1
 import pygame
2
-from intelligine.synergy.Colony import Colony
3
-from intelligine.synergy.Environment import Environment
4
-from intelligine.synergy.object.StockedFood import StockedFood
5
-from synergine.synergy.Simulation import Simulation
2
+from intelligine.display.map import get_map_connector
6
 from synergine_xyz.display.PygameImageRotate import PygameImageRotate
3
 from synergine_xyz.display.PygameImageRotate import PygameImageRotate
7
 from synergine_xyz.display.PygameVisualisation import PygameVisualisation
4
 from synergine_xyz.display.PygameVisualisation import PygameVisualisation
8
 from synergine_xyz.display.object.pygame.PygameImage import PygameImage
5
 from synergine_xyz.display.object.pygame.PygameImage import PygameImage
9
-from intelligine.synergy.object.Food import Food
10
 from intelligine.synergy.object.ant.Ant import Ant
6
 from intelligine.synergy.object.ant.Ant import Ant
11
-from intelligine.synergy.object.Rock import Rock
12
 from intelligine.synergy.object.ant.Egg import Egg
7
 from intelligine.synergy.object.ant.Egg import Egg
13
 from os import getcwd
8
 from os import getcwd
14
 from synergine_xyz.cst import PREVIOUS_DIRECTION
9
 from synergine_xyz.cst import PREVIOUS_DIRECTION
15
-from synergine_xyz.tmx.TileMapConnector import TileMapConnector
16
 
10
 
17
 SURFACE_PHEROMONE_HOME = 'molecule_home'
11
 SURFACE_PHEROMONE_HOME = 'molecule_home'
18
 SURFACE_PHEROMONE_EXPLORATION = 'molecule_exploration'
12
 SURFACE_PHEROMONE_EXPLORATION = 'molecule_exploration'
158
 # Behind, new
152
 # Behind, new
159
 #############################
153
 #############################
160
 
154
 
161
-map_config = {
162
-    'simulation': {
163
-        'base': Simulation
164
-    },
165
-    'collection': {
166
-        'ant': Colony,
167
-        'env': Environment
168
-    },
169
-    'object': {
170
-        'ant': Ant,
171
-        'egg': Egg,
172
-        'rock': Rock,
173
-        'food': Food,
174
-        'stocked_food': StockedFood
175
-    }
176
-}
177
 image_rotate = PygameImageRotate()
155
 image_rotate = PygameImageRotate()
178
 
156
 
179
 
157
 
203
 
181
 
204
 
182
 
205
 def get_standard_extract_from_map(map_file_path, map_config):
183
 def get_standard_extract_from_map(map_file_path, map_config):
206
-    map_connector = TileMapConnector.from_file(map_file_path, dict(map_config))
184
+    map_connector = get_map_connector(map_file_path, map_config)
207
     visualisation = PygameVisualisation.get_default_visualisation()
185
     visualisation = PygameVisualisation.get_default_visualisation()
208
 
186
 
209
     simulations = map_connector.create_simulations()
187
     simulations = map_connector.create_simulations()

+ 4 - 3
intelligine/tests/src/simulation/SimpleTestWorld1Simulation.py View File

1
+from intelligine.display.map import get_map_connector
2
+from intelligine.display.pygame.config import map_config
1
 from synergine.test.TestSimulation import TestSimulation
3
 from synergine.test.TestSimulation import TestSimulation
2
 from os import getcwd
4
 from os import getcwd
3
-from intelligine.display.pygame.visualisation import get_standard_extract_from_map, map_config
4
 
5
 
5
 
6
 
6
 class SimpleTestWorld1Simulation(TestSimulation):
7
 class SimpleTestWorld1Simulation(TestSimulation):
8
     def __init__(self, *args, **kwargs):
9
     def __init__(self, *args, **kwargs):
9
         super().__init__(*args, **kwargs)
10
         super().__init__(*args, **kwargs)
10
 
11
 
11
-        simulations, visualisation = get_standard_extract_from_map(
12
+        map_connector = get_map_connector(
12
             getcwd()+"/intelligine/tests/src/simulation/SimpleTestWorld1.tmx",
13
             getcwd()+"/intelligine/tests/src/simulation/SimpleTestWorld1.tmx",
13
             map_config
14
             map_config
14
         )
15
         )
15
-        self._simulations = simulations
16
+        self._simulations = map_connector.create_simulations()
16
 
17
 
17
     def _get_set_up_simulations(self):
18
     def _get_set_up_simulations(self):
18
         return self._simulations
19
         return self._simulations