|
@@ -1,8 +1,9 @@
|
1
|
1
|
# coding: utf-8
|
|
2
|
+import typing
|
2
|
3
|
from random import choice
|
3
|
4
|
|
4
|
5
|
from sandbox.engulf.const import COLLECTION_GRASS
|
5
|
|
-from synergine2.simulation import SubjectBehaviour, SimulationMechanism, SimulationBehaviour
|
|
6
|
+from synergine2.simulation import SubjectBehaviour, SimulationMechanism, SimulationBehaviour, SubjectBehaviourSelector
|
6
|
7
|
from synergine2.simulation import Event
|
7
|
8
|
from synergine2.utils import ChunkManager
|
8
|
9
|
from synergine2.xyz import ProximitySubjectMechanism, DIRECTIONS, DIRECTION_SLIGHTLY
|
|
@@ -179,3 +180,20 @@ class Explore(SubjectBehaviour):
|
179
|
180
|
if not self.subject.previous_direction:
|
180
|
181
|
return choice(DIRECTIONS)
|
181
|
182
|
return choice(DIRECTION_SLIGHTLY[self.subject.previous_direction])
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+class CellBehaviourSelector(SubjectBehaviourSelector):
|
|
186
|
+ # If behaviour in sublist, only one be kept in sublist
|
|
187
|
+ behaviour_hierarchy = ( # TODO: refact it
|
|
188
|
+ (
|
|
189
|
+ Eat,
|
|
190
|
+ SearchFood,
|
|
191
|
+ Explore,
|
|
192
|
+ ),
|
|
193
|
+ )
|
|
194
|
+
|
|
195
|
+ def reduce_behaviours(
|
|
196
|
+ self,
|
|
197
|
+ behaviours: typing.Dict[typing.Type[SubjectBehaviour], dict],
|
|
198
|
+ ) -> typing.Dict[typing.Type[SubjectBehaviour], dict]:
|
|
199
|
+ return behaviours # TODO: code it
|