|
|
|
|
3
|
from intelligine.core.exceptions import NoMolecule
|
3
|
from intelligine.core.exceptions import NoMolecule
|
4
|
from intelligine.simulation.molecule.Molecule import Molecule
|
4
|
from intelligine.simulation.molecule.Molecule import Molecule
|
5
|
from intelligine.simulation.molecule.MoleculeFlavour import MoleculeFlavour
|
5
|
from intelligine.simulation.molecule.MoleculeFlavour import MoleculeFlavour
|
6
|
-from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
|
|
7
|
|
6
|
|
8
|
ppath.insert(1,getcwd()+'/modules')
|
7
|
ppath.insert(1,getcwd()+'/modules')
|
9
|
|
8
|
|
10
|
from intelligine.tests.simulation.molecule.Base import Base
|
9
|
from intelligine.tests.simulation.molecule.Base import Base
|
11
|
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
10
|
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
12
|
from intelligine.core.Context import Context
|
11
|
from intelligine.core.Context import Context
|
13
|
-from intelligine.cst import PHEROMON_DIRECTION, PHEROMON_DIR_EXPLO, PHEROMON_DIR_HOME
|
|
|
|
|
12
|
+from intelligine.cst import MOLECULES_DIRECTION, PHEROMON_DIR_EXPLO, PHEROMON_DIR_HOME
|
14
|
from intelligine.synergy.event.move.direction import NORTH, NORTH_EST, EST, SOUTH_EST, SOUTH, SOUTH_WEST, WEST, \
|
13
|
from intelligine.synergy.event.move.direction import NORTH, NORTH_EST, EST, SOUTH_EST, SOUTH, SOUTH_WEST, WEST, \
|
15
|
NORTH_WEST, CENTER
|
14
|
NORTH_WEST, CENTER
|
16
|
from intelligine.synergy.event.move.direction import get_position_with_direction_decal as _p
|
15
|
from intelligine.synergy.event.move.direction import get_position_with_direction_decal as _p
|
|
|
|
|
70
|
"""
|
69
|
"""
|
71
|
test_data = {
|
70
|
test_data = {
|
72
|
NORTH_WEST: {
|
71
|
NORTH_WEST: {
|
73
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
74
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
72
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
73
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
75
|
},
|
74
|
},
|
76
|
NORTH: {
|
75
|
NORTH: {
|
77
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
78
|
- _p(NORTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
76
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
77
|
+ _p(NORTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
79
|
},
|
78
|
},
|
80
|
NORTH_EST: {
|
79
|
NORTH_EST: {
|
81
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
82
|
- _p(NORTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
80
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
81
|
+ _p(NORTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
83
|
},
|
82
|
},
|
84
|
WEST: {
|
83
|
WEST: {
|
85
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
86
|
- _p(WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
84
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
85
|
+ _p(WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
87
|
},
|
86
|
},
|
88
|
EST: {
|
87
|
EST: {
|
89
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
90
|
- _p(EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
88
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
89
|
+ _p(EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
91
|
},
|
90
|
},
|
92
|
SOUTH_WEST: {
|
91
|
SOUTH_WEST: {
|
93
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
94
|
- _p(SOUTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
92
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
93
|
+ _p(SOUTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
95
|
},
|
94
|
},
|
96
|
SOUTH: {
|
95
|
SOUTH: {
|
97
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
98
|
- _p(SOUTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
96
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
97
|
+ _p(SOUTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
99
|
},
|
98
|
},
|
100
|
SOUTH_EST: {
|
99
|
SOUTH_EST: {
|
101
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
102
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
|
|
|
|
100
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
101
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}}
|
103
|
}
|
102
|
}
|
104
|
}
|
103
|
}
|
105
|
|
104
|
|
|
|
|
|
113
|
"""
|
112
|
"""
|
114
|
test_data = {
|
113
|
test_data = {
|
115
|
NORTH_WEST: {
|
114
|
NORTH_WEST: {
|
116
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
117
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
118
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}}
|
|
|
|
|
115
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
116
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
117
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}}
|
119
|
},
|
118
|
},
|
120
|
NORTH_WEST: {
|
119
|
NORTH_WEST: {
|
121
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
122
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
123
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}},
|
|
|
124
|
- _p(SOUTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}}
|
|
|
|
|
120
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
121
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
122
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}},
|
|
|
123
|
+ _p(SOUTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}}
|
125
|
},
|
124
|
},
|
126
|
NORTH_WEST: {
|
125
|
NORTH_WEST: {
|
127
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
128
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
129
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}},
|
|
|
130
|
- _p(SOUTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_HOME: (8, 1)}}
|
|
|
|
|
126
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 1)}},
|
|
|
127
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 1)}},
|
|
|
128
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (12, 1)}},
|
|
|
129
|
+ _p(SOUTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_HOME: (8, 1)}}
|
131
|
},
|
130
|
},
|
132
|
}
|
131
|
}
|
133
|
|
132
|
|
|
|
|
|
141
|
"""
|
140
|
"""
|
142
|
test_data = {
|
141
|
test_data = {
|
143
|
NORTH_WEST: {
|
142
|
NORTH_WEST: {
|
144
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 2)}},
|
|
|
145
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
146
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (8, 1)}}
|
|
|
|
|
143
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 2)}},
|
|
|
144
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
145
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (8, 1)}}
|
147
|
},
|
146
|
},
|
148
|
NORTH_WEST: {
|
147
|
NORTH_WEST: {
|
149
|
- _p(CENTER): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 2)}},
|
|
|
150
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
151
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (8, 1)}},
|
|
|
152
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_HOME: (5, 10)}} # an other molecule type
|
|
|
|
|
148
|
+ _p(CENTER): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (10, 2)}},
|
|
|
149
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
150
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (8, 1)}},
|
|
|
151
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_HOME: (5, 10)}} # an other molecule type
|
153
|
}
|
152
|
}
|
154
|
}
|
153
|
}
|
155
|
|
154
|
|
|
|
|
|
159
|
def test_direction_direct(self):
|
158
|
def test_direction_direct(self):
|
160
|
test_data = {
|
159
|
test_data = {
|
161
|
NORTH: {
|
160
|
NORTH: {
|
162
|
- _p(NORTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}}
|
|
|
|
|
161
|
+ _p(NORTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}}
|
163
|
},
|
162
|
},
|
164
|
NORTH: {
|
163
|
NORTH: {
|
165
|
- _p(NORTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
166
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_HOME: (9, 500)}} # An other molecule type
|
|
|
|
|
164
|
+ _p(NORTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}},
|
|
|
165
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_HOME: (9, 500)}} # An other molecule type
|
167
|
}
|
166
|
}
|
168
|
}
|
167
|
}
|
169
|
|
168
|
|
|
|
|
|
173
|
def test_direction_with_multiple_intensity(self):
|
172
|
def test_direction_with_multiple_intensity(self):
|
174
|
test_data = {
|
173
|
test_data = {
|
175
|
NORTH: {
|
174
|
NORTH: {
|
176
|
- _p(NORTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 5)}},
|
|
|
177
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}},
|
|
|
178
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}}
|
|
|
|
|
175
|
+ _p(NORTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 5)}},
|
|
|
176
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}},
|
|
|
177
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}}
|
179
|
},
|
178
|
},
|
180
|
NORTH: {
|
179
|
NORTH: {
|
181
|
- _p(NORTH): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 5)}},
|
|
|
182
|
- _p(WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_HOME: (9, 500)}}, # An other molecule_type
|
|
|
183
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}},
|
|
|
184
|
- _p(NORTH_WEST): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}}
|
|
|
|
|
180
|
+ _p(NORTH): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 5)}},
|
|
|
181
|
+ _p(WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_HOME: (9, 500)}}, # An other molecule_type
|
|
|
182
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}},
|
|
|
183
|
+ _p(NORTH_WEST): {MOLECULES_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}}
|
185
|
}
|
184
|
}
|
186
|
}
|
185
|
}
|
187
|
|
186
|
|
|
|
|
|
198
|
# Wrong molecule type
|
197
|
# Wrong molecule type
|
199
|
try: # WTF ?
|
198
|
try: # WTF ?
|
200
|
self.assertRaises(NoMolecule, self._test_direction_for_points({
|
199
|
self.assertRaises(NoMolecule, self._test_direction_for_points({
|
201
|
- _p(SOUTH_EST): {PHEROMON_DIRECTION: {PHEROMON_DIR_HOME: (9, 5)}}
|
|
|
|
|
200
|
+ _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_HOME: (9, 5)}}
|
202
|
}, -1))
|
201
|
}, -1))
|
203
|
except NoMolecule:
|
202
|
except NoMolecule:
|
204
|
self.assertTrue(True)
|
203
|
self.assertTrue(True)
|
|
|
|
|
239
|
self.assertTrue(True)
|
238
|
self.assertTrue(True)
|
240
|
|
239
|
|
241
|
def _get_molecule(self, type, distance):
|
240
|
def _get_molecule(self, type, distance):
|
242
|
- return Molecule(PHEROMON_DIRECTION, type, distance=distance)
|
|
|
|
|
241
|
+ return Molecule(MOLECULES_DIRECTION, type, distance=distance)
|