Browse Source

clean sandboxs with tmx load

Bastien Sevajol 8 years ago
parent
commit
fc3df328cb

+ 0 - 0
TODO View File


+ 5 - 7
config.py View File

@@ -1,19 +1,17 @@
1 1
 from intelligine.core.Context import Context
2
-from intelligine.synergy.Simulation import Simulation
3 2
 from intelligine.display.Pygame import Pygame
4
-from intelligine.display.pygame.visualisation import visualisation as pygame_visualisation
5 3
 import argparse
6 4
 
7 5
 parser = argparse.ArgumentParser(description='Select sandbox.')
8 6
 parser.add_argument('sandbox', metavar='sandbox', type=str, nargs=1,
9
-                    help='Name of sandbox: ' + ', '.join(['exploration', 'multi']))
7
+                    help='Name of sandbox: ' + ', '.join(['exploration', 'all']))
10 8
 
11 9
 args = parser.parse_args()
12 10
 
13
-if 'multi' in args.sandbox:
14
-    from intelligine.sandbox.colored.colors_colonys import collections
11
+if 'all' in args.sandbox:
12
+    from intelligine.sandbox.all.all import simulations, visualisation as pygame_visualisation
15 13
 elif 'exploration' in args.sandbox:
16
-    from intelligine.sandbox.exploration.collections import collections
14
+    from intelligine.sandbox.exploration.exploration import simulations, visualisation as pygame_visualisation
17 15
 else:
18 16
     parser.parse_args(['-h'])
19 17
 
@@ -31,7 +29,7 @@ config = {
31 29
             'cycles': -1
32 30
         }
33 31
     },
34
-    'simulations' : [Simulation(collections)],
32
+    'simulations': simulations,
35 33
     'connections': [Pygame],
