1 | #include "core/CoreIncludes.h" |
---|
2 | #include "core/XMLPort.h" |
---|
3 | #include "getShortestPath.h" |
---|
4 | |
---|
5 | |
---|
6 | #include "worldentities/ControllableEntity.h" |
---|
7 | using namespace std; |
---|
8 | |
---|
9 | namespace orxonox{ |
---|
10 | |
---|
11 | //Check if there is a collision |
---|
12 | bool jeanfindpos(Vector3 one, Vector3 other){ |
---|
13 | if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; |
---|
14 | return false; |
---|
15 | } |
---|
16 | |
---|
17 | struct graphVertex; |
---|
18 | void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]); |
---|
19 | void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor); |
---|
20 | graphVertex findNextVertexToConsider(graphVertex[]); |
---|
21 | struct graphVertex { |
---|
22 | |
---|
23 | Vector3 position; |
---|
24 | graphVertex *adjacentVertices[4]; //neighbooring vertices |
---|
25 | |
---|
26 | //would a vector of vector storing the neighboors not be more suitable ? |
---|
27 | |
---|
28 | int shortestDistanceToStart; //actual shortest distance to start point |
---|
29 | graphVertex* actuelPredecessor; //the predecessor giving the for now shortest |
---|
30 | //path to start |
---|
31 | graphVertex* currentNearestNonVisitedNeighboor; |
---|
32 | bool alreadyVisited; |
---|
33 | graphVertex(){ //default constructor |
---|
34 | position=0; |
---|
35 | shortestDistanceToStart= std::numeric_limits<int>::max(); |
---|
36 | actuelPredecessor=NULL; |
---|
37 | alreadyVisited=false; |
---|
38 | for(int kl =0; kl <4;kl++){ |
---|
39 | adjacentVertices[kl]=NULL; //first put all position in array listing neighboors to 0 |
---|
40 | } |
---|
41 | } |
---|
42 | graphVertex(Vector3 wantedPosition){ //normal constructor |
---|
43 | position=wantedPosition; |
---|
44 | shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity |
---|
45 | actuelPredecessor=NULL; |
---|
46 | alreadyVisited=false; |
---|
47 | for(int kl =0; kl <4;kl++){ |
---|
48 | adjacentVertices[kl]=NULL; //first put all position in array listing neighboors to 0 |
---|
49 | } |
---|
50 | } |
---|
51 | graphVertex* operator = (graphVertex *rightSide){ |
---|
52 | this->position=rightSide->position; |
---|
53 | this->actuelPredecessor=rightSide->actuelPredecessor; |
---|
54 | return this; |
---|
55 | } |
---|
56 | |
---|
57 | }; |
---|
58 | |
---|
59 | |
---|
60 | Vector3 getShortestPath(Vector3 start, Vector3 goal){ |
---|
61 | //this function should then somehow produce the algorithm and call all other functions |
---|
62 | //and finally return the best neighboor of the actual position of the pacman |
---|
63 | |
---|
64 | |
---|
65 | if(start==goal){ // basic case |
---|
66 | return start; |
---|
67 | } |
---|
68 | |
---|
69 | //All positions in the map, see documentation |
---|
70 | Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 |
---|
71 | Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 |
---|
72 | Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 |
---|
73 | Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 |
---|
74 | Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 |
---|
75 | Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 |
---|
76 | Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 |
---|
77 | Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39 |
---|
78 | Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44 |
---|
79 | Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49 |
---|
80 | Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54 |
---|
81 | Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59 |
---|
82 | Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64 |
---|
83 | Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 |
---|
84 | |
---|
85 | graphVertex listOfVertices[67]= { graphVertex()}; //list of all vertices in the map. // We need graphVertex() |
---|
86 | |
---|
87 | |
---|
88 | for(int an=0; an < 67; an++){ |
---|
89 | listOfVertices[an]= graphVertex(possibleposition[an]); //same position order as in other file |
---|
90 | } |
---|
91 | |
---|
92 | graphVertex actualVertex; |
---|
93 | |
---|
94 | actualVertex.alreadyVisited=true; |
---|
95 | actualVertex.shortestDistanceToStart=0; |
---|
96 | findNeighboorVertices(actualVertex.position, *actualVertex.adjacentVertices); |
---|
97 | // second parameter is an array ! |
---|
98 | |
---|
99 | while(actualVertex.position!=goal){ |
---|
100 | for(int h=0;h < 4; h++){ |
---|
101 | if(actualVertex.adjacentVertices[h]!=NULL){ |
---|
102 | updateShortestDistanceToStart(actualVertex, *actualVertex.adjacentVertices[h]); |
---|
103 | } //we "update" the neighboors of our new visited vertex |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | actualVertex=findNextVertexToConsider(listOfVertices); |
---|
108 | actualVertex.alreadyVisited=true; |
---|
109 | if(actualVertex.position!=goal){ |
---|
110 | findNeighboorVertices(actualVertex.position,*actualVertex.adjacentVertices); |
---|
111 | //we find the neighboors of our new visited vertex |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | //we should have reached our goal at this point |
---|
116 | |
---|
117 | while(actualVertex.actuelPredecessor->actuelPredecessor!=NULL){ |
---|
118 | actualVertex=actualVertex.actuelPredecessor; |
---|
119 | } |
---|
120 | // the predecessor is our starting point, in other words we are now on an |
---|
121 | //adjacent vertex of the start |
---|
122 | |
---|
123 | return actualVertex.position; //we return the position of this adjacent vertex |
---|
124 | } |
---|
125 | |
---|
126 | int graphDistance(Vector3 start, Vector3 goal){ |
---|
127 | |
---|
128 | Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); |
---|
129 | |
---|
130 | return differenceVector.x+differenceVector.z; |
---|
131 | } |
---|
132 | |
---|
133 | void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ |
---|
134 | //apply this method to all non visited neighboors of a vertex. |
---|
135 | // This method should always be run on a vertex after we marked it as visited. |
---|
136 | if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. |
---|
137 | if(neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + |
---|
138 | graphDistance(vertex.position, neighboor.position)){ |
---|
139 | |
---|
140 | neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + |
---|
141 | graphDistance(vertex.position, neighboor.position); |
---|
142 | neighboor.actuelPredecessor = &vertex; |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | void findNearestNonVisitedNeighboor (graphVertex &vertex){ |
---|
149 | //find nearest non visited neighboor of a given already visited vertex |
---|
150 | int shortestDistance = -1; |
---|
151 | graphVertex nearestNonVisitedNeighboor=graphVertex(); //by default there is not any. |
---|
152 | //Also, if all neighboors are already visited, we return NULL, i.e. there is no |
---|
153 | //nearest non visited neighboor. |
---|
154 | for(int i=0; i < 4; i++){ |
---|
155 | if((vertex.adjacentVertices[i]!=NULL)&&(vertex.adjacentVertices[i]->alreadyVisited==false)){ |
---|
156 | if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor |
---|
157 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
158 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; |
---|
159 | } |
---|
160 | else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ |
---|
161 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
162 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; |
---|
163 | } |
---|
164 | } |
---|
165 | } |
---|
166 | vertex.currentNearestNonVisitedNeighboor = &nearestNonVisitedNeighboor; |
---|
167 | } |
---|
168 | |
---|
169 | |
---|
170 | graphVertex findNextVertexToConsider(graphVertex listOfVertices[]){ //find next, nearest from start, non visited vertex |
---|
171 | |
---|
172 | int shortestDistance = -1; |
---|
173 | graphVertex nextVertexToConsider; |
---|
174 | |
---|
175 | for(int i=0; i < 67; i++){ //we loop over all possible positions |
---|
176 | |
---|
177 | if(listOfVertices[i].alreadyVisited==true){ //vertex should already be visited |
---|
178 | |
---|
179 | findNearestNonVisitedNeighboor(listOfVertices[i]); //we update nearest neighboor |
---|
180 | //of all visited vertices given that one of the nearest neighboor of a visited |
---|
181 | // vertex is now also visited because it was chosen as next optimal vertex |
---|
182 | |
---|
183 | if(listOfVertices[i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate! |
---|
184 | if(shortestDistance==-1){ //our first possible candidate |
---|
185 | |
---|
186 | shortestDistance=graphDistance(listOfVertices[i].position, |
---|
187 | listOfVertices[i].currentNearestNonVisitedNeighboor->position) + |
---|
188 | listOfVertices[i].shortestDistanceToStart; |
---|
189 | |
---|
190 | nextVertexToConsider=listOfVertices[i].currentNearestNonVisitedNeighboor; |
---|
191 | |
---|
192 | } |
---|
193 | else if(shortestDistance > graphDistance(listOfVertices[i].position, |
---|
194 | listOfVertices[i].currentNearestNonVisitedNeighboor->position) + |
---|
195 | listOfVertices[i].shortestDistanceToStart){ |
---|
196 | |
---|
197 | shortestDistance=graphDistance(listOfVertices[i].position, |
---|
198 | listOfVertices[i].currentNearestNonVisitedNeighboor->position) + |
---|
199 | listOfVertices[i].shortestDistanceToStart; |
---|
200 | |
---|
201 | nextVertexToConsider=listOfVertices[i].currentNearestNonVisitedNeighboor; |
---|
202 | } |
---|
203 | } |
---|
204 | } |
---|
205 | //we want after all to return the nearest non visited neighboor |
---|
206 | } |
---|
207 | |
---|
208 | return nextVertexToConsider; |
---|
209 | } |
---|
210 | |
---|
211 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
212 | |
---|
213 | //if vertex already visited, call function on it and reapeat until you reach non visited vertex |
---|
214 | // ---> not sure if a good idea because we risk infinite loop |
---|
215 | |
---|
216 | //-215 -185 -135 -70 -20 0 20 70 135 185 215 |
---|
217 | |
---|
218 | //-195 -135 -85 -35 15 60 105 150 195 245 |
---|
219 | |
---|
220 | void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]){ |
---|
221 | |
---|
222 | //All positions in the map, see documentation |
---|
223 | Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 |
---|
224 | Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 |
---|
225 | Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 |
---|
226 | Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 |
---|
227 | Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 |
---|
228 | Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 |
---|
229 | Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 |
---|
230 | Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39 |
---|
231 | Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44 |
---|
232 | Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49 |
---|
233 | Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54 |
---|
234 | Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59 |
---|
235 | Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64 |
---|
236 | Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | if(jeanfindpos(actuelposition,possibleposition[0])){ |
---|
242 | // we should use listOfVertices[i] instead of possibleposition[i] I think |
---|
243 | // so that all neighboors are "the same" |
---|
244 | adjacentVertices[0]=graphVertex(possibleposition[1]); //need to do it everywhere !!! |
---|
245 | adjacentVertices[1]=graphVertex(possibleposition[17]); |
---|
246 | adjacentVertices[2]=possibleposition[19]; //maybe a vector would be more suitable ? |
---|
247 | } |
---|
248 | else if(jeanfindpos(actuelposition,possibleposition[1])){ |
---|
249 | adjacentVertices[0]=possibleposition[0]; |
---|
250 | adjacentVertices[1]=possibleposition[2]; |
---|
251 | } |
---|
252 | else if(jeanfindpos(actuelposition,possibleposition[2])){ |
---|
253 | adjacentVertices[0]=possibleposition[1]; |
---|
254 | adjacentVertices[1]=possibleposition[3]; |
---|
255 | } |
---|
256 | else if(jeanfindpos(actuelposition,possibleposition[3])){ |
---|
257 | adjacentVertices[0]=possibleposition[2]; |
---|
258 | adjacentVertices[1]=possibleposition[4]; |
---|
259 | adjacentVertices[2]=possibleposition[5]; |
---|
260 | } |
---|
261 | else if(jeanfindpos(actuelposition,possibleposition[4])){ |
---|
262 | adjacentVertices[0]=possibleposition[3]; |
---|
263 | adjacentVertices[1]=possibleposition[6]; |
---|
264 | } |
---|
265 | else if(jeanfindpos(actuelposition,possibleposition[5])){ |
---|
266 | adjacentVertices[0]=possibleposition[3]; |
---|
267 | adjacentVertices[1]=possibleposition[7]; |
---|
268 | } |
---|
269 | else if(jeanfindpos(actuelposition,possibleposition[6])){ |
---|
270 | adjacentVertices[0]=possibleposition[4]; |
---|
271 | adjacentVertices[1]=possibleposition[9]; |
---|
272 | adjacentVertices[2]=possibleposition[26]; |
---|
273 | } |
---|
274 | else if(jeanfindpos(actuelposition,possibleposition[7])){ |
---|
275 | adjacentVertices[0]=possibleposition[5]; |
---|
276 | adjacentVertices[1]=possibleposition[8]; |
---|
277 | } |
---|
278 | else if(jeanfindpos(actuelposition,possibleposition[8])){ |
---|
279 | adjacentVertices[0]=possibleposition[7]; |
---|
280 | adjacentVertices[1]=possibleposition[9]; |
---|
281 | } |
---|
282 | else if(jeanfindpos(actuelposition,possibleposition[9])){ |
---|
283 | adjacentVertices[0]=possibleposition[6]; |
---|
284 | adjacentVertices[1]=possibleposition[8]; |
---|
285 | adjacentVertices[2]=possibleposition[10]; |
---|
286 | adjacentVertices[3]=possibleposition[38]; |
---|
287 | } |
---|
288 | else if(jeanfindpos(actuelposition,possibleposition[10])){ |
---|
289 | adjacentVertices[0]=possibleposition[9]; |
---|
290 | adjacentVertices[1]=possibleposition[11]; |
---|
291 | adjacentVertices[2]=possibleposition[45]; |
---|
292 | } |
---|
293 | else if(jeanfindpos(actuelposition,possibleposition[11])){ |
---|
294 | adjacentVertices[0]=possibleposition[10]; |
---|
295 | adjacentVertices[1]=possibleposition[12]; |
---|
296 | adjacentVertices[2]=possibleposition[13]; |
---|
297 | } |
---|
298 | else if(jeanfindpos(actuelposition,possibleposition[12])){ |
---|
299 | adjacentVertices[0]=possibleposition[11]; |
---|
300 | adjacentVertices[1]=possibleposition[14]; |
---|
301 | } |
---|
302 | else if(jeanfindpos(actuelposition,possibleposition[13])){ |
---|
303 | adjacentVertices[0]=possibleposition[11]; |
---|
304 | adjacentVertices[1]=possibleposition[14]; |
---|
305 | adjacentVertices[2]=possibleposition[16]; |
---|
306 | adjacentVertices[3]=possibleposition[61]; |
---|
307 | } |
---|
308 | else if(jeanfindpos(actuelposition,possibleposition[14])){ |
---|
309 | adjacentVertices[0]=possibleposition[12]; |
---|
310 | adjacentVertices[1]=possibleposition[13]; |
---|
311 | adjacentVertices[2]=possibleposition[15]; |
---|
312 | } |
---|
313 | else if(jeanfindpos(actuelposition,possibleposition[15])){ |
---|
314 | adjacentVertices[0]=possibleposition[14]; |
---|
315 | adjacentVertices[1]=possibleposition[16]; |
---|
316 | } |
---|
317 | else if(jeanfindpos(actuelposition,possibleposition[16])){ |
---|
318 | adjacentVertices[0]=possibleposition[13]; |
---|
319 | adjacentVertices[1]=possibleposition[15]; |
---|
320 | adjacentVertices[2]=possibleposition[62]; |
---|
321 | } |
---|
322 | else if(jeanfindpos(actuelposition,possibleposition[17])){ |
---|
323 | adjacentVertices[0]=possibleposition[0]; |
---|
324 | adjacentVertices[1]=possibleposition[25]; |
---|
325 | } |
---|
326 | else if(jeanfindpos(actuelposition,possibleposition[18])){ |
---|
327 | adjacentVertices[0]=possibleposition[19]; |
---|
328 | adjacentVertices[1]=possibleposition[24]; |
---|
329 | } |
---|
330 | else if(jeanfindpos(actuelposition,possibleposition[19])){ |
---|
331 | adjacentVertices[0]=possibleposition[0]; |
---|
332 | adjacentVertices[1]=possibleposition[18]; |
---|
333 | adjacentVertices[2]=possibleposition[20]; |
---|
334 | } |
---|
335 | else if(jeanfindpos(actuelposition,possibleposition[20])){ |
---|
336 | adjacentVertices[0]=possibleposition[19]; |
---|
337 | adjacentVertices[1]=possibleposition[21]; |
---|
338 | } |
---|
339 | else if(jeanfindpos(actuelposition,possibleposition[21])){ |
---|
340 | adjacentVertices[0]=possibleposition[20]; |
---|
341 | adjacentVertices[1]=possibleposition[22]; |
---|
342 | } |
---|
343 | else if(jeanfindpos(actuelposition,possibleposition[22])){ |
---|
344 | adjacentVertices[0]=possibleposition[21]; |
---|
345 | adjacentVertices[1]=possibleposition[23]; |
---|
346 | adjacentVertices[2]=possibleposition[31]; |
---|
347 | } |
---|
348 | else if(jeanfindpos(actuelposition,possibleposition[23])){ |
---|
349 | adjacentVertices[0]=possibleposition[22]; |
---|
350 | adjacentVertices[1]=possibleposition[30]; |
---|
351 | } |
---|
352 | else if(jeanfindpos(actuelposition,possibleposition[24])){ |
---|
353 | adjacentVertices[0]=possibleposition[18]; |
---|
354 | adjacentVertices[1]=possibleposition[29]; |
---|
355 | } |
---|
356 | else if(jeanfindpos(actuelposition,possibleposition[25])){ |
---|
357 | adjacentVertices[0]=possibleposition[17]; |
---|
358 | adjacentVertices[1]=possibleposition[26]; |
---|
359 | } |
---|
360 | else if(jeanfindpos(actuelposition,possibleposition[26])){ |
---|
361 | adjacentVertices[0]=possibleposition[6]; |
---|
362 | adjacentVertices[1]=possibleposition[25]; |
---|
363 | adjacentVertices[2]=possibleposition[27]; |
---|
364 | } |
---|
365 | else if(jeanfindpos(actuelposition,possibleposition[27])){ |
---|
366 | adjacentVertices[0]=possibleposition[26]; |
---|
367 | adjacentVertices[1]=possibleposition[28]; |
---|
368 | adjacentVertices[2]=possibleposition[37]; |
---|
369 | } |
---|
370 | else if(jeanfindpos(actuelposition,possibleposition[28])){ |
---|
371 | adjacentVertices[0]=possibleposition[27]; |
---|
372 | adjacentVertices[1]=possibleposition[29]; |
---|
373 | adjacentVertices[2]=possibleposition[36]; |
---|
374 | } |
---|
375 | else if(jeanfindpos(actuelposition,possibleposition[29])){ |
---|
376 | adjacentVertices[0]=possibleposition[24]; |
---|
377 | adjacentVertices[1]=possibleposition[28]; |
---|
378 | adjacentVertices[2]=possibleposition[30]; |
---|
379 | } |
---|
380 | else if(jeanfindpos(actuelposition,possibleposition[30])){ |
---|
381 | adjacentVertices[0]=possibleposition[23]; |
---|
382 | adjacentVertices[1]=possibleposition[29]; |
---|
383 | adjacentVertices[2]=possibleposition[34]; |
---|
384 | } |
---|
385 | else if(jeanfindpos(actuelposition,possibleposition[31])){ |
---|
386 | adjacentVertices[0]=possibleposition[22]; |
---|
387 | adjacentVertices[1]=possibleposition[32]; |
---|
388 | } |
---|
389 | else if(jeanfindpos(actuelposition,possibleposition[32])){ |
---|
390 | adjacentVertices[0]=possibleposition[31]; |
---|
391 | adjacentVertices[1]=possibleposition[33]; |
---|
392 | } |
---|
393 | else if(jeanfindpos(actuelposition,possibleposition[33])){ |
---|
394 | adjacentVertices[0]=possibleposition[32]; |
---|
395 | adjacentVertices[1]=possibleposition[34]; |
---|
396 | } |
---|
397 | else if(jeanfindpos(actuelposition,possibleposition[34])){ |
---|
398 | adjacentVertices[0]=possibleposition[30]; |
---|
399 | adjacentVertices[1]=possibleposition[33]; |
---|
400 | adjacentVertices[2]=possibleposition[35]; |
---|
401 | adjacentVertices[3]=possibleposition[42]; |
---|
402 | |
---|
403 | } |
---|
404 | else if(jeanfindpos(actuelposition,possibleposition[35])){ |
---|
405 | adjacentVertices[0]=possibleposition[34]; |
---|
406 | adjacentVertices[1]=possibleposition[36]; |
---|
407 | adjacentVertices[2]=possibleposition[41]; |
---|
408 | } |
---|
409 | else if(jeanfindpos(actuelposition,possibleposition[36])){ |
---|
410 | adjacentVertices[0]=possibleposition[28]; |
---|
411 | adjacentVertices[1]=possibleposition[35]; |
---|
412 | } |
---|
413 | else if(jeanfindpos(actuelposition,possibleposition[37])){ |
---|
414 | adjacentVertices[0]=possibleposition[27]; |
---|
415 | adjacentVertices[1]=possibleposition[38]; |
---|
416 | } |
---|
417 | else if(jeanfindpos(actuelposition,possibleposition[38])){ |
---|
418 | adjacentVertices[0]=possibleposition[9]; |
---|
419 | adjacentVertices[1]=possibleposition[37]; |
---|
420 | adjacentVertices[2]=possibleposition[39]; |
---|
421 | } |
---|
422 | else if(jeanfindpos(actuelposition,possibleposition[39])){ |
---|
423 | adjacentVertices[0]=possibleposition[38]; |
---|
424 | adjacentVertices[1]=possibleposition[40]; |
---|
425 | adjacentVertices[2]=possibleposition[45]; |
---|
426 | } |
---|
427 | else if(jeanfindpos(actuelposition,possibleposition[40])){ |
---|
428 | adjacentVertices[0]=possibleposition[39]; |
---|
429 | adjacentVertices[1]=possibleposition[41]; |
---|
430 | } |
---|
431 | else if(jeanfindpos(actuelposition,possibleposition[41])){ |
---|
432 | adjacentVertices[0]=possibleposition[35]; |
---|
433 | adjacentVertices[1]=possibleposition[43]; |
---|
434 | } |
---|
435 | else if(jeanfindpos(actuelposition,possibleposition[42])){ |
---|
436 | adjacentVertices[0]=possibleposition[34]; |
---|
437 | adjacentVertices[1]=possibleposition[43]; |
---|
438 | adjacentVertices[2]=possibleposition[54]; |
---|
439 | } |
---|
440 | else if(jeanfindpos(actuelposition,possibleposition[43])){ |
---|
441 | adjacentVertices[0]=possibleposition[41]; |
---|
442 | adjacentVertices[1]=possibleposition[46]; |
---|
443 | } |
---|
444 | else if(jeanfindpos(actuelposition,possibleposition[44])){ |
---|
445 | adjacentVertices[0]=possibleposition[40]; |
---|
446 | adjacentVertices[1]=possibleposition[66]; |
---|
447 | } |
---|
448 | else if(jeanfindpos(actuelposition,possibleposition[45])){ |
---|
449 | adjacentVertices[0]=possibleposition[10]; |
---|
450 | adjacentVertices[1]=possibleposition[39]; |
---|
451 | adjacentVertices[2]=possibleposition[49]; |
---|
452 | } |
---|
453 | else if(jeanfindpos(actuelposition,possibleposition[46])){ |
---|
454 | adjacentVertices[0]=possibleposition[43]; |
---|
455 | adjacentVertices[1]=possibleposition[47]; |
---|
456 | } |
---|
457 | else if(jeanfindpos(actuelposition,possibleposition[47])){ |
---|
458 | adjacentVertices[0]=possibleposition[46]; |
---|
459 | adjacentVertices[1]=possibleposition[52]; |
---|
460 | adjacentVertices[2]=possibleposition[66]; |
---|
461 | } |
---|
462 | else if(jeanfindpos(actuelposition,possibleposition[48])){ |
---|
463 | adjacentVertices[0]=possibleposition[49]; |
---|
464 | adjacentVertices[1]=possibleposition[51]; |
---|
465 | adjacentVertices[2]=possibleposition[66]; |
---|
466 | } |
---|
467 | else if(jeanfindpos(actuelposition,possibleposition[49])){ |
---|
468 | adjacentVertices[0]=possibleposition[45]; |
---|
469 | adjacentVertices[1]=possibleposition[48]; |
---|
470 | } |
---|
471 | else if(jeanfindpos(actuelposition,possibleposition[50])){ |
---|
472 | adjacentVertices[0]=possibleposition[51]; |
---|
473 | adjacentVertices[1]=possibleposition[61]; |
---|
474 | } |
---|
475 | else if(jeanfindpos(actuelposition,possibleposition[51])){ |
---|
476 | adjacentVertices[0]=possibleposition[48]; |
---|
477 | adjacentVertices[1]=possibleposition[50]; |
---|
478 | } |
---|
479 | else if(jeanfindpos(actuelposition,possibleposition[52])){ |
---|
480 | adjacentVertices[0]=possibleposition[47]; |
---|
481 | adjacentVertices[1]=possibleposition[53]; |
---|
482 | } |
---|
483 | else if(jeanfindpos(actuelposition,possibleposition[53])){ |
---|
484 | adjacentVertices[0]=possibleposition[52]; |
---|
485 | adjacentVertices[1]=possibleposition[58]; |
---|
486 | } |
---|
487 | else if(jeanfindpos(actuelposition,possibleposition[54])){ |
---|
488 | adjacentVertices[0]=possibleposition[42]; |
---|
489 | adjacentVertices[1]=possibleposition[55]; |
---|
490 | adjacentVertices[2]=possibleposition[57]; |
---|
491 | } |
---|
492 | else if(jeanfindpos(actuelposition,possibleposition[55])){ |
---|
493 | adjacentVertices[0]=possibleposition[54]; |
---|
494 | adjacentVertices[1]=possibleposition[56]; |
---|
495 | } |
---|
496 | else if(jeanfindpos(actuelposition,possibleposition[56])){ |
---|
497 | adjacentVertices[0]=possibleposition[55]; |
---|
498 | adjacentVertices[1]=possibleposition[57]; |
---|
499 | adjacentVertices[2]=possibleposition[65]; |
---|
500 | } |
---|
501 | else if(jeanfindpos(actuelposition,possibleposition[57])){ |
---|
502 | adjacentVertices[0]=possibleposition[54]; |
---|
503 | adjacentVertices[1]=possibleposition[56]; |
---|
504 | adjacentVertices[2]=possibleposition[58]; |
---|
505 | adjacentVertices[3]=possibleposition[64]; |
---|
506 | |
---|
507 | } |
---|
508 | else if(jeanfindpos(actuelposition,possibleposition[58])){ |
---|
509 | adjacentVertices[0]=possibleposition[53]; |
---|
510 | adjacentVertices[1]=possibleposition[57]; |
---|
511 | adjacentVertices[2]=possibleposition[59]; |
---|
512 | } |
---|
513 | else if(jeanfindpos(actuelposition,possibleposition[59])){ |
---|
514 | adjacentVertices[0]=possibleposition[58]; |
---|
515 | adjacentVertices[1]=possibleposition[59]; |
---|
516 | adjacentVertices[2]=possibleposition[63]; |
---|
517 | } |
---|
518 | else if(jeanfindpos(actuelposition,possibleposition[60])){ |
---|
519 | adjacentVertices[0]=possibleposition[59]; |
---|
520 | adjacentVertices[1]=possibleposition[61]; |
---|
521 | adjacentVertices[2]=possibleposition[62]; |
---|
522 | } |
---|
523 | else if(jeanfindpos(actuelposition,possibleposition[61])){ |
---|
524 | adjacentVertices[0]=possibleposition[13]; |
---|
525 | adjacentVertices[1]=possibleposition[50]; |
---|
526 | adjacentVertices[2]=possibleposition[60]; |
---|
527 | } |
---|
528 | else if(jeanfindpos(actuelposition,possibleposition[62])){ |
---|
529 | adjacentVertices[0]=possibleposition[16]; |
---|
530 | adjacentVertices[1]=possibleposition[60]; |
---|
531 | } |
---|
532 | else if(jeanfindpos(actuelposition,possibleposition[63])){ |
---|
533 | adjacentVertices[0]=possibleposition[59]; |
---|
534 | adjacentVertices[1]=possibleposition[64]; |
---|
535 | } |
---|
536 | else if(jeanfindpos(actuelposition,possibleposition[64])){ |
---|
537 | adjacentVertices[0]=possibleposition[57]; |
---|
538 | adjacentVertices[1]=possibleposition[63]; |
---|
539 | adjacentVertices[2]=possibleposition[65]; |
---|
540 | } |
---|
541 | else if(jeanfindpos(actuelposition,possibleposition[65])){ |
---|
542 | adjacentVertices[0]=possibleposition[56]; |
---|
543 | adjacentVertices[1]=possibleposition[64]; |
---|
544 | } |
---|
545 | else if(jeanfindpos(actuelposition,possibleposition[66])){ |
---|
546 | adjacentVertices[0]=possibleposition[47]; |
---|
547 | adjacentVertices[1]=possibleposition[48]; |
---|
548 | } |
---|
549 | } |
---|
550 | |
---|
551 | } |
---|