[12293] | 1 | #include "core/CoreIncludes.h" |
---|
| 2 | #include "core/XMLPort.h" |
---|
[12304] | 3 | //#include "getShortestPath.h" |
---|
| 4 | #include "PacmanGhost.h" |
---|
[12293] | 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 | |
---|
[12304] | 50 | graphVertex listOfVertices[67]; |
---|
[12293] | 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 | |
---|
[12304] | 66 | graphVertex actualVertex= graphVertex(start); |
---|
[12293] | 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 | |
---|
[12304] | 144 | graphVertex findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex |
---|
[12293] | 145 | |
---|
| 146 | int shortestDistance = -1; |
---|
| 147 | graphVertex nextVertexToConsider; |
---|
| 148 | |
---|
| 149 | for(int i=0; i < 67; i++){ //we loop over all possible positions |
---|
| 150 | |
---|
[12304] | 151 | if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited |
---|
[12293] | 152 | |
---|
[12304] | 153 | findNearestNonVisitedNeighboor(listOfVerticesP[i]); //we update nearest neighboor |
---|
[12293] | 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 | |
---|
[12304] | 157 | if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate! |
---|
[12293] | 158 | if(shortestDistance==-1){ //our first possible candidate |
---|
| 159 | |
---|
[12304] | 160 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 161 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 162 | listOfVerticesP[i].shortestDistanceToStart; |
---|
[12293] | 163 | |
---|
[12304] | 164 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
[12293] | 165 | |
---|
| 166 | } |
---|
[12304] | 167 | else if(shortestDistance > graphDistance(listOfVerticesP[i].position, |
---|
| 168 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 169 | listOfVerticesP[i].shortestDistanceToStart){ |
---|
[12293] | 170 | |
---|
[12304] | 171 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 172 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 173 | listOfVerticesP[i].shortestDistanceToStart; |
---|
[12293] | 174 | |
---|
[12304] | 175 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
[12293] | 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 | |
---|
[12304] | 194 | void findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[]){ |
---|
[12293] | 195 | |
---|
| 196 | |
---|
[12304] | 197 | if(findpos(actuelposition,possibleposition[0])){ |
---|
[12293] | 198 | // we should use listOfVertices[i] instead of possibleposition[i] I think |
---|
| 199 | // so that all neighboors are "the same" |
---|
[12304] | 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 ? |
---|
[12293] | 203 | } |
---|
[12304] | 204 | else if(findpos(actuelposition,possibleposition[1])){ |
---|
| 205 | adjacentVertices[0]=&listOfVertices[0]; //graphVertex(possibleposition[0]); |
---|
| 206 | adjacentVertices[1]=&listOfVertices[2]; //graphVertex(possibleposition[2]); |
---|
[12293] | 207 | } |
---|
[12304] | 208 | else if(findpos(actuelposition,possibleposition[2])){ |
---|
| 209 | adjacentVertices[0]=&listOfVertices[1]; //graphVertex(possibleposition[1]); |
---|
| 210 | adjacentVertices[1]=&listOfVertices[3]; //graphVertex(possibleposition[3]); |
---|
[12293] | 211 | } |
---|
[12304] | 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]); |
---|
[12293] | 216 | } |
---|
[12304] | 217 | else if(findpos(actuelposition,possibleposition[4])){ |
---|
| 218 | adjacentVertices[0]=&listOfVertices[3]; //graphVertex(possibleposition[3]); |
---|
| 219 | adjacentVertices[1]=&listOfVertices[6]; //graphVertex(possibleposition[6]); |
---|
[12293] | 220 | } |
---|
[12304] | 221 | else if(findpos(actuelposition,possibleposition[5])){ |
---|
| 222 | adjacentVertices[0]=&listOfVertices[3]; //graphVertex(possibleposition[3]); |
---|
| 223 | adjacentVertices[1]=&listOfVertices[7]; //graphVertex(possibleposition[7]); |
---|
[12293] | 224 | } |
---|
[12304] | 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]); |
---|
[12293] | 229 | } |
---|
[12304] | 230 | else if(findpos(actuelposition,possibleposition[7])){ |
---|
| 231 | adjacentVertices[0]=&listOfVertices[5]; //graphVertex(possibleposition[5]); |
---|
| 232 | adjacentVertices[1]=&listOfVertices[8]; //graphVertex(possibleposition[8]); |
---|
[12293] | 233 | } |
---|
[12304] | 234 | else if(findpos(actuelposition,possibleposition[8])){ |
---|
| 235 | adjacentVertices[0]=&listOfVertices[7]; //graphVertex(possibleposition[7]); |
---|
| 236 | adjacentVertices[1]=&listOfVertices[9]; //graphVertex(possibleposition[9]); |
---|
[12293] | 237 | } |
---|
[12304] | 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]); |
---|
[12293] | 243 | } |
---|
[12304] | 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]); |
---|
[12293] | 248 | } |
---|
[12304] | 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]); |
---|
[12293] | 253 | } |
---|
[12304] | 254 | else if(findpos(actuelposition,possibleposition[12])){ |
---|
| 255 | adjacentVertices[0]=&listOfVertices[11]; //graphVertex(possibleposition[11]); |
---|
| 256 | adjacentVertices[1]=&listOfVertices[14]; //graphVertex(possibleposition[14]); |
---|
[12293] | 257 | } |
---|
[12304] | 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]); |
---|
[12293] | 263 | } |
---|
[12304] | 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]); |
---|
[12293] | 268 | } |
---|
[12304] | 269 | else if(findpos(actuelposition,possibleposition[15])){ |
---|
| 270 | adjacentVertices[0]=&listOfVertices[14]; //graphVertex(possibleposition[14]); |
---|
| 271 | adjacentVertices[1]=&listOfVertices[16]; //graphVertex(possibleposition[16]); |
---|
[12293] | 272 | } |
---|
[12304] | 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]); |
---|
[12293] | 277 | } |
---|
[12304] | 278 | else if(findpos(actuelposition,possibleposition[17])){ |
---|
| 279 | adjacentVertices[0]=&listOfVertices[0]; //graphVertex(possibleposition[0]); |
---|
| 280 | adjacentVertices[1]=&listOfVertices[25]; //graphVertex(possibleposition[25]); |
---|
[12293] | 281 | } |
---|
[12304] | 282 | else if(findpos(actuelposition,possibleposition[18])){ |
---|
| 283 | adjacentVertices[0]=&listOfVertices[19]; //graphVertex(possibleposition[19]); |
---|
| 284 | adjacentVertices[1]=&listOfVertices[24]; //graphVertex(possibleposition[24]); |
---|
[12293] | 285 | } |
---|
[12304] | 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]); |
---|
[12293] | 290 | } |
---|
[12304] | 291 | else if(findpos(actuelposition,possibleposition[20])){ |
---|
| 292 | adjacentVertices[0]=&listOfVertices[19]; //graphVertex(possibleposition[19]); |
---|
| 293 | adjacentVertices[1]=&listOfVertices[21]; //graphVertex(possibleposition[21]); |
---|
[12293] | 294 | } |
---|
[12304] | 295 | else if(findpos(actuelposition,possibleposition[21])){ |
---|
| 296 | adjacentVertices[0]=&listOfVertices[20]; //graphVertex(possibleposition[20]); |
---|
| 297 | adjacentVertices[1]=&listOfVertices[22]; //graphVertex(possibleposition[22]); |
---|
[12293] | 298 | } |
---|
[12304] | 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]); |
---|
[12293] | 303 | } |
---|
[12304] | 304 | else if(findpos(actuelposition,possibleposition[23])){ |
---|
| 305 | adjacentVertices[0]=&listOfVertices[22]; //graphVertex(possibleposition[22]); |
---|
| 306 | adjacentVertices[1]=&listOfVertices[30]; //graphVertex(possibleposition[30]); |
---|
[12293] | 307 | } |
---|
[12304] | 308 | else if(findpos(actuelposition,possibleposition[24])){ |
---|
| 309 | adjacentVertices[0]=&listOfVertices[18]; //graphVertex(possibleposition[18]); |
---|
| 310 | adjacentVertices[1]=&listOfVertices[29]; //graphVertex(possibleposition[29]); |
---|
[12293] | 311 | } |
---|
[12304] | 312 | else if(findpos(actuelposition,possibleposition[25])){ |
---|
| 313 | adjacentVertices[0]=&listOfVertices[17]; //graphVertex(possibleposition[17]); |
---|
| 314 | adjacentVertices[1]=&listOfVertices[26]; //graphVertex(possibleposition[26]); |
---|
[12293] | 315 | } |
---|
[12304] | 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]); |
---|
[12293] | 320 | } |
---|
[12304] | 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]); |
---|
[12293] | 325 | } |
---|
[12304] | 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]); |
---|
[12293] | 330 | } |
---|
[12304] | 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]); |
---|
[12293] | 335 | } |
---|
[12304] | 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]); |
---|
[12293] | 340 | } |
---|
[12304] | 341 | else if(findpos(actuelposition,possibleposition[31])){ |
---|
| 342 | adjacentVertices[0]=&listOfVertices[22]; //graphVertex(possibleposition[22]); |
---|
| 343 | adjacentVertices[1]=&listOfVertices[32]; //graphVertex(possibleposition[32]); |
---|
[12293] | 344 | } |
---|
[12304] | 345 | else if(findpos(actuelposition,possibleposition[32])){ |
---|
| 346 | adjacentVertices[0]=&listOfVertices[31]; //graphVertex(possibleposition[31]); |
---|
| 347 | adjacentVertices[1]=&listOfVertices[33]; //graphVertex(possibleposition[33]); |
---|
[12293] | 348 | } |
---|
[12304] | 349 | else if(findpos(actuelposition,possibleposition[33])){ |
---|
| 350 | adjacentVertices[0]=&listOfVertices[32]; //graphVertex(possibleposition[32]); |
---|
| 351 | adjacentVertices[1]=&listOfVertices[34]; //graphVertex(possibleposition[34]); |
---|
[12293] | 352 | } |
---|
[12304] | 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]); |
---|
[12293] | 358 | |
---|
| 359 | } |
---|
[12304] | 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]); |
---|
[12293] | 364 | } |
---|
[12304] | 365 | else if(findpos(actuelposition,possibleposition[36])){ |
---|
| 366 | adjacentVertices[0]=&listOfVertices[28]; //graphVertex(possibleposition[28]); |
---|
| 367 | adjacentVertices[1]=&listOfVertices[35]; //graphVertex(possibleposition[35]); |
---|
[12293] | 368 | } |
---|
[12304] | 369 | else if(findpos(actuelposition,possibleposition[37])){ |
---|
| 370 | adjacentVertices[0]=&listOfVertices[27]; //graphVertex(possibleposition[27]); |
---|
| 371 | adjacentVertices[1]=&listOfVertices[38]; //graphVertex(possibleposition[38]); |
---|
[12293] | 372 | } |
---|
[12304] | 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]); |
---|
[12293] | 377 | } |
---|
[12304] | 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]); |
---|
[12293] | 382 | } |
---|
[12304] | 383 | else if(findpos(actuelposition,possibleposition[40])){ |
---|
| 384 | adjacentVertices[0]=&listOfVertices[39]; //graphVertex(possibleposition[39]); |
---|
| 385 | adjacentVertices[1]=&listOfVertices[41]; //graphVertex(possibleposition[41]); |
---|
[12293] | 386 | } |
---|
[12304] | 387 | else if(findpos(actuelposition,possibleposition[41])){ |
---|
| 388 | adjacentVertices[0]=&listOfVertices[35]; //graphVertex(possibleposition[35]); |
---|
| 389 | adjacentVertices[1]=&listOfVertices[43]; //graphVertex(possibleposition[43]); |
---|
[12293] | 390 | } |
---|
[12304] | 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]); |
---|
[12293] | 395 | } |
---|
[12304] | 396 | else if(findpos(actuelposition,possibleposition[43])){ |
---|
| 397 | adjacentVertices[0]=&listOfVertices[41]; //graphVertex(possibleposition[41]); |
---|
| 398 | adjacentVertices[1]=&listOfVertices[46]; //graphVertex(possibleposition[46]); |
---|
[12293] | 399 | } |
---|
[12304] | 400 | else if(findpos(actuelposition,possibleposition[44])){ |
---|
| 401 | adjacentVertices[0]=&listOfVertices[40]; //graphVertex(possibleposition[40]); |
---|
| 402 | adjacentVertices[1]=&listOfVertices[66]; //graphVertex(possibleposition[66]); |
---|
[12293] | 403 | } |
---|
[12304] | 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]); |
---|
[12293] | 408 | } |
---|
[12304] | 409 | else if(findpos(actuelposition,possibleposition[46])){ |
---|
| 410 | adjacentVertices[0]=&listOfVertices[43]; //graphVertex(possibleposition[43]); |
---|
| 411 | adjacentVertices[1]=&listOfVertices[47]; //graphVertex(possibleposition[47]); |
---|
[12293] | 412 | } |
---|
[12304] | 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]); |
---|
[12293] | 417 | } |
---|
[12304] | 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]); |
---|
[12293] | 422 | } |
---|
[12304] | 423 | else if(findpos(actuelposition,possibleposition[49])){ |
---|
| 424 | adjacentVertices[0]=&listOfVertices[45]; //graphVertex(possibleposition[45]); |
---|
| 425 | adjacentVertices[1]=&listOfVertices[48]; //graphVertex(possibleposition[48]); |
---|
[12293] | 426 | } |
---|
[12304] | 427 | else if(findpos(actuelposition,possibleposition[50])){ |
---|
| 428 | adjacentVertices[0]=&listOfVertices[51]; //graphVertex(possibleposition[51]); |
---|
| 429 | adjacentVertices[1]=&listOfVertices[61]; //graphVertex(possibleposition[61]); |
---|
[12293] | 430 | } |
---|
[12304] | 431 | else if(findpos(actuelposition,possibleposition[51])){ |
---|
| 432 | adjacentVertices[0]=&listOfVertices[48]; //graphVertex(possibleposition[48]); |
---|
| 433 | adjacentVertices[1]=&listOfVertices[50]; //graphVertex(possibleposition[50]); |
---|
[12293] | 434 | } |
---|
[12304] | 435 | else if(findpos(actuelposition,possibleposition[52])){ |
---|
| 436 | adjacentVertices[0]=&listOfVertices[47]; //graphVertex(possibleposition[47]); |
---|
| 437 | adjacentVertices[1]=&listOfVertices[53]; //graphVertex(possibleposition[53]); |
---|
[12293] | 438 | } |
---|
[12304] | 439 | else if(findpos(actuelposition,possibleposition[53])){ |
---|
| 440 | adjacentVertices[0]=&listOfVertices[52]; //graphVertex(possibleposition[52]); |
---|
| 441 | adjacentVertices[1]=&listOfVertices[58]; //graphVertex(possibleposition[58]); |
---|
[12293] | 442 | } |
---|
[12304] | 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]); |
---|
[12293] | 447 | } |
---|
[12304] | 448 | else if(findpos(actuelposition,possibleposition[55])){ |
---|
| 449 | adjacentVertices[0]=&listOfVertices[54]; //graphVertex(possibleposition[54]); |
---|
| 450 | adjacentVertices[1]=&listOfVertices[56]; //graphVertex(possibleposition[56]); |
---|
[12293] | 451 | } |
---|
[12304] | 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]); |
---|
[12293] | 456 | } |
---|
[12304] | 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]); |
---|
[12293] | 462 | |
---|
| 463 | } |
---|
[12304] | 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]); |
---|
[12293] | 468 | } |
---|
[12304] | 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]); |
---|
[12293] | 473 | } |
---|
[12304] | 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]); |
---|
[12293] | 478 | } |
---|
[12304] | 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]); |
---|
[12293] | 483 | } |
---|
[12304] | 484 | else if(findpos(actuelposition,possibleposition[62])){ |
---|
| 485 | adjacentVertices[0]=&listOfVertices[16]; //graphVertex(possibleposition[16]); |
---|
| 486 | adjacentVertices[1]=&listOfVertices[60]; //graphVertex(possibleposition[60]); |
---|
[12293] | 487 | } |
---|
[12304] | 488 | else if(findpos(actuelposition,possibleposition[63])){ |
---|
| 489 | adjacentVertices[0]=&listOfVertices[59]; //graphVertex(possibleposition[59]); |
---|
| 490 | adjacentVertices[1]=&listOfVertices[64]; //graphVertex(possibleposition[64]); |
---|
[12293] | 491 | } |
---|
[12304] | 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]); |
---|
[12293] | 496 | } |
---|
[12304] | 497 | else if(findpos(actuelposition,possibleposition[65])){ |
---|
| 498 | adjacentVertices[0]=&listOfVertices[56]; //graphVertex(possibleposition[56]); |
---|
| 499 | adjacentVertices[1]=&listOfVertices[64]; //graphVertex(possibleposition[64]); |
---|
[12293] | 500 | } |
---|
[12304] | 501 | else if(findpos(actuelposition,possibleposition[66])){ |
---|
| 502 | adjacentVertices[0]=&listOfVertices[47]; //graphVertex(possibleposition[47]); |
---|
| 503 | adjacentVertices[1]=&listOfVertices[48]; //graphVertex(possibleposition[48]); |
---|
[12293] | 504 | } |
---|
| 505 | } |
---|
| 506 | |
---|
[12304] | 507 | |
---|
[12293] | 508 | } |
---|