|
@@ -20,12 +20,13 @@ Engulf is simulation containing:
|
20
|
20
|
"""
|
21
|
21
|
from random import randint
|
22
|
22
|
|
23
|
|
-from sandbox.engulf.subject import Cell, Grass
|
|
23
|
+from sandbox.engulf.subject import Cell, Grass, COLLECTION_GRASS
|
24
|
24
|
from synergine2.core import Core
|
25
|
25
|
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
|
30
|
|
30
|
31
|
|
31
|
32
|
class Engulf(Simulation):
|
|
@@ -78,7 +79,7 @@ def fill_with_random_grass(
|
78
|
79
|
start_count: int,
|
79
|
80
|
start_position: tuple,
|
80
|
81
|
end_position: tuple,
|
81
|
|
- density: int=10,
|
|
82
|
+ density: int=5,
|
82
|
83
|
) -> None:
|
83
|
84
|
grasses = []
|
84
|
85
|
|
|
@@ -88,6 +89,7 @@ def fill_with_random_grass(
|
88
|
89
|
randint(start_position[1], end_position[1]+1),
|
89
|
90
|
randint(start_position[2], end_position[2]+1),
|
90
|
91
|
)
|
|
92
|
+
|
91
|
93
|
if position not in subjects.grass_xyz:
|
92
|
94
|
grass = Grass(
|
93
|
95
|
simulation=subjects.simulation,
|
|
@@ -96,7 +98,17 @@ def fill_with_random_grass(
|
96
|
98
|
grasses.append(grass)
|
97
|
99
|
subjects.append(grass)
|
98
|
100
|
|
99
|
|
- # TODO: density
|
|
101
|
+ for grass in subjects.simulation.collections[COLLECTION_GRASS][:]:
|
|
102
|
+ a = 1
|
|
103
|
+ for around in get_around_positions_of(grass.position, distance=density):
|
|
104
|
+ if around not in subjects.grass_xyz:
|
|
105
|
+ grass = Grass(
|
|
106
|
+ simulation=subjects.simulation,
|
|
107
|
+ position=around,
|
|
108
|
+ )
|
|
109
|
+ grasses.append(grass)
|
|
110
|
+ subjects.append(grass)
|
|
111
|
+ # TODO: valeur nutritive regressive avec eloignement
|
100
|
112
|
|
101
|
113
|
|
102
|
114
|
def main():
|