36 34
     'terminal': {
37 35
       'pygame': {

+ 189 - 107
intelligine/display/pygame/visualisation.py View File

@@ -1,34 +1,35 @@
1
+import pygame
2
+from intelligine.synergy.Colony import Colony
3
+from intelligine.synergy.Rocks import Rocks
4
+from synergine.synergy.Simulation import Simulation
5
+from synergine_xyz.display.PygameImageRotate import PygameImageRotate
6
+from synergine_xyz.display.PygameVisualisation import PygameVisualisation
1 7
 from synergine_xyz.display.object.pygame.PygameImage import PygameImage
2
-from synergine_xyz.display.object.pygame.DirectionnedImage import DirectionnedImage
3
-from intelligine.synergy.object.Bug import Bug
4 8
 from intelligine.synergy.object.Food import Food
5
-from intelligine.synergy.object.Hole import Hole
6 9
 from intelligine.synergy.object.ant.Ant import Ant
7
-from intelligine.sandbox.colored.BlueAnt import BlueAnt
8
-from intelligine.sandbox.colored.RedAnt import RedAnt
9
-from intelligine.sandbox.colored.GreenAnt import GreenAnt
10 10
 from intelligine.synergy.object.Rock import Rock
11 11
 from intelligine.synergy.object.ant.Egg import Egg
12 12
 from os import getcwd
13 13
 from synergine_xyz.cst import PREVIOUS_DIRECTION
14
+from synergine_xyz.tmx.TileMapConnector import TileMapConnector
14 15
 
15 16
 SURFACE_PHEROMONE_HOME = 'pheromone_home'
16 17
 SURFACE_PHEROMONE_EXPLORATION = 'pheromone_exploration'
17 18
 
18 19
 # TODO: Analyser les procedes ici pour proposer des outils dans le framework
19 20
 
20
-ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
21
-food = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/food.png')
22
-hole = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/hole.png')
23
-dead_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_ant.png')
24
-red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/red_ant.png')
25
-green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/green_ant.png')
26
-blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/blue_ant.png')
27
-dead_red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_red_ant.png')
28
-dead_green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_green_ant.png')
29
-dead_blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_blue_ant.png')
30
-bug = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
31
-rock = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/rock.png')
21
+# ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
22
+# food = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/food.png')
23
+# hole = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/hole.png')
24
+# dead_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_ant.png')
25
+# red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/red_ant.png')
26
+# green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/green_ant.png')
27
+# blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/blue_ant.png')
28
+# dead_red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_red_ant.png')
29
+# dead_green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_green_ant.png')
30
+# dead_blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_blue_ant.png')
31
+# bug = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
32
+# rock = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/rock.png')
32 33
 egg = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg.png')
33 34
 eggc2 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c2.png')
34 35
 eggc3 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c3.png')
@@ -37,49 +38,49 @@ eggc5 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/eg
37 38
 eggc7 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c7.png')
38 39
 phee = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/phee.png')
39 40
 pheh = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/pheh.png')
40
-
41
-directions_ant = DirectionnedImage(ant)
42
-directions_red_ant = DirectionnedImage(red_ant)
43
-directions_blue_ant = DirectionnedImage(blue_ant)
44
-directions_green_ant = DirectionnedImage(green_ant)
45
-
46
-def bug_direction(bug, context):
47
-    if bug.get_life_points() <= 0:
48
-        return dead_ant
49
-    try:
50
-        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
51
-    except KeyError:
52
-        previous_direction = 14
53
-    return directions_ant.get_for_direction(previous_direction)
54
-
55
-def red_ant_direction(bug, context):
56
-    if bug.get_life_points() <= 0:
57
-        return dead_red_ant
58
-    try:
59
-        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
60
-    except KeyError:
61
-        previous_direction = 14
62
-    return directions_red_ant.get_for_direction(previous_direction)
63
-
64
-def blue_ant_direction(bug, context):
65
-    if bug.get_life_points() <= 0:
66
-        return dead_blue_ant
67
-    try:
68
-        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
69
-    except KeyError:
70
-        previous_direction = 14
71
-    return directions_blue_ant.get_for_direction(previous_direction)
72
-
73
-def green_ant_direction(bug, context):
74
-    if bug.get_life_points() <= 0:
75
-        return dead_green_ant
76
-    try:
77
-        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
78
-    except KeyError:
79
-        previous_direction = 14
80
-    return directions_green_ant.get_for_direction(previous_direction)
81
-
82
-
41
+#
42
+# directions_ant = DirectionnedImage(ant)
43
+# directions_red_ant = DirectionnedImage(red_ant)
44
+# directions_blue_ant = DirectionnedImage(blue_ant)
45
+# directions_green_ant = DirectionnedImage(green_ant)
46
+#
47
+# def bug_direction(bug, context):
48
+#     if bug.get_life_points() <= 0:
49
+#         return dead_ant
50
+#     try:
51
+#         previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
52
+#     except KeyError:
53
+#         previous_direction = 14
54
+#     return directions_ant.get_for_direction(previous_direction)
55
+#
56
+# def red_ant_direction(bug, context):
57
+#     if bug.get_life_points() <= 0:
58
+#         return dead_red_ant
59
+#     try:
60
+#         previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
61
+#     except KeyError:
62
+#         previous_direction = 14
63
+#     return directions_red_ant.get_for_direction(previous_direction)
64
+#
65
+# def blue_ant_direction(bug, context):
66
+#     if bug.get_life_points() <= 0:
67
+#         return dead_blue_ant
68
+#     try:
69
+#         previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
70
+#     except KeyError:
71
+#         previous_direction = 14
72
+#     return directions_blue_ant.get_for_direction(previous_direction)
73
+#
74
+# def green_ant_direction(bug, context):
75
+#     if bug.get_life_points() <= 0:
76
+#         return dead_green_ant
77
+#     try:
78
+#         previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
79
+#     except KeyError:
80
+#         previous_direction = 14
81
+#     return directions_green_ant.get_for_direction(previous_direction)
82
+#
83
+#
83 84
 def for_position(position, objects, context):
84 85
     # TODO: DEV TMP: refact, etc
85 86
     eggs = []
@@ -95,54 +96,135 @@ def for_position(position, objects, context):
95 96
     if len(eggs) > 4:
96 97
         return (eggc7, eggs)
97 98
     return (None, [])
99
+#
100
+# visualisation = {
101
+#     'window': {},
102
+#     'callbacks': {
103
+#         'position': for_position
104
+#     },
105
+#     'surfaces': {
106
+#         SURFACE_PHEROMONE_EXPLORATION: {
107
+#             'default': phee,
108
+#             'callbacks': []
109
+#         },
110
+#         SURFACE_PHEROMONE_HOME: {
111
+#             'default': pheh,
112
+#             'callbacks': []
113
+#         },
114
+#     },
115
+#     'objects': {
116
+#         RedAnt: {
117
+#             'default': red_ant,
118
+#             'callbacks': [red_ant_direction]
119
+#         },
120
+#         BlueAnt: {
121
+#             'default': blue_ant,
122
+#             'callbacks': [blue_ant_direction]
123
+#         },
124
+#         GreenAnt: {
125
+#             'default': green_ant,
126
+#             'callbacks': [green_ant_direction]
127
+#         },
128
+#         Ant: {
129
+#             'default': ant,
130
+#             'callbacks': [bug_direction]
131
+#         },
132
+#         Bug: {
133
+#             'default': bug,
134
+#             'callbacks': [bug_direction]
135
+#         },
136
+#         Egg: {
137
+#             'default': egg
138
+#         },
139
+#         Rock: {
140
+#             'default': rock
141
+#         },
142
+#         Food: {
143
+#             'default': food
144
+#         },
145
+#         Hole: {
146
+#             'default': hole
147
+#         }
148
+#     }
149
+# }
150
+
151
+#############################
152
+# Behind, new
153
+#############################
98 154
 
99
-visualisation = {
100
-    'window': {},
101
-    'callbacks': {
102
-        'position': for_position
155
+map_config = {
156
+    'simulation': {
157
+        'base': Simulation
103 158
     },
104
-    'surfaces': {
105
-        SURFACE_PHEROMONE_EXPLORATION: {
106
-            'default': phee,
107
-            'callbacks': []
108
-        },
109
-        SURFACE_PHEROMONE_HOME: {
110
-            'default': pheh,
111
-            'callbacks': []
112
-        },
159
+    'collection': {
160
+        'ant': Colony,
161
+        'env': Rocks  # TODO: Nom plus generique
113 162
     },
114
-    'objects': {
115
-        RedAnt: {
116
-            'default': red_ant,
117
-            'callbacks': [red_ant_direction]
118
-        },
119
-        BlueAnt: {
120
-            'default': blue_ant,
121
-            'callbacks': [blue_ant_direction]
122
-        },
123
-        GreenAnt: {
124
-            'default': green_ant,
125
-            'callbacks': [green_ant_direction]
126
-        },
127
-        Ant: {
128
-            'default': ant,
129
-            'callbacks': [bug_direction]
130
-        },
131
-        Bug: {
132
-            'default': bug,
133
-            'callbacks': [bug_direction]
134
-        },
135
-        Egg: {
136
-            'default': egg
137
-        },
138
-        Rock: {
139
-            'default': rock
140
-        },
141
-        Food: {
142
-            'default': food
163
+    'object': {
164
+        'ant': Ant,
165
+        'egg': Egg,
166
+        'rock': Rock,
167
+        'food': Food
168
+    }
169
+}
170
+image_rotate = PygameImageRotate()
171
+
172
+
173
+def dead_ant_callback_container(map_connector, production_class):
174
+    tile_set_id = map_connector.get_dynamic_classes().get_production_class_collection_id(production_class)
175
+    pil_image = map_connector.extract_image_with_class(tile_set_id, 'dead_ant')
176
+    image_bytes = pil_image.tobytes()
177
+    pygame_surface = pygame.image.fromstring(image_bytes, pil_image.size, pil_image.mode)
178
+    pygame_image = PygameImage(pygame_surface)
179
+
180
+    def dead_ant_callback(obj, context):
181
+        # TODO: obj dans le col ALIVE truc comme ça
182
+        if obj.get_life_points() <= 0:
183
+            return pygame_image
184
+        # TODO: raise, ou dans objectVisual.get_visual tests si bool plutot que is
185
+        return False
186
+
187
+    return dead_ant_callback
188
+
189
+
190
+def ant_direction_modifier(obj, context, visual):
191
+    try:
192
+        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, obj.get_id())
193
+    except KeyError:
194
+        previous_direction = 14
195
+    return image_rotate.get_for_direction(visual, previous_direction)
196
+
197
+
198
+def get_standard_extract_from_map(map_file_path, map_config):
199
+    map_connector = TileMapConnector.from_file(map_file_path, dict(map_config))
200
+    visualisation = PygameVisualisation.get_default_visualisation()
201
+
202
+    simulations = map_connector.create_simulations()
203
+    visualizer = PygameVisualisation(visualisation)
204
+
205
+    objects_images = map_connector.extract_objects_images()
206
+    visualizer.update_objects_images(objects_images)
207
+
208
+    map_connector.add_object_callback_to_visualisation(visualizer, [Ant], dead_ant_callback_container)
209
+    ant_production_classes = map_connector.get_dynamic_classes().get_production_classes(Ant)
210
+
211
+    for ant_production_class in ant_production_classes:
212
+        visualizer.add_modifier(ant_production_class, ant_direction_modifier)
213
+
214
+    visualisation.update({
215
+        'callbacks': {
216
+            'position': for_position
143 217
         },
144
-        Hole: {
145
-            'default': hole
218
+        'surfaces': {
219
+            SURFACE_PHEROMONE_EXPLORATION: {
220
+                'default': phee,
221
+                'callbacks': []
222
+            },
223
+            SURFACE_PHEROMONE_HOME: {
224
+                'default': pheh,
225
+                'callbacks': []
226
+            },
146 227
         }
147
-    }
148
-}
228
+    })
229
+
230
+    return simulations, visualisation

BIN
intelligine/display/src/environment.png View File


BIN
intelligine/display/src/environment.xcf View File


BIN
intelligine/display/src/tileset.png View File


BIN
intelligine/display/src/tileset.xcf View File


BIN
intelligine/display/src/tileset_colony.png View File


BIN
intelligine/display/src/tileset_colony_blue.png View File


BIN
intelligine/display/src/tileset_colony_green.png View File


BIN
intelligine/display/src/tileset_colony_red.png View File


+ 35 - 0
intelligine/sandbox/all/Labyrinthe.tmx View File

@@ -0,0 +1,35 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<map version="1.0" orientation="orthogonal" renderorder="right-down" width="200" height="100" tilewidth="20" tileheight="20" nextobjectid="1">
3
+ <tileset firstgid="1" name="Rock" tilewidth="20" tileheight="20">
4
+  <image source="../../display/pygame/image/rock.png" width="20" height="20"/>
5
+  <tile id="0">
6
+   <properties>
7
+    <property name="classname" value="Rock"/>
8
+    <property name="file" value="intelligine.synergy.object.Rock"/>
9
+   </properties>
10
+  </tile>
11
+ </tileset>
12
+ <tileset firstgid="2" name="Food" tilewidth="20" tileheight="20">
13
+  <image source="../../display/pygame/image/food.png" width="20" height="20"/>
14
+  <tile id="0">
15
+   <properties>
16
+    <property name="classname" value="Food"/>
17
+    <property name="file" value="intelligine.synergy.object.Food"/>
18
+   </properties>
19
+  </tile>
20
+ </tileset>
21
+ <tileset firstgid="3" name="Hole" tilewidth="20" tileheight="20">
22
+  <image source="../../display/pygame/image/hole.png" width="20" height="20"/>
23
+  <tile id="0">
24
+   <properties>
25
+    <property name="classname" value="Hole"/>
26
+    <property name="file" value="intelligine.synergy.object.Hole"/>
27
+   </properties>
28
+  </tile>
29
+ </tileset>
30
+ <layer name="Calque 1" width="200" height="100">
31
+  <data encoding="base64" compression="zlib">
32
+   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
33
+  </data>
34
+ </layer>
35
+</map>

+ 6 - 0
intelligine/sandbox/all/all.py View File

@@ -0,0 +1,6 @@
1
+from os import getcwd
2
+from intelligine.display.pygame.visualisation import get_standard_extract_from_map, map_config
3
+
4
+
5
+simulations, visualisation = get_standard_extract_from_map(getcwd()+"/intelligine/sandbox/all/map.tmx",
6
+                                                           map_config)

File diff suppressed because it is too large
+ 10186 - 0
intelligine/sandbox/all/map.tmx


+ 36 - 0
intelligine/sandbox/all/old_map.tmx View File

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<map version="1.0" orientation="isometric" width="200" height="100" tilewidth="20" tileheight="20">
3
+ <tileset firstgid="1" name="Rock" tilewidth="20" tileheight="20">
4
+  <image source="../../display/pygame/image/rock.png" width="20" height="20"/>
5
+  <tile id="0">
6
+   <properties>
7
+    <property name="classname" value="Rock"/>
8
+    <property name="file" value="intelligine.synergy.object.Rock"/>
9
+   </properties>
10
+  </tile>
11
+ </tileset>
12
+ <tileset firstgid="2" name="Food" tilewidth="20" tileheight="20">
13
+  <image source="../../display/pygame/image/food.png" width="20" height="20"/>
14
+  <tile id="0">
15
+   <properties>
16
+    <property name="classname" value="Food"/>
17
+    <property name="file" value="intelligine.synergy.object.Food"/>
18
+   </properties>
19
+  </tile>
20
+ </tileset>
21
+ <tileset firstgid="3" name="Hole" tilewidth="20" tileheight="20">
22
+  <image source="../../display/pygame/image/hole.png" width="20" height="20"/>
23
+  <tile id="0">
24
+   <properties>
25
+    <property name="classname" value="Hole"/>
26
+    <property name="file" value="intelligine.synergy.object.Hole"/>
27
+   </properties>
28
+  </tile>
29
+ </tileset>
30
+ <layer name="Calque 1" width="200" height="100">
31
+  <data encoding="base64" compression="zlib">
32
+   eJztndtu4zAMBZPu///zolgY2wa+ySapw+MZQE8FL6U0SFIlzfv1er1ZLNbmgljuzpQ90QA/cjgz06+b8ZAPfuSwN9OvjzUaD3XgRw5bM/10Y8sR9kSDLT/+VDdiBn54wONHDvjhAX7kMOLHSDzUgh854IcH+JED9x8e4EcO+OHBqB+z7/m7vMcAPzy44kcnZvWLHx7gh2bdbnN2BT8063absyv4oVm325xdwQ/Nut3m7Ap+aNbtNmdX8EOzbrc5u4IfGvclV/qGfPBDs263ObuCH5p1u83ZFfzQrNttzq7gh2bdbnN2BT8063absyv4oVm325xdwY+cPPjhAX7k5MEPD/AjJw9+eIAfOXnwwwP8yMmDHx7gR20e1XqwDn7U5lGtB+vgR20e1XqwDn7U5lGtB+vgR20e1XqwjpIfUZ8t+syplEe1Hqwzy4/sz9/9rKOUR7UerDPTj6OfR9TCD7iDih9r/+s/+rnWHc483kUvmI+CH3vfh6F+VrJ6U/6dn4SiH50cwQ9vVP3o4gh+eNPFjyVG7dzghzeqfuzFKZ0d/PBG0Y8zsSrnBz+8UfDjarzCGcIPb7r6seSYfY7ww5vOfix5Zp4l/PCmux9Lrlnn6UzdK73hhwYOfiz5Zpwp/PDGxY8lZ/W5wg9vZvqR8X69akfww5tOjx+KjuCHN538GImrcgQ/vOnmx0hshSP44U1HP0bisx3BD2+6+jGSI9MR/PCmsx8jebIcwQ9vuvsxkivDEfzwxsGPkXzRjjzVD/X+onDxYyRnpCP44Y2THyN51e4QI2IqUe8vCjc/RlC6Q4yIqUS9vyie7Mc3KneIETGVqPcXxdP9+EbhDjEiphL1/qLAj3/MvkOMiKlEvb8o8OM/M+8QI2IqUe8vCvz4zaw7xIiYStT7i6Ly75yfdVWZcYcYEVOJen9R4Mc61XeIETGVqPcXBX5sEzUb/OgLfuwTMR/86At+HHN3RvjRF/w4x5054Udf8OM8V2eFH33BjzGuzAs/+oIf4+CHfn9R4Ec++NEX/MgHP/rynrieAn705WlndQb40Rf8yAc/+oIf+eBHX7b8OPtdy3AMfvRlzY+R7yKHY/CjL59+4EY8e2dpa87q50+9vyjwI5+9569bs1Y/f+r9RYEf+ew9f8UPbbb8gDjwoy9rfkAs+NEX7j/ywY++4Ec+R6/Pz8Yood5fFPgxh6PXeep7ot5fFPihifqeqPcXBX5oor4n6v1FgR+aqO+Jen9R4Icm6nui3l8U+KGJ+p6o9xfFzM/Xslgd1l+ybAWq
33
+  </data>
34
+ </layer>
35
+ <objectgroup name="Calque d'objets 1" width="200" height="100"/>
36
+</map>

+ 0 - 4
intelligine/sandbox/colored/BlueAnt.py View File

@@ -1,4 +0,0 @@
1
-from intelligine.synergy.object.ant.Ant import Ant
2
-
3
-class BlueAnt(Ant):
4
-    pass

+ 0 - 8
intelligine/sandbox/colored/BlueColonyConfiguration.py View File

@@ -1,8 +0,0 @@
1
-from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.sandbox.colored.BlueAnt import BlueAnt
3
-
4
-
5
-class BlueColonyConfiguration(ColonyConfiguration):
6
-
7
-    _start_position = (0, 20, 20)
8
-    _ant_class = BlueAnt

+ 0 - 4
intelligine/sandbox/colored/GreenAnt.py View File

@@ -1,4 +0,0 @@
1
-from intelligine.synergy.object.ant.Ant import Ant
2
-
3
-class GreenAnt(Ant):
4
-    pass

+ 0 - 8
intelligine/sandbox/colored/GreenColonyConfiguration.py View File

@@ -1,8 +0,0 @@
1
-from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.sandbox.colored.GreenAnt import GreenAnt
3
-
4
-
5
-class GreenColonyConfiguration(ColonyConfiguration):
6
-
7
-    _start_position = (0, 70, 70)
8
-    _ant_class = GreenAnt

+ 0 - 4
intelligine/sandbox/colored/RedAnt.py View File

@@ -1,4 +0,0 @@
1
-from intelligine.synergy.object.ant.Ant import Ant
2
-
3
-class RedAnt(Ant):
4
-    pass

+ 0 - 28
intelligine/sandbox/colored/RedColonyConfiguration.py View File

@@ -1,28 +0,0 @@
1
-from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.sandbox.colored.RedAnt import RedAnt
3
-from intelligine.synergy.object.ant.Egg import Egg
4
-from intelligine.cst import COLONY, MOVE_MODE_NURSE
5
-
6
-
7
-class RedColonyConfiguration(ColonyConfiguration):
8
-
9
-    _start_position = (0, 20, 70)
10
-    _ant_class = RedAnt
11
-    _ant_count = 50
12
-
13
-    def get_start_objects(self, collection, context):
14
-        objects = super().get_start_objects(collection, context)
15
-
16
-        for ant in objects:
17
-            ant._brain.switch_to_mode(MOVE_MODE_NURSE)
18
-
19
-        for x in range(50):
20
-          for y in range(1, 50):
21
-            if x % 3 == 0 and y % 3 == 0:
22
-              egg = Egg(collection, context)
23
-              egg.set_position((0, 1+x, 50+y))
24
-              context.metas.value.set(COLONY, egg.get_id(), collection.get_id())
25
-              objects.append(egg)
26
-
27
-        return objects
28
-

+ 0 - 11
intelligine/sandbox/colored/colors_colonys.py View File

@@ -1,11 +0,0 @@
1
-from intelligine.sandbox.colored.RedColonyConfiguration import RedColonyConfiguration
2
-from intelligine.sandbox.colored.BlueColonyConfiguration import BlueColonyConfiguration
3
-from intelligine.sandbox.colored.GreenColonyConfiguration import GreenColonyConfiguration
4
-from intelligine.synergy.Colony import Colony
5
-from intelligine.synergy.Rocks import Rocks
6
-from intelligine.synergy.RocksConfiguration import RocksConfiguration
7
-
8
-collections = [Colony(BlueColonyConfiguration()), \
9
-               Colony(RedColonyConfiguration()), \
10
-               Colony(GreenColonyConfiguration()), \
11
-               Rocks(RocksConfiguration())]

+ 0 - 9
intelligine/sandbox/exploration/ColonyConfiguration.py View File

@@ -1,9 +0,0 @@
1
-from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.synergy.object.ant.Ant import Ant
3
-
4
-
5
-class ColonyConfiguration(ColonyConfiguration):
6
-
7
-    _start_position = (0, 1, 1)
8
-    _ant_class = Ant
9
-    _ant_count = 100

+ 0 - 40
intelligine/sandbox/exploration/RocksConfiguration.py View File

@@ -1,40 +0,0 @@
1
-from intelligine.synergy.object.Food import Food
2
-from synergine.synergy.collection.Configuration import Configuration
3
-from intelligine.synergy.object.Rock import Rock
4
-import pytmx
5
-from os import getcwd
6
-
7
-
8
-class RocksConfiguration(Configuration):
9
-
10
-    def get_start_objects(self, collection, context):
11
-        rocks = []
12
-        # TODO: Experimental: Crer un loader de TMX (qui gere aussi les visualisation ?)
13
-        tmxdata = pytmx.TiledMap(getcwd()+"/intelligine/sandbox/exploration/map2.tmx")
14
-
15
-        objects = {}
16
-        for tileset in tmxdata.tilesets:
17
-            obj_id = tileset.firstgid
18
-            file = tmxdata.tile_properties[obj_id]['file']
19
-            classname = tmxdata.tile_properties[obj_id]['classname']
20
-            mod = __import__(file,
21
-                             fromlist=[classname])
22
-            objects[obj_id] = {
23
-                'class': getattr(mod, classname)
24
-            }
25
-
26
-        for layer in [vl for vl in tmxdata.visible_layers]:
27
-            for xi, x in enumerate(layer.data):
28
-                for yi, y in enumerate(x):
29
-                    if y in objects:
30
-                        rock = objects[y]['class'](collection, context)
31
-                        rock.set_position((0, xi, yi))
32
-                        rocks.append(rock)
33
-
34
-        #  TEST (en attendant d'avoir des algo pour deposer dans un depot)
35
-        food1 = Food(collection, context)
36
-        food1.set_position((0, 0, 0))
37
-        food1.is_takable = lambda: False
38
-        rocks.append(food1)
39
-
40
-        return rocks

+ 0 - 6
intelligine/sandbox/exploration/collections.py View File

@@ -1,6 +0,0 @@
1
-from intelligine.sandbox.exploration.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.synergy.Colony import Colony
3
-from intelligine.synergy.Rocks import Rocks
4
-from intelligine.sandbox.exploration.RocksConfiguration import RocksConfiguration
5
-
6
-collections = [Colony(ColonyConfiguration()), Rocks(RocksConfiguration())]

+ 6 - 0
intelligine/sandbox/exploration/exploration.py View File

@@ -0,0 +1,6 @@
1
+from os import getcwd
2
+from intelligine.display.pygame.visualisation import get_standard_extract_from_map, map_config
3
+
4
+
5
+simulations, visualisation = get_standard_extract_from_map(getcwd()+"/intelligine/sandbox/exploration/map.tmx",
6
+                                                           map_config)

File diff suppressed because it is too large
+ 10167 - 16
intelligine/sandbox/exploration/map.tmx


+ 0 - 35
intelligine/sandbox/exploration/map2.tmx View File

@@ -1,35 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<map version="1.0" orientation="isometric" width="200" height="100" tilewidth="20" tileheight="20">
3
- <tileset firstgid="1" name="Rock" tilewidth="20" tileheight="20">
4
-  <image source="../../display/pygame/image/rock.png" width="20" height="20"/>
5
-  <tile id="0">
6
-   <properties>
7
-    <property name="classname" value="Rock"/>
8
-    <property name="file" value="intelligine.synergy.object.Rock"/>
9
-   </properties>
10
-  </tile>
11
- </tileset>
12
- <tileset firstgid="2" name="Food" tilewidth="20" tileheight="20">
13
-  <image source="../../display/pygame/image/food.png" width="20" height="20"/>
14
-  <tile id="0">
15
-   <properties>
16
-    <property name="classname" value="Food"/>
17
-    <property name="file" value="intelligine.synergy.object.Food"/>
18
-   </properties>
19
-  </tile>
20
- </tileset>
21
- <tileset firstgid="3" name="hole" tilewidth="20" tileheight="20">
22
-  <image source="../../display/pygame/image/hole.png" width="20" height="20"/>
23
-  <tile id="0">
24
-   <properties>
25
-    <property name="classname" value="Hole"/>
26
-    <property name="file" value="intelligine.synergy.object.Hole"/>
27
-   </properties>
28
-  </tile>
29
- </tileset>
30
- <layer name="Calque 1" width="200" height="100">
31
-  <data encoding="base64" compression="zlib">
32
-   eJzt3MFKI0EARdFE//+fBxeiDE5MXsIs6p4DvS14dC4upOt6uVyunvnhbK96x6f+Vt5uPKdu5os+fqePLn3cRx9N+rifPnp+esfvLzrnRPpo8ffjcfro0MdGHw362BU31+hjV9xco49dcXONPnbFzTX62BU31+hjV9xco49dcXONPnbFzTX62BU31+hjV9xco49dcXONPnbFzTX62BU31+hjV9xc8/GOb91BcO9T/K0UN9foY1fcXKOPXXFzjT52xc01+tgVN9foY1fcXKOPXXFzjf9/7Iqba/SxK26u0ceuuLlGH7vi5hp97Iqba/SxK26u0ceuuLlGH7vi5hp97Iqba/SxK26u0ceuuLlGH7vi5hp97Iqba/SxK26u0ceuuLlGH7vi5hp9bKrfhNXo43HlbyZrPr+vfcU5BfVvimu+f3/+7Dmn8819z9/3MzxzzsncSdH00/0l6zmncmdL17/u91nOOZE7jdpu3X/16DmncecXv90P98g5J3EnHh+unqceAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+jz/dxQL7
33
-  </data>
34
- </layer>
35
-</map>