|
@@ -68,10 +68,17 @@ class TestChangeMode(Base):
|
68
|
68
|
test_case = self
|
69
|
69
|
class FoodConfiguration(Configuration):
|
70
|
70
|
def get_start_objects(self, collection, context):
|
|
71
|
+ foods = []
|
71
|
72
|
food = Food(collection, context)
|
72
|
73
|
food.set_position((0, 0, -3))
|
|
74
|
+ # TEST (en attendant d'avoir des algo pour deposer dans un depot)
|
|
75
|
+ food1 = Food(collection, context)
|
|
76
|
+ food1.set_position((0, 0, -1))
|
|
77
|
+ food1.is_takable = lambda: False
|
|
78
|
+ foods.append(food1)
|
|
79
|
+ foods.append(food)
|
73
|
80
|
test_case.food = food
|
74
|
|
- return [food]
|
|
81
|
+ return foods
|
75
|
82
|
return FoodConfiguration()
|
76
|
83
|
|
77
|
84
|
def _get_core_configuration(self, cycles, main_process=True):
|
|
@@ -81,6 +88,12 @@ class TestChangeMode(Base):
|
81
|
88
|
'classes': {
|
82
|
89
|
'Context': Context
|
83
|
90
|
}
|
|
91
|
+ },
|
|
92
|
+ 'ant': {
|
|
93
|
+ 'take': {
|
|
94
|
+ # Disable this constrain to test in little space
|
|
95
|
+ 'cant_put_still': 0
|
|
96
|
+ }
|
84
|
97
|
}
|
85
|
98
|
})
|
86
|
99
|
return config
|
|
@@ -89,34 +102,32 @@ class TestChangeMode(Base):
|
89
|
102
|
self._run_and_get_core(0)
|
90
|
103
|
self.assertEquals((0, 0, 0), self.ant.get_position())
|
91
|
104
|
self.assertEquals(MOVE_MODE_EXPLO, self.ant.get_brain().get_movement_mode())
|
|
105
|
+ self.assertFalse(self.ant.is_carrying())
|
92
|
106
|
|
93
|
107
|
self._run_and_get_core(1)
|
94
|
108
|
self.assertEquals((0, 0, -1), self.ant.get_position())
|
95
|
109
|
self.assertEquals(MOVE_MODE_EXPLO, self.ant.get_brain().get_movement_mode())
|
|
110
|
+ self.assertFalse(self.ant.is_carrying())
|
96
|
111
|
|
|
112
|
+ # Ant has take Food piece
|
97
|
113
|
self._run_and_get_core(2)
|
98
|
114
|
self.assertEquals((0, 0, -2), self.ant.get_position())
|
|
115
|
+ self.assertTrue(self.ant.is_carrying())
|
|
116
|
+ self.assertIsNotNone(self.ant.get_carried())
|
|
117
|
+ self.assertEquals(self.food.__class__, self.ant.get_carried().__class__)
|
99
|
118
|
pheromone = self.ant.get_movement_pheromone_gland().get_pheromone()
|
|
119
|
+ # Now it appose exploration pheromone
|
100
|
120
|
self.assertEquals((PHEROMON_DIR_EXPLO, 0), (pheromone.get_type(), pheromone.get_distance()))
|
|
121
|
+ self.assertEquals(MOVE_MODE_GOHOME, self.ant.get_brain().get_movement_mode())
|
|
122
|
+ self.assertEquals(PHEROMON_DIR_EXPLO, self.ant.get_movement_pheromone_gland().get_pheromone_type())
|
101
|
123
|
|
102
|
|
- # Ant has take Food piece
|
103
|
124
|
self._run_and_get_core(3)
|
104
|
125
|
self.assertEquals((0, 0, -1), self.ant.get_position())
|
105
|
|
-
|
106
|
126
|
self.assertTrue(self.ant.is_carrying())
|
107
|
|
- self.assertIsNotNone(self.ant.get_carried())
|
108
|
|
- self.assertEquals(self.food.__class__, self.ant.get_carried().__class__)
|
109
|
|
- self.assertEquals(MOVE_MODE_GOHOME, self.ant.get_brain().get_movement_mode())
|
110
|
|
- # Now it appose exploration pheromone
|
111
|
|
- self.assertEquals(PHEROMON_DIR_EXPLO, self.ant.get_movement_pheromone_gland().get_pheromone_type())
|
112
|
127
|
|
113
|
128
|
self._run_and_get_core(4)
|
114
|
129
|
self.assertEquals((0, 0, 0), self.ant.get_position())
|
115
|
|
-
|
116
|
130
|
# Ant has put his food piece
|
117
|
|
- self._run_and_get_core(5)
|
118
|
|
- self.assertEquals((0, 0, -1), self.ant.get_position())
|
119
|
|
-
|
120
|
131
|
self.assertFalse(self.ant.is_carrying())
|
121
|
132
|
self.assertEquals(MOVE_MODE_EXPLO, self.ant.get_brain().get_movement_mode())
|
122
|
133
|
self.assertEquals(PHEROMON_DIR_HOME, self.ant.get_movement_pheromone_gland().get_pheromone_type())
|