Browse Source

fix for recent changes

Bastien Sevajol 7 years ago
parent
commit
fdbcba4b1f

+ 4 - 0
sandbox/life_game/config.yaml View File

@@ -0,0 +1,4 @@
1
+core:
2
+    cycle_duration: 0.5
3
+terminals:
4
+    sync: True

+ 6 - 4
sandbox/life_game/run.py View File

@@ -124,16 +124,18 @@ def main():
124 124
         0 0 0 0 0 0 0 0 0 0 0 0 0
125 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 133
     subjects = get_subjects_from_str_representation(
129 134
         start_str_representation,
130 135
         simulation,
131 136
     )
132 137
     simulation.subjects = subjects
133 138
 
134
-    config = Config()
135
-    logger = get_default_logger(level=logging.DEBUG)
136
-
137 139
     core = Core(
138 140
         config=config,
139 141
         logger=logger,

+ 8 - 2
sandbox/life_game/simulation.py View File

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

+ 2 - 0
sandbox/life_game/utils.py View File

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

+ 1 - 0
synergine2/cycle.py View File

@@ -333,6 +333,7 @@ class CycleManager(object):
333 333
 
334 334
         for behaviour_class, behaviour_data in simulation_actions:
335 335
             behaviour = behaviour_class(
336
+                config=self.config,
336 337
                 simulation=self.simulation,
337 338
             )
338 339
 

+ 1 - 1
synergine2/simulation.py View File

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

+ 1 - 1
synergine2/xyz.py View File

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