|
@@ -18,7 +18,7 @@ Engulf is simulation containing:
|
18
|
18
|
* alone/not alone: - be alone + not alone
|
19
|
19
|
|
20
|
20
|
"""
|
21
|
|
-from random import randint
|
|
21
|
+from random import randint, seed
|
22
|
22
|
|
23
|
23
|
from sandbox.engulf.subject import Cell, Grass, COLLECTION_GRASS
|
24
|
24
|
from synergine2.core import Core
|
|
@@ -26,7 +26,7 @@ from synergine2.cycle import CycleManager
|
26
|
26
|
from synergine2.terminals import TerminalManager, Terminal, TerminalPackage
|
27
|
27
|
from synergine2.xyz import Simulation
|
28
|
28
|
from sandbox.engulf.simulation import EngulfSubjects
|
29
|
|
-from synergine2.xyz_utils import get_around_positions_of
|
|
29
|
+from synergine2.xyz_utils import get_around_positions_of, get_distance_between_points
|
30
|
30
|
|
31
|
31
|
|
32
|
32
|
class Engulf(Simulation):
|
|
@@ -98,20 +98,20 @@ def fill_with_random_grass(
|
98
|
98
|
grasses.append(grass)
|
99
|
99
|
subjects.append(grass)
|
100
|
100
|
|
101
|
|
- for grass in subjects.simulation.collections[COLLECTION_GRASS][:]:
|
102
|
|
- a = 1
|
|
101
|
+ for grass in grasses:
|
103
|
102
|
for around in get_around_positions_of(grass.position, distance=density):
|
104
|
103
|
if around not in subjects.grass_xyz:
|
105
|
|
- grass = Grass(
|
|
104
|
+ new_grass = Grass(
|
106
|
105
|
simulation=subjects.simulation,
|
107
|
106
|
position=around,
|
108
|
107
|
)
|
109
|
|
- grasses.append(grass)
|
110
|
|
- subjects.append(grass)
|
111
|
|
-
|
|
108
|
+ distance = get_distance_between_points(around, grass.position)
|
|
109
|
+ new_grass.density = 100 - round((distance * 100) / 7)
|
|
110
|
+ subjects.append(new_grass)
|
112
|
111
|
|
113
|
112
|
|
114
|
113
|
def main():
|
|
114
|
+ seed(0)
|
115
|
115
|
simulation = Engulf()
|
116
|
116
|
subjects = EngulfSubjects(simulation=simulation)
|
117
|
117
|
fill_with_random_cells(
|
|
@@ -122,7 +122,7 @@ def main():
|
122
|
122
|
)
|
123
|
123
|
fill_with_random_grass(
|
124
|
124
|
subjects,
|
125
|
|
- 15,
|
|
125
|
+ 5,
|
126
|
126
|
(-34, -34, 0),
|
127
|
127
|
(34, 34, 0),
|
128
|
128
|
)
|