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