|
@@ -3,14 +3,13 @@ from sys import path as ppath
|
3
|
3
|
from intelligine.core.exceptions import NoMolecule
|
4
|
4
|
from intelligine.simulation.molecule.Molecule import Molecule
|
5
|
5
|
from intelligine.simulation.molecule.MoleculeFlavour import MoleculeFlavour
|
6
|
|
-from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
7
|
6
|
|
8
|
7
|
ppath.insert(1,getcwd()+'/modules')
|
9
|
8
|
|
10
|
9
|
from intelligine.tests.simulation.molecule.Base import Base
|
11
|
10
|
from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
|
12
|
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
|
13
|
from intelligine.synergy.event.move.direction import NORTH, NORTH_EST, EST, SOUTH_EST, SOUTH, SOUTH_WEST, WEST, \
|
15
|
14
|
NORTH_WEST, CENTER
|
16
|
15
|
from intelligine.synergy.event.move.direction import get_position_with_direction_decal as _p
|
|
@@ -70,36 +69,36 @@ class TestDirection(Base):
|
70
|
69
|
"""
|
71
|
70
|
test_data = {
|
72
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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,21 +112,21 @@ class TestDirection(Base):
|
113
|
112
|
"""
|
114
|
113
|
test_data = {
|
115
|
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
|
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
|
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,15 +140,15 @@ class TestDirection(Base):
|
141
|
140
|
"""
|
142
|
141
|
test_data = {
|
143
|
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
|
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,11 +158,11 @@ class TestDirection(Base):
|
159
|
158
|
def test_direction_direct(self):
|
160
|
159
|
test_data = {
|
161
|
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
|
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,15 +172,15 @@ class TestDirection(Base):
|
173
|
172
|
def test_direction_with_multiple_intensity(self):
|
174
|
173
|
test_data = {
|
175
|
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
|
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,7 +197,7 @@ class TestDirection(Base):
|
198
|
197
|
# Wrong molecule type
|
199
|
198
|
try: # WTF ?
|
200
|
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
|
201
|
}, -1))
|
203
|
202
|
except NoMolecule:
|
204
|
203
|
self.assertTrue(True)
|
|
@@ -239,4 +238,4 @@ class TestDirection(Base):
|
239
|
238
|
self.assertTrue(True)
|
240
|
239
|
|
241
|
240
|
def _get_molecule(self, type, distance):
|
242
|
|
- return Molecule(PHEROMON_DIRECTION, type, distance=distance)
|
|
241
|
+ return Molecule(MOLECULES_DIRECTION, type, distance=distance)
|