Explorar el Código

fix for recent changes

Bastien Sevajol hace 8 años
padre
commit
fdbcba4b1f

+ 4 - 0
sandbox/life_game/config.yaml Ver fichero

1
+core:
2
+    cycle_duration: 0.5
3
+terminals:
4
+    sync: True

+ 6 - 4
sandbox/life_game/run.py Ver fichero

124
         0 0 0 0 0 0 0 0 0 0 0 0 0
124
         0 0 0 0 0 0 0 0 0 0 0 0 0
125
         0 0 0 0 0 0 0 0 0 0 0 0 0
125
         0 0 0 0 0 0 0 0 0 0 0 0 0
126
     """
126
     """
127
-    simulation = LifeGame()
127
+
128
+    config = Config()
129
+    config.load_files(['sandbox/life_game/config.yaml'])
130
+    logger = get_default_logger(level=logging.DEBUG)
131
+
132
+    simulation = LifeGame(config)
128
     subjects = get_subjects_from_str_representation(
133
     subjects = get_subjects_from_str_representation(
129
         start_str_representation,
134
         start_str_representation,
130
         simulation,
135
         simulation,
131
     )
136
     )
132
     simulation.subjects = subjects
137
     simulation.subjects = subjects
133
 
138
 
134
-    config = Config()
135
-    logger = get_default_logger(level=logging.DEBUG)
136
-
137
     core = Core(
139
     core = Core(
138
         config=config,
140
         config=config,
139
         logger=logger,
141
         logger=logger,

+ 8 - 2
sandbox/life_game/simulation.py Ver fichero

1
 # coding: utf-8
1
 # coding: utf-8
2
-from synergine2.simulation import Subject, SimulationMechanism, Simulation
2
+from synergine2.simulation import Subject, SimulationMechanism
3
 from synergine2.simulation import SimulationBehaviour
3
 from synergine2.simulation import SimulationBehaviour
4
 from synergine2.simulation import Event
4
 from synergine2.simulation import Event
5
 from synergine2.simulation import SubjectBehaviour
5
 from synergine2.simulation import SubjectBehaviour
6
 from synergine2.utils import ChunkManager
6
 from synergine2.utils import ChunkManager
7
 from synergine2.xyz import ProximitySubjectMechanism, ProximityMixin
7
 from synergine2.xyz import ProximitySubjectMechanism, ProximityMixin
8
 from synergine2.xyz import XYZSubjectMixin
8
 from synergine2.xyz import XYZSubjectMixin
9
+from synergine2.xyz import XYZSimulation
9
 from synergine2.xyz_utils import get_around_positions_of_positions, get_min_and_max
10
 from synergine2.xyz_utils import get_around_positions_of_positions, get_min_and_max
10
 
11
 
11
 COLLECTION_CELL = 'COLLECTION_CELL'  # Collections of Cell type
12
 COLLECTION_CELL = 'COLLECTION_CELL'  # Collections of Cell type
74
 
75
 
75
     def action(self, data):
76
     def action(self, data):
76
         new_empty = Empty(
77
         new_empty = Empty(
78
+            config=self.config,
77
             simulation=self.simulation,
79
             simulation=self.simulation,
78
             position=self.subject.position,
80
             position=self.subject.position,
79
         )
81
         )
93
 
95
 
94
     def action(self, data):
96
     def action(self, data):
95
         new_cell = Cell(
97
         new_cell = Cell(
98
+            config=self.config,
96
             simulation=self.simulation,
99
             simulation=self.simulation,
97
             position=self.subject.position,
100
             position=self.subject.position,
98
         )
101
         )
101
         for position in positions_to_complete:
104
         for position in positions_to_complete:
102
             if position not in self.simulation.subjects.xyz:
105
             if position not in self.simulation.subjects.xyz:
103
                 new_empty = Empty(
106
                 new_empty = Empty(
107
+                    config=self.config,
104
                     simulation=self.simulation,
108
                     simulation=self.simulation,
105
                     position=position,
109
                     position=position,
106
                 )
110
                 )
122
 
126
 
123
         if not cell_at_position or isinstance(cell_at_position, Empty):
127
         if not cell_at_position or isinstance(cell_at_position, Empty):
124
             new_cell = Cell(
128
             new_cell = Cell(
129
+                config=self.config,
125
                 simulation=self.simulation,
130
                 simulation=self.simulation,
126
                 position=position,
131
                 position=position,
127
             )
132
             )
131
             return [CellBornEvent(new_cell.id)]
136
             return [CellBornEvent(new_cell.id)]
132
 
137
 
133
         new_empty = Empty(
138
         new_empty = Empty(
139
+            config=self.config,
134
             simulation=self.simulation,
140
             simulation=self.simulation,
135
             position=position,
141
             position=position,
136
         )
142
         )
178
     behaviours_classes = [CellBornBehaviour]
184
     behaviours_classes = [CellBornBehaviour]
179
 
185
 
180
 
186
 
181
-class LifeGame(Simulation):
187
+class LifeGame(XYZSimulation):
182
     behaviours_classes = [LotOfCellsSignalBehaviour]
188
     behaviours_classes = [LotOfCellsSignalBehaviour]

+ 2 - 0
sandbox/life_game/utils.py Ver fichero

16
         for position in positions:
16
         for position in positions:
17
             if item == '0':
17
             if item == '0':
18
                 subjects.append(Empty(
18
                 subjects.append(Empty(
19
+                    config=simulation.config,
19
                     simulation=simulation,
20
                     simulation=simulation,
20
                     position=position,
21
                     position=position,
21
                 ))
22
                 ))
22
             if item == '1':
23
             if item == '1':
23
                 subjects.append(Cell(
24
                 subjects.append(Cell(
25
+                    config=simulation.config,
24
                     simulation=simulation,
26
                     simulation=simulation,
25
                     position=position,
27
                     position=position,
26
                 ))
28
                 ))

+ 1 - 0
synergine2/cycle.py Ver fichero

333
 
333
 
334
         for behaviour_class, behaviour_data in simulation_actions:
334
         for behaviour_class, behaviour_data in simulation_actions:
335
             behaviour = behaviour_class(
335
             behaviour = behaviour_class(
336
+                config=self.config,
336
                 simulation=self.simulation,
337
                 simulation=self.simulation,
337
             )
338
             )
338
 
339
 

+ 1 - 1
synergine2/simulation.py Ver fichero

32
         self.initialize()
32
         self.initialize()
33
 
33
 
34
     def __str__(self):
34
     def __str__(self):
35
-        return self.id
35
+        return self.__repr__()
36
 
36
 
37
     def __repr__(self):
37
     def __repr__(self):
38
         return '{}({})'.format(
38
         return '{}({})'.format(

+ 1 - 1
synergine2/xyz.py Ver fichero

192
         )
192
         )
193
 
193
 
194
     def acceptable_subject(self, subject: Subject) -> bool:
194
     def acceptable_subject(self, subject: Subject) -> bool:
195
-        pass
195
+        return True
196
 
196
 
197
 
197
 
198
 class ProximitySubjectMechanism(ProximityMixin, SubjectMechanism):
198
 class ProximitySubjectMechanism(ProximityMixin, SubjectMechanism):