|
@@ -1,4 +1,7 @@
|
|
1
|
+from intelligine.display.Pygame import Pygame
|
|
2
|
+from intelligine.synergy.Environment import Environment
|
1
|
3
|
from intelligine.synergy.object.Food import Food
|
|
4
|
+from intelligine.synergy.object.StockedFood import StockedFood
|
2
|
5
|
from intelligine.tests.simulation.mode.Base import Base
|
3
|
6
|
from intelligine.synergy.Colony import Colony
|
4
|
7
|
from intelligine.synergy.Simulation import Simulation
|
|
@@ -15,8 +18,8 @@ from intelligine.cst import PHEROMON_DIR_EXPLO
|
15
|
18
|
|
16
|
19
|
class TestChangeMode(Base):
|
17
|
20
|
|
18
|
|
- def __init__(self, methodName='runTest'):
|
19
|
|
- super().__init__(methodName)
|
|
21
|
+ def __init__(self, *args, **kwargs):
|
|
22
|
+ super().__init__(*args, **kwargs)
|
20
|
23
|
self.ant = None
|
21
|
24
|
self.food = None
|
22
|
25
|
self._force_move = self._force_move
|
|
@@ -24,12 +27,12 @@ class TestChangeMode(Base):
|
24
|
27
|
@staticmethod
|
25
|
28
|
def _force_move(self_move_action, object_id, context):
|
26
|
29
|
object_movement_mode = context.metas.value.get(MOVE_MODE, object_id)
|
27
|
|
- if object_movement_mode == MOVE_MODE_GOHOME:
|
|
30
|
+ if object_movement_mode == MOVE_MODE_GOHOME or object_movement_mode == MOVE_MODE_HOME:
|
28
|
31
|
return SOUTH
|
29
|
32
|
return NORTH
|
30
|
33
|
|
31
|
34
|
def _get_set_up_simulations(self):
|
32
|
|
- return [Simulation([self._get_colony(), self._get_foods()])]
|
|
35
|
+ return [Simulation([self._get_colony(), self._get_foods(), self._get_environment()])]
|
33
|
36
|
|
34
|
37
|
def _get_colony(self):
|
35
|
38
|
test_case = self
|
|
@@ -63,17 +66,25 @@ class TestChangeMode(Base):
|
63
|
66
|
def get_start_objects(self, collection, context):
|
64
|
67
|
foods = []
|
65
|
68
|
food = Food(collection, context)
|
66
|
|
- food.set_position((0, 0, -3))
|
67
|
|
- # TEST (en attendant d'avoir des algo pour deposer dans un depot)
|
68
|
|
- food1 = Food(collection, context)
|
69
|
|
- food1.set_position((0, 0, -1))
|
70
|
|
- food1.is_takable = lambda: False
|
71
|
|
- foods.append(food1)
|
|
69
|
+ stocked_food = StockedFood(collection, context)
|
|
70
|
+ food.set_position((0, 0, -20))
|
|
71
|
+ stocked_food.set_position((0, 0, 0))
|
|
72
|
+ foods.append(stocked_food)
|
72
|
73
|
foods.append(food)
|
73
|
74
|
test_case.food = food
|
74
|
75
|
return foods
|
75
|
76
|
return FoodConfiguration()
|
76
|
77
|
|
|
78
|
+ def _get_environment(self):
|
|
79
|
+ class TestEnvironment(Environment):
|
|
80
|
+ pass
|
|
81
|
+ return TestEnvironment(self._get_environment_configuration())
|
|
82
|
+
|
|
83
|
+ def _get_environment_configuration(self):
|
|
84
|
+ class TestEnvironmentConfiguration(Configuration):
|
|
85
|
+ pass
|
|
86
|
+ return TestEnvironmentConfiguration()
|
|
87
|
+
|
77
|
88
|
def _get_core_configuration(self, cycles, main_process=True):
|
78
|
89
|
config = super()._get_core_configuration(cycles, main_process)
|
79
|
90
|
config.update({
|
|
@@ -103,8 +114,8 @@ class TestChangeMode(Base):
|
103
|
114
|
self.assertFalse(self.ant.is_carrying())
|
104
|
115
|
|
105
|
116
|
# Ant has take Food piece
|
106
|
|
- self._run_and_get_core(2)
|
107
|
|
- self.assertEquals((0, 0, -2), self.ant.get_position())
|
|
117
|
+ self._run_and_get_core(19)
|
|
118
|
+ self.assertEquals((0, 0, -19), self.ant.get_position())
|
108
|
119
|
self.assertTrue(self.ant.is_carrying())
|
109
|
120
|
self.assertIsNotNone(self.ant.get_carried())
|
110
|
121
|
self.assertEquals(self.food.__class__, self.ant.get_carried().__class__)
|
|
@@ -114,12 +125,25 @@ class TestChangeMode(Base):
|
114
|
125
|
self.assertEquals(MOVE_MODE_GOHOME, self.ant.get_brain().get_movement_mode())
|
115
|
126
|
self.assertEquals(PHEROMON_DIR_EXPLO, self.ant.get_movement_molecule_gland().get_molecule_type())
|
116
|
127
|
|
117
|
|
- self._run_and_get_core(3)
|
118
|
|
- self.assertEquals((0, 0, -1), self.ant.get_position())
|
|
128
|
+ self._run_and_get_core(32)
|
|
129
|
+ self.assertEquals((0, 0, -6), self.ant.get_position())
|
119
|
130
|
self.assertTrue(self.ant.is_carrying())
|
|
131
|
+ self.assertEquals(MOVE_MODE_HOME, self.ant.get_brain().get_movement_mode())
|
120
|
132
|
|
121
|
|
- self._run_and_get_core(4)
|
122
|
|
- self.assertEquals((0, 0, 0), self.ant.get_position())
|
123
|
|
- # Ant has NOT put his food piece
|
|
133
|
+ self._run_and_get_core(33)
|
|
134
|
+ self.assertEquals((0, 0, -5), self.ant.get_position())
|
124
|
135
|
self.assertTrue(self.ant.is_carrying())
|
125
|
|
- # TODO: Le "poser" depend maintenant de matiere où poser. Tests à ecrires.
|
|
136
|
+ self.assertEquals(MOVE_MODE_HOME, self.ant.get_brain().get_movement_mode())
|
|
137
|
+
|
|
138
|
+ self._run_and_get_core(34)
|
|
139
|
+ self.assertEquals((0, 0, -4), self.ant.get_position())
|
|
140
|
+ self.assertEquals(MOVE_MODE_HOME, self.ant.get_brain().get_movement_mode())
|
|
141
|
+
|
|
142
|
+ self._run_and_get_core(37)
|
|
143
|
+ self.assertEquals((0, 0, -1), self.ant.get_position())
|
|
144
|
+ # Ant has NOT put his food piece
|
|
145
|
+ self.assertFalse(self.ant.is_carrying())
|
|
146
|
+
|
|
147
|
+ self._run_and_get_core(38)
|
|
148
|
+ self.assertEquals((0, 0, -2), self.ant.get_position())
|
|
149
|
+ self.assertFalse(self.ant.is_carrying())
|