- Timestamp:
- Apr 18, 2019, 1:26:10 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.cc
r12293 r12304 1 1 #include "core/CoreIncludes.h" 2 2 #include "core/XMLPort.h" 3 #include "getShortestPath.h" 3 //#include "getShortestPath.h" 4 #include "PacmanGhost.h" 4 5 5 6 … … 9 10 namespace orxonox{ 10 11 11 //Check if there is a collision12 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 12 struct graphVertex { 22 13 … … 57 48 }; 58 49 50 graphVertex listOfVertices[67]; 59 51 60 52 Vector3 getShortestPath(Vector3 start, Vector3 goal){ … … 66 58 return start; 67 59 } 68 69 //All positions in the map, see documentation70 Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-471 Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-972 Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-1473 Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-1974 Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-2475 Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-2976 Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-3477 Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-3978 Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-4479 Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-4980 Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-5481 Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-5982 Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-6483 Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-6684 85 graphVertex listOfVertices[67]= { graphVertex()}; //list of all vertices in the map. // We need graphVertex()86 60 87 61 … … 90 64 } 91 65 92 graphVertex actualVertex ;66 graphVertex actualVertex= graphVertex(start); 93 67 94 68 actualVertex.alreadyVisited=true; … … 168 142 169 143 170 graphVertex findNextVertexToConsider(graphVertex listOfVertices []){ //find next, nearest from start, non visited vertex144 graphVertex findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex 171 145 172 146 int shortestDistance = -1; … … 175 149 for(int i=0; i < 67; i++){ //we loop over all possible positions 176 150 177 if(listOfVertices [i].alreadyVisited==true){ //vertex should already be visited178 179 findNearestNonVisitedNeighboor(listOfVertices [i]); //we update nearest neighboor151 if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited 152 153 findNearestNonVisitedNeighboor(listOfVerticesP[i]); //we update nearest neighboor 180 154 //of all visited vertices given that one of the nearest neighboor of a visited 181 155 // vertex is now also visited because it was chosen as next optimal vertex 182 156 183 if(listOfVertices [i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate!157 if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate! 184 158 if(shortestDistance==-1){ //our first possible candidate 185 159 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;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; 202 176 } 203 177 } … … 218 192 //-195 -135 -85 -35 15 60 105 150 195 245 219 193 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])){ 194 void findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[]){ 195 196 197 if(findpos(actuelposition,possibleposition[0])){ 242 198 // we should use listOfVertices[i] instead of possibleposition[i] I think 243 199 // 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];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]); 334 290 } 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];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]); 364 320 } 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];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]); 402 358 403 359 } 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];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]); 421 377 } 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];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]); 506 462 507 463 } 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];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]); 548 504 } 549 505 } 550 506 507 551 508 }
Note: See TracChangeset
for help on using the changeset viewer.