[11898] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[11992] | 23 | * Marc Dreher |
---|
[11898] | 24 | * Co-authors: |
---|
[11992] | 25 | * .. |
---|
[11898] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "PacmanGhost.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "BulletDynamics/Dynamics/btRigidBody.h" |
---|
| 33 | |
---|
| 34 | namespace orxonox |
---|
| 35 | { |
---|
[12304] | 36 | |
---|
[12316] | 37 | |
---|
| 38 | struct PacmanGhost::graphVertex { |
---|
| 39 | |
---|
| 40 | public: |
---|
| 41 | |
---|
| 42 | Vector3 position; |
---|
| 43 | graphVertex *adjacentVertices[4]; //neighbooring vertices |
---|
| 44 | |
---|
| 45 | //would a vector of vector storing the neighboors not be more suitable ? |
---|
| 46 | |
---|
| 47 | int shortestDistanceToStart; //actual shortest distance to start point |
---|
| 48 | graphVertex* actuelPredecessor; //the predecessor giving the for now shortest |
---|
| 49 | //path to start |
---|
| 50 | graphVertex* currentNearestNonVisitedNeighboor; |
---|
| 51 | bool alreadyVisited; |
---|
| 52 | graphVertex(){ //default constructor |
---|
| 53 | position=0; |
---|
| 54 | shortestDistanceToStart= std::numeric_limits<int>::max(); |
---|
| 55 | actuelPredecessor=nullptr; |
---|
| 56 | alreadyVisited=false; |
---|
| 57 | for(int kl =0; kl <4;kl++){ |
---|
| 58 | adjacentVertices[kl]=nullptr; //first put all position in array listing neighboors to 0 |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | graphVertex(Vector3 wantedPosition){ //normal constructor |
---|
| 62 | position=wantedPosition; |
---|
| 63 | shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity |
---|
| 64 | actuelPredecessor=nullptr; |
---|
| 65 | alreadyVisited=false; |
---|
| 66 | for(int kl =0; kl <4;kl++){ |
---|
| 67 | adjacentVertices[kl]=nullptr; //first put all position in array listing neighboors to 0 |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | graphVertex& operator = (const graphVertex &rightSide){ |
---|
| 71 | this->position=rightSide.position; |
---|
| 72 | this->shortestDistanceToStart=rightSide.shortestDistanceToStart; |
---|
| 73 | this->actuelPredecessor=rightSide.actuelPredecessor; |
---|
| 74 | this->currentNearestNonVisitedNeighboor=rightSide.currentNearestNonVisitedNeighboor; |
---|
| 75 | this->alreadyVisited=rightSide.alreadyVisited; |
---|
| 76 | |
---|
| 77 | return *this; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | }; |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | static PacmanGhost::graphVertex listOfVertices[67]; |
---|
| 84 | |
---|
[12304] | 85 | //Check if there is a collision |
---|
| 86 | bool findpos(Vector3 one, Vector3 other){ |
---|
| 87 | if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true; |
---|
| 88 | return false; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | //All positions in the map, see documentation |
---|
| 92 | Vector3 possibleposition[67] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4 |
---|
| 93 | Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9 |
---|
| 94 | Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14 |
---|
| 95 | Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19 |
---|
| 96 | Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24 |
---|
| 97 | Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29 |
---|
| 98 | Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34 |
---|
| 99 | Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39 |
---|
| 100 | Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44 |
---|
| 101 | Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49 |
---|
| 102 | Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54 |
---|
| 103 | Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59 |
---|
| 104 | Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64 |
---|
| 105 | Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66 |
---|
| 106 | |
---|
[11898] | 107 | RegisterClass(PacmanGhost); |
---|
| 108 | |
---|
| 109 | /** |
---|
| 110 | @brief |
---|
| 111 | Constructor. Registers the object and initializes some default values. |
---|
| 112 | @param creator |
---|
| 113 | The creator of this object. |
---|
| 114 | */ |
---|
| 115 | PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context) |
---|
| 116 | { |
---|
| 117 | RegisterObject(PacmanGhost); |
---|
| 118 | |
---|
[12316] | 119 | //this->pathAlgorithm = new GetShortestPathAlgorithm; |
---|
| 120 | |
---|
| 121 | |
---|
[11927] | 122 | this->velocity = Vector3(0, 0, 0); |
---|
[12304] | 123 | |
---|
[11898] | 124 | this->setCollisionType(CollisionType::Dynamic); |
---|
| 125 | |
---|
| 126 | this->actuelposition = this->getPosition(); |
---|
[11945] | 127 | |
---|
| 128 | if(findpos(actuelposition, Vector3(0,-20,0))) |
---|
| 129 | dontmove = true; |
---|
[11898] | 130 | |
---|
| 131 | this->target_x = actuelposition.x; |
---|
[11927] | 132 | this->target_z = actuelposition.z; |
---|
[11898] | 133 | |
---|
[12316] | 134 | //this->lastPlayerPassedPoint=Vector3(185,10,150); //no idea what to put |
---|
| 135 | |
---|
[11898] | 136 | } |
---|
| 137 | |
---|
| 138 | /** |
---|
| 139 | @brief |
---|
[11992] | 140 | Destructor. Destroys ghost, if present. |
---|
[11898] | 141 | */ |
---|
| 142 | PacmanGhost::~PacmanGhost() |
---|
| 143 | { |
---|
[12316] | 144 | // Deletes the controller if the object was initialized and the pointer to the controller is not nullptr. |
---|
[11898] | 145 | } |
---|
| 146 | |
---|
| 147 | /** |
---|
| 148 | @brief |
---|
[11992] | 149 | Method for creating a ghost through XML. |
---|
[11898] | 150 | */ |
---|
[12304] | 151 | void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
[11898] | 152 | { |
---|
| 153 | SUPER(PacmanGhost, XMLPort, xmlelement, mode); |
---|
| 154 | } |
---|
| 155 | |
---|
[11992] | 156 | //Change this with other ghost |
---|
[11947] | 157 | void PacmanGhost::changewith(PacmanGhost* otherghost){ |
---|
[11949] | 158 | |
---|
[11950] | 159 | while(lockmove){}; |
---|
[11992] | 160 | lockmove = true; //Prevent change of target while ghost is changed |
---|
[11949] | 161 | |
---|
[11945] | 162 | otherghost->setPosition(this->getPosition()); |
---|
| 163 | this->setPosition(0,-20,0); |
---|
[11992] | 164 | otherghost->target_x = this->target_x; |
---|
[11948] | 165 | otherghost->target_z = this->target_z; |
---|
[11945] | 166 | otherghost->ismoving = this->ismoving; |
---|
[11903] | 167 | |
---|
[11945] | 168 | this->dontmove = true; |
---|
| 169 | otherghost->dontmove = false; |
---|
[11949] | 170 | |
---|
[11950] | 171 | lockmove = false; |
---|
[11945] | 172 | } |
---|
[11903] | 173 | |
---|
[11992] | 174 | //Move ghost with rotation |
---|
[11903] | 175 | void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){ |
---|
[11976] | 176 | if(!dontmove){ |
---|
[11979] | 177 | this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt)); |
---|
[11992] | 178 | |
---|
| 179 | //Rotate ghost in the direction of movement |
---|
[12304] | 180 | if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)){ |
---|
[11978] | 181 | if(velocity.x<0){ |
---|
| 182 | this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0))); |
---|
[11976] | 183 | } |
---|
[11978] | 184 | else{ |
---|
| 185 | this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0))); |
---|
[11976] | 186 | } |
---|
[12304] | 187 | } |
---|
| 188 | if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)){ |
---|
[11978] | 189 | if(velocity.z<0){ |
---|
| 190 | this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0))); |
---|
[11976] | 191 | } |
---|
[11978] | 192 | else{ |
---|
| 193 | this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); |
---|
| 194 | } |
---|
[12304] | 195 | } |
---|
[11978] | 196 | |
---|
[11976] | 197 | } |
---|
[11903] | 198 | } |
---|
| 199 | |
---|
[11992] | 200 | //Change ability to move |
---|
[11944] | 201 | void PacmanGhost::changemovability(){ |
---|
[11933] | 202 | if(dontmove){ |
---|
| 203 | dontmove = false;} |
---|
| 204 | else{ |
---|
| 205 | dontmove = true; |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | |
---|
[11992] | 209 | //ResetGhost |
---|
[11903] | 210 | void PacmanGhost::resetGhost(){ |
---|
[11927] | 211 | |
---|
[11915] | 212 | this->setPosition(this->resetposition); |
---|
| 213 | this->ismoving = false; |
---|
| 214 | this->actuelposition = this->getPosition(); |
---|
| 215 | |
---|
| 216 | this->target_x = actuelposition.x; |
---|
| 217 | this->target_z = actuelposition.z; |
---|
[11927] | 218 | |
---|
[11903] | 219 | } |
---|
[11958] | 220 | |
---|
[11992] | 221 | //Increase speed of ghosts |
---|
[11959] | 222 | void PacmanGhost::levelupvelo(){ |
---|
[11979] | 223 | speed ++; |
---|
[11958] | 224 | } |
---|
[12304] | 225 | |
---|
[12316] | 226 | /*Vector3 PacmanGhost::setPureArrayPos(Vector3 &posToSet){ |
---|
[12304] | 227 | //given that the position of a pacman is generally not "neat", |
---|
| 228 | //we need to set it to the nearest point on the map |
---|
| 229 | // if the pacman is not moving anymore, i.e. has reached a point |
---|
| 230 | int i=0; |
---|
| 231 | while(!(findpos(possibleposition[i], posToSet))){ |
---|
| 232 | i++; |
---|
| 233 | } |
---|
| 234 | return possibleposition[i]; |
---|
[12316] | 235 | }*/ |
---|
| 236 | |
---|
| 237 | Vector3 PacmanGhost::getPlayerPos() |
---|
| 238 | { |
---|
| 239 | for (PacmanGelb* player : ObjectList<PacmanGelb>()) |
---|
| 240 | { |
---|
| 241 | return player->getWorldPosition(); |
---|
| 242 | } |
---|
[12318] | 243 | //std::cout<<"bug ??"<<endl; |
---|
[12316] | 244 | return Vector3(0,0,0); //default, should not be used |
---|
| 245 | |
---|
[12304] | 246 | } |
---|
| 247 | |
---|
| 248 | |
---|
[12319] | 249 | bool PacmanGhost::jeanfindpos(Vector3 one, Vector3 other){ |
---|
| 250 | if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true; |
---|
| 251 | return false; |
---|
| 252 | } |
---|
[12316] | 253 | |
---|
[12319] | 254 | void PacmanGhost::setNewTargetGhost(Vector3 goalToGo){ |
---|
[12316] | 255 | |
---|
[12319] | 256 | this->target_x = goalToGo.x; |
---|
| 257 | this->target_z = goalToGo.z; |
---|
| 258 | this->ismoving = true; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | |
---|
[12316] | 262 | /// |
---|
| 263 | //// getShortestPath ///////// |
---|
| 264 | /// |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | |
---|
[12319] | 268 | Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1){ |
---|
| 269 | //this function should then somehow produce the algorithm and call all other functions |
---|
| 270 | //and finally return the best neighboor of the actual position of the pacman |
---|
| 271 | |
---|
| 272 | //(optional parameter) pointToAvoidP1 is a point that cannot be considered |
---|
[12316] | 273 | |
---|
[12319] | 274 | |
---|
| 275 | graphVertex listOfVerticesM[67]; //our list of all possible graphs |
---|
| 276 | graphVertex* actualVertex; //we will walk through the array with a pointer |
---|
| 277 | |
---|
| 278 | if(start==goal){ // basic case |
---|
| 279 | return start; |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | for(int an=0; an < 67; an++){ |
---|
| 283 | listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file |
---|
| 284 | if(start==possibleposition[an]){ |
---|
| 285 | actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array |
---|
| 286 | //cout<<an<<endl; |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | //graphVertex actualVertex= listOfVerticesM[an]; |
---|
| 291 | |
---|
| 292 | actualVertex->alreadyVisited=true; //our start point is now visited |
---|
| 293 | actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0 |
---|
| 294 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 295 | // second parameter is an array ! //third is our global array |
---|
| 296 | |
---|
| 297 | while(actualVertex->position!=goal){ |
---|
| 298 | for(int h=0;h < 4; h++){ |
---|
| 299 | if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex |
---|
| 300 | |
---|
| 301 | //h=2 and 3 never reached |
---|
| 302 | updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]); |
---|
| 303 | } //we "update" the neighboors of our new visited vertex |
---|
| 304 | |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | actualVertex=findNextVertexToConsider(listOfVerticesM, pointToAvoidP1); |
---|
| 308 | actualVertex->alreadyVisited=true; |
---|
| 309 | //cout<<actualVertex->position<<endl; |
---|
| 310 | if(actualVertex->position!=goal){ |
---|
| 311 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 312 | //we find the neighboors of our new visited vertex |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | //cout<<"meuejeeke"<<endl; never reached |
---|
| 317 | |
---|
| 318 | //we should have reached our goal at this point |
---|
| 319 | |
---|
| 320 | while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor |
---|
| 321 | actualVertex=actualVertex->actuelPredecessor; |
---|
| 322 | } |
---|
| 323 | // the predecessor is our starting point, in other words we are now on an |
---|
| 324 | //adjacent vertex of the start |
---|
| 325 | |
---|
| 326 | return actualVertex->position; //we return the position of this - adjacent to start - vertex |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | //end of getShortestPath |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){ |
---|
| 333 | //cout<<hgj++<<endl; |
---|
| 334 | Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); |
---|
| 335 | |
---|
| 336 | return differenceVector.x+differenceVector.z; |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ |
---|
| 340 | //apply this method to all non visited neighboors of a vertex. |
---|
| 341 | // This method should always be run on a vertex after we marked it as visited. |
---|
| 342 | if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. |
---|
| 343 | if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&& |
---|
| 344 | (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + |
---|
| 345 | graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case ! |
---|
| 346 | |
---|
| 347 | neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + |
---|
| 348 | graphDistance(vertex.position, neighboor.position); |
---|
| 349 | neighboor.actuelPredecessor = &vertex; |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3){ |
---|
| 355 | //find nearest non visited neighboor of a given already visited vertex |
---|
| 356 | //(optional parameter) pointToAvoidP3 is a point that cannot be considered |
---|
| 357 | int shortestDistance = -1; |
---|
| 358 | graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any. |
---|
| 359 | //Also, if all neighboors are already visited, we return NULL, i.e. there is no |
---|
| 360 | //nearest non visited neighboor. |
---|
| 361 | for(int i=0; i < 4; i++){ |
---|
| 362 | if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)&&(vertex.adjacentVertices[i]->position!=pointToAvoidP3)){ |
---|
| 363 | if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor //(optional) if the position of the neighboor is the one we want |
---|
| 364 | //to avoid, then we ignore it |
---|
| 365 | |
---|
| 366 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 367 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 368 | //cout<<shortestDistance<<endl; |
---|
| 369 | } |
---|
| 370 | else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ |
---|
| 371 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 372 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 373 | //cout<<(hgj++)%4<<endl; |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses ! |
---|
| 378 | //cout<<hgj++<<endl; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2){ //find next, nearest from start, non visited vertex in our listOfVertices array |
---|
| 383 | //(optional parameter) pointToAvoidP2 is a point that cannot be considered |
---|
| 384 | |
---|
| 385 | int shortestDistance = -1; |
---|
| 386 | graphVertex* nextVertexToConsider; |
---|
| 387 | |
---|
| 388 | for(int i=0; i < 67; i++){ //we loop over all possible positions |
---|
| 389 | |
---|
| 390 | if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited |
---|
| 391 | |
---|
| 392 | findNearestNonVisitedNeighboor(listOfVerticesP[i], pointToAvoidP2); //we update nearest neighboor |
---|
| 393 | //of all visited vertices given that one of the nearest neighboor of a visited |
---|
| 394 | // vertex is now also visited because it was chosen as next optimal vertex |
---|
| 395 | |
---|
| 396 | if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate! |
---|
| 397 | if(shortestDistance==-1){ //our first possible candidate |
---|
| 398 | |
---|
| 399 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 400 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 401 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 402 | |
---|
| 403 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 404 | //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor |
---|
| 405 | |
---|
| 406 | } |
---|
| 407 | else if(shortestDistance > graphDistance(listOfVerticesP[i].position, |
---|
| 408 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 409 | listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available |
---|
| 410 | |
---|
| 411 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 412 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 413 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 414 | |
---|
| 415 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 416 | //we dont need the & because we are not giving the adress of the array element |
---|
| 417 | //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor |
---|
| 418 | } |
---|
| 419 | } |
---|
| 420 | } |
---|
| 421 | //we want after all to return the nearest non visited neighboor |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 428 | |
---|
| 429 | //if vertex already visited, call function on it and reapeat until you reach non visited vertex |
---|
| 430 | // ---> not sure if a good idea because we risk infinite loop |
---|
| 431 | |
---|
| 432 | //-215 -185 -135 -70 -20 0 20 70 135 185 215 |
---|
| 433 | |
---|
| 434 | //-195 -135 -85 -35 15 60 105 150 195 245 |
---|
| 435 | |
---|
| 436 | void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){ |
---|
| 437 | |
---|
| 438 | |
---|
| 439 | if(findpos(actuelposition,possibleposition[0])){ |
---|
| 440 | // we should use listOfVerticesP2[i] instead of possibleposition[i] I think |
---|
| 441 | // so that all neighboors are "the same" |
---|
| 442 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!! |
---|
| 443 | adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 444 | adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ? |
---|
| 445 | } |
---|
| 446 | else if(findpos(actuelposition,possibleposition[1])){ |
---|
| 447 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 448 | adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 449 | } |
---|
| 450 | else if(findpos(actuelposition,possibleposition[2])){ |
---|
| 451 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); |
---|
| 452 | adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 453 | } |
---|
| 454 | else if(findpos(actuelposition,possibleposition[3])){ |
---|
| 455 | adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 456 | adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 457 | adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 458 | } |
---|
| 459 | else if(findpos(actuelposition,possibleposition[4])){ |
---|
| 460 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 461 | adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 462 | } |
---|
| 463 | else if(findpos(actuelposition,possibleposition[5])){ |
---|
| 464 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 465 | adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 466 | } |
---|
| 467 | else if(findpos(actuelposition,possibleposition[6])){ |
---|
| 468 | adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 469 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 470 | adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 471 | } |
---|
| 472 | else if(findpos(actuelposition,possibleposition[7])){ |
---|
| 473 | adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 474 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 475 | } |
---|
| 476 | else if(findpos(actuelposition,possibleposition[8])){ |
---|
| 477 | adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 478 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 479 | } |
---|
| 480 | else if(findpos(actuelposition,possibleposition[9])){ |
---|
| 481 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 482 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 483 | adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 484 | adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 485 | } |
---|
| 486 | else if(findpos(actuelposition,possibleposition[10])){ |
---|
| 487 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 488 | adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 489 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 490 | } |
---|
| 491 | else if(findpos(actuelposition,possibleposition[11])){ |
---|
| 492 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 493 | adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 494 | adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 495 | } |
---|
| 496 | else if(findpos(actuelposition,possibleposition[12])){ |
---|
| 497 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 498 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 499 | } |
---|
| 500 | else if(findpos(actuelposition,possibleposition[13])){ |
---|
| 501 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 502 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 503 | adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 504 | adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 505 | } |
---|
| 506 | else if(findpos(actuelposition,possibleposition[14])){ |
---|
| 507 | adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 508 | adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 509 | adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 510 | } |
---|
| 511 | else if(findpos(actuelposition,possibleposition[15])){ |
---|
| 512 | adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 513 | adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 514 | } |
---|
| 515 | else if(findpos(actuelposition,possibleposition[16])){ |
---|
| 516 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 517 | adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 518 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 519 | } |
---|
| 520 | else if(findpos(actuelposition,possibleposition[17])){ |
---|
| 521 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 522 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 523 | } |
---|
| 524 | else if(findpos(actuelposition,possibleposition[18])){ |
---|
| 525 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 526 | adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 527 | } |
---|
| 528 | else if(findpos(actuelposition,possibleposition[19])){ |
---|
| 529 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 530 | adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 531 | adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 532 | } |
---|
| 533 | else if(findpos(actuelposition,possibleposition[20])){ |
---|
| 534 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 535 | adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 536 | } |
---|
| 537 | else if(findpos(actuelposition,possibleposition[21])){ |
---|
| 538 | adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 539 | adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 540 | } |
---|
| 541 | else if(findpos(actuelposition,possibleposition[22])){ |
---|
| 542 | adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 543 | adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 544 | adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 545 | } |
---|
| 546 | else if(findpos(actuelposition,possibleposition[23])){ |
---|
| 547 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 548 | adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 549 | } |
---|
| 550 | else if(findpos(actuelposition,possibleposition[24])){ |
---|
| 551 | adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 552 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 553 | } |
---|
| 554 | else if(findpos(actuelposition,possibleposition[25])){ |
---|
| 555 | adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 556 | adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 557 | } |
---|
| 558 | else if(findpos(actuelposition,possibleposition[26])){ |
---|
| 559 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 560 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 561 | adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 562 | } |
---|
| 563 | else if(findpos(actuelposition,possibleposition[27])){ |
---|
| 564 | adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 565 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 566 | adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 567 | } |
---|
| 568 | else if(findpos(actuelposition,possibleposition[28])){ |
---|
| 569 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 570 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 571 | adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 572 | } |
---|
| 573 | else if(findpos(actuelposition,possibleposition[29])){ |
---|
| 574 | adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 575 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 576 | adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 577 | } |
---|
| 578 | else if(findpos(actuelposition,possibleposition[30])){ |
---|
| 579 | adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 580 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 581 | adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 582 | } |
---|
| 583 | else if(findpos(actuelposition,possibleposition[31])){ |
---|
| 584 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 585 | adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 586 | } |
---|
| 587 | else if(findpos(actuelposition,possibleposition[32])){ |
---|
| 588 | adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 589 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 590 | } |
---|
| 591 | else if(findpos(actuelposition,possibleposition[33])){ |
---|
| 592 | adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 593 | adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 594 | } |
---|
| 595 | else if(findpos(actuelposition,possibleposition[34])){ |
---|
| 596 | adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 597 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 598 | adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 599 | adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 600 | |
---|
| 601 | } |
---|
| 602 | else if(findpos(actuelposition,possibleposition[35])){ |
---|
| 603 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 604 | adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 605 | adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 606 | } |
---|
| 607 | else if(findpos(actuelposition,possibleposition[36])){ |
---|
| 608 | adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 609 | adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 610 | } |
---|
| 611 | else if(findpos(actuelposition,possibleposition[37])){ |
---|
| 612 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 613 | adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 614 | } |
---|
| 615 | else if(findpos(actuelposition,possibleposition[38])){ |
---|
| 616 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 617 | adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 618 | adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 619 | } |
---|
| 620 | else if(findpos(actuelposition,possibleposition[39])){ |
---|
| 621 | adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 622 | adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 623 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 624 | } |
---|
| 625 | else if(findpos(actuelposition,possibleposition[40])){ |
---|
| 626 | adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 627 | adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 628 | } |
---|
| 629 | else if(findpos(actuelposition,possibleposition[41])){ |
---|
| 630 | adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 631 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 632 | } |
---|
| 633 | else if(findpos(actuelposition,possibleposition[42])){ |
---|
| 634 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 635 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 636 | adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 637 | } |
---|
| 638 | else if(findpos(actuelposition,possibleposition[43])){ |
---|
| 639 | adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 640 | adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 641 | } |
---|
| 642 | else if(findpos(actuelposition,possibleposition[44])){ |
---|
| 643 | adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 644 | adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 645 | } |
---|
| 646 | else if(findpos(actuelposition,possibleposition[45])){ |
---|
| 647 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 648 | adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 649 | adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 650 | } |
---|
| 651 | else if(findpos(actuelposition,possibleposition[46])){ |
---|
| 652 | adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 653 | adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 654 | } |
---|
| 655 | else if(findpos(actuelposition,possibleposition[47])){ |
---|
| 656 | adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 657 | adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 658 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 659 | } |
---|
| 660 | else if(findpos(actuelposition,possibleposition[48])){ |
---|
| 661 | adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 662 | adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 663 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 664 | } |
---|
| 665 | else if(findpos(actuelposition,possibleposition[49])){ |
---|
| 666 | adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 667 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 668 | } |
---|
| 669 | else if(findpos(actuelposition,possibleposition[50])){ |
---|
| 670 | adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 671 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 672 | } |
---|
| 673 | else if(findpos(actuelposition,possibleposition[51])){ |
---|
| 674 | adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 675 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 676 | } |
---|
| 677 | else if(findpos(actuelposition,possibleposition[52])){ |
---|
| 678 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 679 | adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 680 | } |
---|
| 681 | else if(findpos(actuelposition,possibleposition[53])){ |
---|
| 682 | adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 683 | adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 684 | } |
---|
| 685 | else if(findpos(actuelposition,possibleposition[54])){ |
---|
| 686 | adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 687 | adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 688 | adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 689 | } |
---|
| 690 | else if(findpos(actuelposition,possibleposition[55])){ |
---|
| 691 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 692 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 693 | } |
---|
| 694 | else if(findpos(actuelposition,possibleposition[56])){ |
---|
| 695 | adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 696 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 697 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 698 | } |
---|
| 699 | else if(findpos(actuelposition,possibleposition[57])){ |
---|
| 700 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 701 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 702 | adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 703 | adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 704 | |
---|
| 705 | } |
---|
| 706 | else if(findpos(actuelposition,possibleposition[58])){ |
---|
| 707 | adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 708 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 709 | adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 710 | } |
---|
| 711 | else if(findpos(actuelposition,possibleposition[59])){ |
---|
| 712 | adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 713 | adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 714 | adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 715 | } |
---|
| 716 | else if(findpos(actuelposition,possibleposition[60])){ |
---|
| 717 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 718 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 719 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 720 | } |
---|
| 721 | else if(findpos(actuelposition,possibleposition[61])){ |
---|
| 722 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 723 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 724 | adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 725 | } |
---|
| 726 | else if(findpos(actuelposition,possibleposition[62])){ |
---|
| 727 | adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 728 | adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 729 | } |
---|
| 730 | else if(findpos(actuelposition,possibleposition[63])){ |
---|
| 731 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 732 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 733 | } |
---|
| 734 | else if(findpos(actuelposition,possibleposition[64])){ |
---|
| 735 | adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 736 | adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 737 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 738 | } |
---|
| 739 | else if(findpos(actuelposition,possibleposition[65])){ |
---|
| 740 | adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 741 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 742 | } |
---|
| 743 | else if(findpos(actuelposition,possibleposition[66])){ |
---|
| 744 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 745 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 746 | } |
---|
| 747 | } |
---|
| 748 | |
---|
| 749 | |
---|
| 750 | |
---|
| 751 | |
---|
| 752 | |
---|
| 753 | /*Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal){ |
---|
[12316] | 754 | //this function should then somehow produce the algorithm and call all other functions |
---|
| 755 | //and finally return the best neighboor of the actual position of the pacman |
---|
| 756 | |
---|
| 757 | |
---|
| 758 | graphVertex listOfVerticesM[67]; //our list of all possible graphs |
---|
| 759 | graphVertex* actualVertex;// = new graphVertex(); //we will walk through the array with a pointer |
---|
| 760 | |
---|
| 761 | if(start==goal){ // basic case |
---|
| 762 | return start; |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | for(int an=0; an < 67; an++){ |
---|
| 766 | listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file |
---|
| 767 | if(start==possibleposition[an]){ |
---|
| 768 | actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array |
---|
| 769 | //cout<<an<<endl; |
---|
| 770 | } |
---|
| 771 | } |
---|
| 772 | |
---|
| 773 | actualVertex->alreadyVisited=true; //our start point is now visited |
---|
| 774 | actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0 |
---|
| 775 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 776 | // second parameter is an array ! //third is our global array |
---|
| 777 | |
---|
| 778 | while(actualVertex->position!=goal){ |
---|
| 779 | for(int h=0;h < 4; h++){ |
---|
| 780 | if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex |
---|
| 781 | |
---|
| 782 | //h=2 and 3 never reached |
---|
| 783 | updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]); |
---|
| 784 | } //we "update" the neighboors of our new visited vertex |
---|
| 785 | |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | actualVertex=findNextVertexToConsider(listOfVerticesM); |
---|
| 789 | actualVertex->alreadyVisited=true; |
---|
| 790 | //cout<<actualVertex->position<<endl; |
---|
| 791 | if(actualVertex->position!=goal){ |
---|
| 792 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 793 | //we find the neighboors of our new visited vertex |
---|
| 794 | } |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | //cout<<"meuejeeke"<<endl; never reached |
---|
| 798 | |
---|
| 799 | //we should have reached our goal at this point |
---|
| 800 | |
---|
| 801 | while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor |
---|
| 802 | actualVertex=actualVertex->actuelPredecessor; |
---|
| 803 | } |
---|
| 804 | // the predecessor is our starting point, in other words we are now on an |
---|
| 805 | //adjacent vertex of the start |
---|
| 806 | |
---|
| 807 | return actualVertex->position; //we return the position of this - adjacent to start - vertex |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | //end of getShortestPath |
---|
| 811 | |
---|
| 812 | |
---|
| 813 | int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){ |
---|
| 814 | //cout<<hgj++<<endl; |
---|
| 815 | Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); |
---|
| 816 | |
---|
| 817 | return differenceVector.x+differenceVector.z; |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ |
---|
| 821 | //apply this method to all non visited neighboors of a vertex. |
---|
| 822 | // This method should always be run on a vertex after we marked it as visited. |
---|
| 823 | if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. |
---|
| 824 | if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&& |
---|
| 825 | (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + |
---|
| 826 | graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case ! |
---|
| 827 | |
---|
| 828 | neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + |
---|
| 829 | graphDistance(vertex.position, neighboor.position); |
---|
| 830 | neighboor.actuelPredecessor = &vertex; |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | } |
---|
| 834 | |
---|
| 835 | void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex){ |
---|
| 836 | //find nearest non visited neighboor of a given already visited vertex |
---|
| 837 | int shortestDistance = -1; |
---|
| 838 | graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any. |
---|
| 839 | //Also, if all neighboors are already visited, we return nullptr, i.e. there is no |
---|
| 840 | //nearest non visited neighboor. |
---|
| 841 | for(int i=0; i < 4; i++){ |
---|
| 842 | if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)){ |
---|
| 843 | if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor |
---|
| 844 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 845 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 846 | //cout<<shortestDistance<<endl; |
---|
| 847 | } |
---|
| 848 | else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ |
---|
| 849 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 850 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 851 | //cout<<(hgj++)%4<<endl; |
---|
| 852 | } |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses ! |
---|
| 856 | //cout<<hgj++<<endl; |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | |
---|
| 860 | PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex in our listOfVertices array |
---|
| 861 | |
---|
| 862 | int shortestDistance = -1; |
---|
| 863 | graphVertex* nextVertexToConsider; |
---|
| 864 | |
---|
| 865 | for(int i=0; i < 67; i++){ //we loop over all possible positions |
---|
| 866 | |
---|
| 867 | if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited |
---|
| 868 | |
---|
| 869 | findNearestNonVisitedNeighboor(listOfVerticesP[i]); //we update nearest neighboor |
---|
| 870 | //of all visited vertices given that one of the nearest neighboor of a visited |
---|
| 871 | // vertex is now also visited because it was chosen as next optimal vertex |
---|
| 872 | |
---|
| 873 | if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate! |
---|
| 874 | if(shortestDistance==-1){ //our first possible candidate |
---|
| 875 | |
---|
| 876 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 877 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 878 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 879 | |
---|
| 880 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 881 | //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor |
---|
| 882 | |
---|
| 883 | } |
---|
| 884 | else if(shortestDistance > graphDistance(listOfVerticesP[i].position, |
---|
| 885 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 886 | listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available |
---|
| 887 | |
---|
| 888 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 889 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 890 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 891 | |
---|
| 892 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 893 | //we dont need the & because we are not giving the adress of the array element |
---|
| 894 | //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor |
---|
| 895 | } |
---|
| 896 | } |
---|
| 897 | } |
---|
| 898 | //we want after all to return the nearest non visited neighboor |
---|
| 899 | } |
---|
| 900 | |
---|
| 901 | return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 905 | |
---|
| 906 | //if vertex already visited, call function on it and reapeat until you reach non visited vertex |
---|
| 907 | // ---> not sure if a good idea because we risk infinite loop |
---|
| 908 | |
---|
| 909 | //-215 -185 -135 -70 -20 0 20 70 135 185 215 |
---|
| 910 | |
---|
| 911 | //-195 -135 -85 -35 15 60 105 150 195 245 |
---|
| 912 | |
---|
| 913 | void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){ |
---|
| 914 | |
---|
| 915 | |
---|
| 916 | if(findpos(actuelposition,possibleposition[0])){ |
---|
| 917 | // we should use listOfVerticesP2[i] instead of possibleposition[i] I think |
---|
| 918 | // so that all neighboors are "the same" |
---|
| 919 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!! |
---|
| 920 | adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 921 | adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ? |
---|
| 922 | } |
---|
| 923 | else if(findpos(actuelposition,possibleposition[1])){ |
---|
| 924 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 925 | adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 926 | } |
---|
| 927 | else if(findpos(actuelposition,possibleposition[2])){ |
---|
| 928 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); |
---|
| 929 | adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 930 | } |
---|
| 931 | else if(findpos(actuelposition,possibleposition[3])){ |
---|
| 932 | adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 933 | adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 934 | adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 935 | } |
---|
| 936 | else if(findpos(actuelposition,possibleposition[4])){ |
---|
| 937 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 938 | adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 939 | } |
---|
| 940 | else if(findpos(actuelposition,possibleposition[5])){ |
---|
| 941 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 942 | adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 943 | } |
---|
| 944 | else if(findpos(actuelposition,possibleposition[6])){ |
---|
| 945 | adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 946 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 947 | adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 948 | } |
---|
| 949 | else if(findpos(actuelposition,possibleposition[7])){ |
---|
| 950 | adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 951 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 952 | } |
---|
| 953 | else if(findpos(actuelposition,possibleposition[8])){ |
---|
| 954 | adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 955 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 956 | } |
---|
| 957 | else if(findpos(actuelposition,possibleposition[9])){ |
---|
| 958 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 959 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 960 | adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 961 | adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 962 | } |
---|
| 963 | else if(findpos(actuelposition,possibleposition[10])){ |
---|
| 964 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 965 | adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 966 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 967 | } |
---|
| 968 | else if(findpos(actuelposition,possibleposition[11])){ |
---|
| 969 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 970 | adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 971 | adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 972 | } |
---|
| 973 | else if(findpos(actuelposition,possibleposition[12])){ |
---|
| 974 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 975 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 976 | } |
---|
| 977 | else if(findpos(actuelposition,possibleposition[13])){ |
---|
| 978 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 979 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 980 | adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 981 | adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 982 | } |
---|
| 983 | else if(findpos(actuelposition,possibleposition[14])){ |
---|
| 984 | adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 985 | adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 986 | adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 987 | } |
---|
| 988 | else if(findpos(actuelposition,possibleposition[15])){ |
---|
| 989 | adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 990 | adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 991 | } |
---|
| 992 | else if(findpos(actuelposition,possibleposition[16])){ |
---|
| 993 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 994 | adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 995 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 996 | } |
---|
| 997 | else if(findpos(actuelposition,possibleposition[17])){ |
---|
| 998 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 999 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 1000 | } |
---|
| 1001 | else if(findpos(actuelposition,possibleposition[18])){ |
---|
| 1002 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 1003 | adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 1004 | } |
---|
| 1005 | else if(findpos(actuelposition,possibleposition[19])){ |
---|
| 1006 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 1007 | adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 1008 | adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 1009 | } |
---|
| 1010 | else if(findpos(actuelposition,possibleposition[20])){ |
---|
| 1011 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 1012 | adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 1013 | } |
---|
| 1014 | else if(findpos(actuelposition,possibleposition[21])){ |
---|
| 1015 | adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 1016 | adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 1017 | } |
---|
| 1018 | else if(findpos(actuelposition,possibleposition[22])){ |
---|
| 1019 | adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 1020 | adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 1021 | adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 1022 | } |
---|
| 1023 | else if(findpos(actuelposition,possibleposition[23])){ |
---|
| 1024 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 1025 | adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 1026 | } |
---|
| 1027 | else if(findpos(actuelposition,possibleposition[24])){ |
---|
| 1028 | adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 1029 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 1030 | } |
---|
| 1031 | else if(findpos(actuelposition,possibleposition[25])){ |
---|
| 1032 | adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 1033 | adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 1034 | } |
---|
| 1035 | else if(findpos(actuelposition,possibleposition[26])){ |
---|
| 1036 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 1037 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 1038 | adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 1039 | } |
---|
| 1040 | else if(findpos(actuelposition,possibleposition[27])){ |
---|
| 1041 | adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 1042 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 1043 | adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 1044 | } |
---|
| 1045 | else if(findpos(actuelposition,possibleposition[28])){ |
---|
| 1046 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 1047 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 1048 | adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 1049 | } |
---|
| 1050 | else if(findpos(actuelposition,possibleposition[29])){ |
---|
| 1051 | adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 1052 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 1053 | adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 1054 | } |
---|
| 1055 | else if(findpos(actuelposition,possibleposition[30])){ |
---|
| 1056 | adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 1057 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 1058 | adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 1059 | } |
---|
| 1060 | else if(findpos(actuelposition,possibleposition[31])){ |
---|
| 1061 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 1062 | adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 1063 | } |
---|
| 1064 | else if(findpos(actuelposition,possibleposition[32])){ |
---|
| 1065 | adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 1066 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 1067 | } |
---|
| 1068 | else if(findpos(actuelposition,possibleposition[33])){ |
---|
| 1069 | adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 1070 | adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 1071 | } |
---|
| 1072 | else if(findpos(actuelposition,possibleposition[34])){ |
---|
| 1073 | adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 1074 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 1075 | adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 1076 | adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 1077 | |
---|
| 1078 | } |
---|
| 1079 | else if(findpos(actuelposition,possibleposition[35])){ |
---|
| 1080 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 1081 | adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 1082 | adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 1083 | } |
---|
| 1084 | else if(findpos(actuelposition,possibleposition[36])){ |
---|
| 1085 | adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 1086 | adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 1087 | } |
---|
| 1088 | else if(findpos(actuelposition,possibleposition[37])){ |
---|
| 1089 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 1090 | adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 1091 | } |
---|
| 1092 | else if(findpos(actuelposition,possibleposition[38])){ |
---|
| 1093 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 1094 | adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 1095 | adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 1096 | } |
---|
| 1097 | else if(findpos(actuelposition,possibleposition[39])){ |
---|
| 1098 | adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 1099 | adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 1100 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 1101 | } |
---|
| 1102 | else if(findpos(actuelposition,possibleposition[40])){ |
---|
| 1103 | adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 1104 | adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 1105 | } |
---|
| 1106 | else if(findpos(actuelposition,possibleposition[41])){ |
---|
| 1107 | adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 1108 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 1109 | } |
---|
| 1110 | else if(findpos(actuelposition,possibleposition[42])){ |
---|
| 1111 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 1112 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 1113 | adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 1114 | } |
---|
| 1115 | else if(findpos(actuelposition,possibleposition[43])){ |
---|
| 1116 | adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 1117 | adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 1118 | } |
---|
| 1119 | else if(findpos(actuelposition,possibleposition[44])){ |
---|
| 1120 | adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 1121 | adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 1122 | } |
---|
| 1123 | else if(findpos(actuelposition,possibleposition[45])){ |
---|
| 1124 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 1125 | adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 1126 | adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 1127 | } |
---|
| 1128 | else if(findpos(actuelposition,possibleposition[46])){ |
---|
| 1129 | adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 1130 | adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 1131 | } |
---|
| 1132 | else if(findpos(actuelposition,possibleposition[47])){ |
---|
| 1133 | adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 1134 | adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 1135 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 1136 | } |
---|
| 1137 | else if(findpos(actuelposition,possibleposition[48])){ |
---|
| 1138 | adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 1139 | adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 1140 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 1141 | } |
---|
| 1142 | else if(findpos(actuelposition,possibleposition[49])){ |
---|
| 1143 | adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 1144 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 1145 | } |
---|
| 1146 | else if(findpos(actuelposition,possibleposition[50])){ |
---|
| 1147 | adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 1148 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 1149 | } |
---|
| 1150 | else if(findpos(actuelposition,possibleposition[51])){ |
---|
| 1151 | adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 1152 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 1153 | } |
---|
| 1154 | else if(findpos(actuelposition,possibleposition[52])){ |
---|
| 1155 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 1156 | adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 1157 | } |
---|
| 1158 | else if(findpos(actuelposition,possibleposition[53])){ |
---|
| 1159 | adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 1160 | adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 1161 | } |
---|
| 1162 | else if(findpos(actuelposition,possibleposition[54])){ |
---|
| 1163 | adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 1164 | adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 1165 | adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 1166 | } |
---|
| 1167 | else if(findpos(actuelposition,possibleposition[55])){ |
---|
| 1168 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 1169 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 1170 | } |
---|
| 1171 | else if(findpos(actuelposition,possibleposition[56])){ |
---|
| 1172 | adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 1173 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 1174 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 1175 | } |
---|
| 1176 | else if(findpos(actuelposition,possibleposition[57])){ |
---|
| 1177 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 1178 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 1179 | adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 1180 | adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 1181 | |
---|
| 1182 | } |
---|
| 1183 | else if(findpos(actuelposition,possibleposition[58])){ |
---|
| 1184 | adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 1185 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 1186 | adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 1187 | } |
---|
| 1188 | else if(findpos(actuelposition,possibleposition[59])){ |
---|
| 1189 | adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 1190 | adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 1191 | adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 1192 | } |
---|
| 1193 | else if(findpos(actuelposition,possibleposition[60])){ |
---|
| 1194 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 1195 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 1196 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 1197 | } |
---|
| 1198 | else if(findpos(actuelposition,possibleposition[61])){ |
---|
| 1199 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 1200 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 1201 | adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 1202 | } |
---|
| 1203 | else if(findpos(actuelposition,possibleposition[62])){ |
---|
| 1204 | adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 1205 | adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 1206 | } |
---|
| 1207 | else if(findpos(actuelposition,possibleposition[63])){ |
---|
| 1208 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 1209 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 1210 | } |
---|
| 1211 | else if(findpos(actuelposition,possibleposition[64])){ |
---|
| 1212 | adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 1213 | adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 1214 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 1215 | } |
---|
| 1216 | else if(findpos(actuelposition,possibleposition[65])){ |
---|
| 1217 | adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 1218 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 1219 | } |
---|
| 1220 | else if(findpos(actuelposition,possibleposition[66])){ |
---|
| 1221 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 1222 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 1223 | } |
---|
[12319] | 1224 | }*/ |
---|
[12316] | 1225 | |
---|
| 1226 | |
---|
[12317] | 1227 | |
---|
| 1228 | |
---|
| 1229 | //functions taken from PacmanPink |
---|
| 1230 | |
---|
| 1231 | |
---|
| 1232 | |
---|
| 1233 | |
---|
| 1234 | |
---|
| 1235 | Vector3 PacmanGhost::diffVector (Vector3 start, Vector3 goal){ |
---|
| 1236 | |
---|
| 1237 | Vector3 result; |
---|
| 1238 | result.x=goal.x-start.x; |
---|
| 1239 | result.z=goal.z-start.z; |
---|
| 1240 | return result; |
---|
| 1241 | } |
---|
| 1242 | |
---|
[12318] | 1243 | |
---|
| 1244 | bool PacmanGhost::playerFindPos(Vector3 one, Vector3 other){ |
---|
| 1245 | if((abs(one.x - other.x)<15) && (abs(one.z - other.z)<15)) return true; |
---|
| 1246 | return false; |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | |
---|
| 1250 | |
---|
| 1251 | |
---|
[12317] | 1252 | int PacmanGhost::findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){ |
---|
| 1253 | //return 0 for south, 1 for west, 2 for north, 3 for east |
---|
| 1254 | |
---|
| 1255 | |
---|
[12318] | 1256 | if(playerFindPos(playerPosBefore, playerPos)){ |
---|
| 1257 | //if player is still near last crossed point |
---|
[12317] | 1258 | |
---|
[12318] | 1259 | return 4; //return the last crossed point for simplicity |
---|
| 1260 | } |
---|
| 1261 | |
---|
| 1262 | |
---|
| 1263 | if(abs(playerPos.x-playerPosBefore.x)<14){ //player is moving vertically |
---|
| 1264 | if((playerPos.z-playerPosBefore.z)<0){//move west |
---|
| 1265 | return 0; |
---|
| 1266 | } |
---|
| 1267 | if((playerPos.z-playerPosBefore.z)>0){//move east |
---|
| 1268 | return 2; |
---|
| 1269 | } |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | if(abs(playerPos.z-playerPosBefore.z)<14){ //player is moving horizontally |
---|
| 1273 | if((playerPos.x-playerPosBefore.x)<0){//move south |
---|
| 1274 | return 1; |
---|
| 1275 | } |
---|
| 1276 | if((playerPos.x-playerPosBefore.x)>0){//move north |
---|
| 1277 | return 3; |
---|
| 1278 | } |
---|
| 1279 | } |
---|
| 1280 | |
---|
| 1281 | |
---|
| 1282 | /*Vector3 difference = diffVector(playerPosBefore, playerPos); |
---|
[12317] | 1283 | if((difference.z < 0)&&(difference.z>difference.x)){ //move south |
---|
| 1284 | |
---|
| 1285 | return 0; |
---|
| 1286 | } |
---|
| 1287 | else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north |
---|
| 1288 | |
---|
| 1289 | return 2; |
---|
| 1290 | } |
---|
| 1291 | else if((difference.x < 0)&&(difference.x > difference.z )){//move west |
---|
| 1292 | |
---|
| 1293 | return 1; |
---|
| 1294 | } |
---|
| 1295 | |
---|
| 1296 | else if((difference.x>0)&&(difference.x>difference.z)){ //move east |
---|
| 1297 | return 3; |
---|
| 1298 | |
---|
| 1299 | } |
---|
| 1300 | |
---|
| 1301 | else { //default move west Can still be changed |
---|
| 1302 | |
---|
| 1303 | return 1; |
---|
[12318] | 1304 | }*/ |
---|
[12317] | 1305 | |
---|
| 1306 | } |
---|
| 1307 | |
---|
| 1308 | Vector3 PacmanGhost::getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){ |
---|
| 1309 | //return the Vector3 point that Pinky should target to |
---|
| 1310 | //be in front of pacman |
---|
| 1311 | |
---|
[12318] | 1312 | if(indexForSWNE==4){ |
---|
[12322] | 1313 | //std::cout<<"Ryukyu"<<endl; |
---|
[12318] | 1314 | return pacLasVisPos; |
---|
| 1315 | } |
---|
| 1316 | |
---|
[12317] | 1317 | Vector3 listOfNeighboors[4]; |
---|
| 1318 | //first element is south, 2nd west, 3d north, 4th east |
---|
| 1319 | |
---|
| 1320 | if(findpos(pacLasVisPos,possibleposition[0])){ |
---|
| 1321 | //no south neighbor |
---|
| 1322 | listOfNeighboors[1]=possibleposition[19]; // west neighbor |
---|
| 1323 | listOfNeighboors[2]=possibleposition[17]; //north |
---|
| 1324 | listOfNeighboors[3]=possibleposition[1]; //east |
---|
| 1325 | return listOfNeighboors[indexForSWNE]; |
---|
| 1326 | } |
---|
| 1327 | else if(findpos(pacLasVisPos,possibleposition[1])){ |
---|
| 1328 | listOfNeighboors[1]=possibleposition[0]; // west neighbor |
---|
| 1329 | listOfNeighboors[2]=possibleposition[2]; //north |
---|
| 1330 | return listOfNeighboors[indexForSWNE]; |
---|
| 1331 | } |
---|
| 1332 | else if(findpos(pacLasVisPos,possibleposition[2])){ |
---|
| 1333 | listOfNeighboors[0]=possibleposition[1]; //south |
---|
| 1334 | listOfNeighboors[1]=possibleposition[3]; //west |
---|
| 1335 | return listOfNeighboors[indexForSWNE]; |
---|
| 1336 | } |
---|
| 1337 | else if(findpos(pacLasVisPos,possibleposition[3])){ |
---|
| 1338 | listOfNeighboors[1]=possibleposition[4]; //west |
---|
| 1339 | listOfNeighboors[2]=possibleposition[5]; //north |
---|
| 1340 | listOfNeighboors[3]=possibleposition[2]; //east |
---|
| 1341 | return listOfNeighboors[indexForSWNE]; |
---|
| 1342 | } |
---|
| 1343 | else if(findpos(pacLasVisPos,possibleposition[4])){ |
---|
| 1344 | listOfNeighboors[2]=possibleposition[6]; //north |
---|
| 1345 | listOfNeighboors[3]=possibleposition[3]; //east |
---|
| 1346 | return listOfNeighboors[indexForSWNE]; |
---|
| 1347 | } |
---|
| 1348 | else if(findpos(pacLasVisPos,possibleposition[5])){ |
---|
| 1349 | listOfNeighboors[0]=possibleposition[3]; //south |
---|
| 1350 | listOfNeighboors[3]=possibleposition[7]; //east |
---|
| 1351 | return listOfNeighboors[indexForSWNE]; |
---|
| 1352 | } |
---|
| 1353 | else if(findpos(pacLasVisPos,possibleposition[6])){ |
---|
| 1354 | listOfNeighboors[0]=possibleposition[4]; //south |
---|
| 1355 | listOfNeighboors[1]=possibleposition[26]; //west |
---|
| 1356 | listOfNeighboors[2]=possibleposition[9]; //north |
---|
| 1357 | return listOfNeighboors[indexForSWNE]; |
---|
| 1358 | } |
---|
| 1359 | else if(findpos(pacLasVisPos,possibleposition[7])){ |
---|
| 1360 | listOfNeighboors[1]=possibleposition[5]; //west |
---|
| 1361 | listOfNeighboors[2]=possibleposition[8]; //north |
---|
| 1362 | return listOfNeighboors[indexForSWNE]; |
---|
| 1363 | } |
---|
| 1364 | else if(findpos(pacLasVisPos,possibleposition[8])){ |
---|
| 1365 | listOfNeighboors[0]=possibleposition[7]; //south |
---|
| 1366 | listOfNeighboors[1]=possibleposition[9]; //west |
---|
| 1367 | return listOfNeighboors[indexForSWNE]; |
---|
| 1368 | } |
---|
| 1369 | else if(findpos(pacLasVisPos,possibleposition[9])){ |
---|
| 1370 | listOfNeighboors[0]=possibleposition[6]; //south |
---|
| 1371 | listOfNeighboors[1]=possibleposition[38]; //west |
---|
| 1372 | listOfNeighboors[2]=possibleposition[10]; //north |
---|
| 1373 | listOfNeighboors[3]=possibleposition[8]; //east |
---|
| 1374 | return listOfNeighboors[indexForSWNE]; |
---|
| 1375 | } |
---|
| 1376 | else if(findpos(pacLasVisPos,possibleposition[10])){ |
---|
[12318] | 1377 | |
---|
| 1378 | if(indexForSWNE==3){ //nothing eastward |
---|
| 1379 | return pacLasVisPos; |
---|
| 1380 | } |
---|
| 1381 | |
---|
[12317] | 1382 | listOfNeighboors[0]=possibleposition[9]; //south |
---|
| 1383 | listOfNeighboors[1]=possibleposition[45]; //west |
---|
| 1384 | listOfNeighboors[2]=possibleposition[11]; //north |
---|
| 1385 | return listOfNeighboors[indexForSWNE]; |
---|
| 1386 | } |
---|
| 1387 | else if(findpos(pacLasVisPos,possibleposition[11])){ |
---|
| 1388 | listOfNeighboors[0]=possibleposition[10]; //south |
---|
| 1389 | listOfNeighboors[2]=possibleposition[13]; //north |
---|
| 1390 | listOfNeighboors[3]=possibleposition[12]; //east |
---|
| 1391 | return listOfNeighboors[indexForSWNE]; |
---|
| 1392 | } |
---|
| 1393 | else if(findpos(pacLasVisPos,possibleposition[12])){ |
---|
| 1394 | listOfNeighboors[1]=possibleposition[11]; //west |
---|
| 1395 | listOfNeighboors[2]=possibleposition[14]; //north |
---|
| 1396 | return listOfNeighboors[indexForSWNE]; |
---|
| 1397 | } |
---|
| 1398 | else if(findpos(pacLasVisPos,possibleposition[13])){ |
---|
| 1399 | listOfNeighboors[0]=possibleposition[11]; //south |
---|
| 1400 | listOfNeighboors[1]=possibleposition[61]; //west |
---|
| 1401 | listOfNeighboors[2]=possibleposition[16]; //north |
---|
| 1402 | listOfNeighboors[3]=possibleposition[14]; //east |
---|
| 1403 | return listOfNeighboors[indexForSWNE]; |
---|
| 1404 | } |
---|
| 1405 | else if(findpos(pacLasVisPos,possibleposition[14])){ |
---|
| 1406 | listOfNeighboors[0]=possibleposition[12]; //south |
---|
| 1407 | listOfNeighboors[1]=possibleposition[13]; //west |
---|
| 1408 | listOfNeighboors[2]=possibleposition[15]; //north |
---|
| 1409 | return listOfNeighboors[indexForSWNE]; |
---|
| 1410 | } |
---|
| 1411 | else if(findpos(pacLasVisPos,possibleposition[15])){ |
---|
| 1412 | listOfNeighboors[0]=possibleposition[14]; //south |
---|
| 1413 | listOfNeighboors[1]=possibleposition[16]; //west |
---|
| 1414 | return listOfNeighboors[indexForSWNE]; |
---|
| 1415 | } |
---|
| 1416 | else if(findpos(pacLasVisPos,possibleposition[16])){ |
---|
| 1417 | listOfNeighboors[0]=possibleposition[13]; //south |
---|
| 1418 | listOfNeighboors[1]=possibleposition[62]; //west |
---|
| 1419 | listOfNeighboors[2]=possibleposition[15]; //north |
---|
| 1420 | return listOfNeighboors[indexForSWNE]; |
---|
| 1421 | } |
---|
| 1422 | else if(findpos(pacLasVisPos,possibleposition[17])){ |
---|
| 1423 | listOfNeighboors[0]=possibleposition[0]; //south |
---|
| 1424 | listOfNeighboors[3]=possibleposition[25]; //east |
---|
| 1425 | return listOfNeighboors[indexForSWNE]; |
---|
| 1426 | } |
---|
| 1427 | else if(findpos(pacLasVisPos,possibleposition[18])){ |
---|
| 1428 | listOfNeighboors[0]=possibleposition[19]; //south |
---|
| 1429 | listOfNeighboors[1]=possibleposition[24]; //west |
---|
| 1430 | return listOfNeighboors[indexForSWNE]; |
---|
| 1431 | } |
---|
| 1432 | else if(findpos(pacLasVisPos,possibleposition[19])){ |
---|
| 1433 | listOfNeighboors[1]=possibleposition[20]; //west |
---|
| 1434 | listOfNeighboors[2]=possibleposition[18]; //north |
---|
| 1435 | listOfNeighboors[3]=possibleposition[0]; //east |
---|
| 1436 | return listOfNeighboors[indexForSWNE]; |
---|
| 1437 | } |
---|
| 1438 | else if(findpos(pacLasVisPos,possibleposition[20])){ |
---|
| 1439 | listOfNeighboors[2]=possibleposition[21]; //north |
---|
| 1440 | listOfNeighboors[3]=possibleposition[19]; //east |
---|
| 1441 | return listOfNeighboors[indexForSWNE]; |
---|
| 1442 | } |
---|
| 1443 | else if(findpos(pacLasVisPos,possibleposition[21])){ |
---|
| 1444 | listOfNeighboors[0]=possibleposition[20]; //south |
---|
| 1445 | listOfNeighboors[3]=possibleposition[22]; //east |
---|
| 1446 | return listOfNeighboors[indexForSWNE]; |
---|
| 1447 | } |
---|
| 1448 | else if(findpos(pacLasVisPos,possibleposition[22])){ |
---|
| 1449 | listOfNeighboors[1]=possibleposition[21]; //west |
---|
| 1450 | listOfNeighboors[2]=possibleposition[31]; //north |
---|
| 1451 | listOfNeighboors[3]=possibleposition[23]; //east |
---|
| 1452 | return listOfNeighboors[indexForSWNE]; |
---|
| 1453 | } |
---|
| 1454 | else if(findpos(pacLasVisPos,possibleposition[23])){ |
---|
| 1455 | listOfNeighboors[1]=possibleposition[22]; //west |
---|
| 1456 | listOfNeighboors[2]=possibleposition[30]; //north |
---|
| 1457 | return listOfNeighboors[indexForSWNE]; |
---|
| 1458 | } |
---|
| 1459 | else if(findpos(pacLasVisPos,possibleposition[24])){ |
---|
| 1460 | listOfNeighboors[2]=possibleposition[29]; //north |
---|
| 1461 | listOfNeighboors[3]=possibleposition[18]; //east |
---|
| 1462 | return listOfNeighboors[indexForSWNE]; |
---|
| 1463 | } |
---|
| 1464 | else if(findpos(pacLasVisPos,possibleposition[25])){ |
---|
| 1465 | listOfNeighboors[1]=possibleposition[17]; //west |
---|
| 1466 | listOfNeighboors[2]=possibleposition[26]; //north |
---|
| 1467 | return listOfNeighboors[indexForSWNE]; |
---|
| 1468 | } |
---|
| 1469 | else if(findpos(pacLasVisPos,possibleposition[26])){ |
---|
| 1470 | listOfNeighboors[0]=possibleposition[25]; //south |
---|
| 1471 | listOfNeighboors[1]=possibleposition[27]; //west |
---|
| 1472 | listOfNeighboors[3]=possibleposition[6]; //east |
---|
| 1473 | return listOfNeighboors[indexForSWNE]; |
---|
| 1474 | } |
---|
| 1475 | else if(findpos(pacLasVisPos,possibleposition[27])){ |
---|
| 1476 | listOfNeighboors[1]=possibleposition[28]; //west |
---|
| 1477 | listOfNeighboors[2]=possibleposition[37]; //north |
---|
| 1478 | listOfNeighboors[3]=possibleposition[26]; //east |
---|
| 1479 | return listOfNeighboors[indexForSWNE]; |
---|
| 1480 | } |
---|
| 1481 | else if(findpos(pacLasVisPos,possibleposition[28])){ |
---|
| 1482 | listOfNeighboors[1]=possibleposition[29]; //west |
---|
| 1483 | listOfNeighboors[2]=possibleposition[36]; //north |
---|
| 1484 | listOfNeighboors[3]=possibleposition[27]; //east |
---|
| 1485 | return listOfNeighboors[indexForSWNE]; |
---|
| 1486 | } |
---|
| 1487 | else if(findpos(pacLasVisPos,possibleposition[29])){ |
---|
| 1488 | listOfNeighboors[0]=possibleposition[24]; //south |
---|
| 1489 | listOfNeighboors[1]=possibleposition[30]; //west |
---|
| 1490 | listOfNeighboors[3]=possibleposition[28]; //east |
---|
| 1491 | return listOfNeighboors[indexForSWNE]; |
---|
| 1492 | } |
---|
| 1493 | else if(findpos(pacLasVisPos,possibleposition[30])){ |
---|
| 1494 | listOfNeighboors[0]=possibleposition[23]; //south |
---|
| 1495 | listOfNeighboors[2]=possibleposition[34]; //north |
---|
| 1496 | listOfNeighboors[3]=possibleposition[29]; //east |
---|
| 1497 | return listOfNeighboors[indexForSWNE]; |
---|
| 1498 | } |
---|
| 1499 | else if(findpos(pacLasVisPos,possibleposition[31])){ |
---|
| 1500 | listOfNeighboors[0]=possibleposition[22]; //south |
---|
| 1501 | listOfNeighboors[1]=possibleposition[32]; //west |
---|
| 1502 | return listOfNeighboors[indexForSWNE]; |
---|
| 1503 | } |
---|
| 1504 | else if(findpos(pacLasVisPos,possibleposition[32])){ |
---|
| 1505 | listOfNeighboors[2]=possibleposition[33]; //north |
---|
| 1506 | listOfNeighboors[3]=possibleposition[31]; //east |
---|
| 1507 | return listOfNeighboors[indexForSWNE]; |
---|
| 1508 | } |
---|
| 1509 | else if(findpos(pacLasVisPos,possibleposition[33])){ |
---|
| 1510 | listOfNeighboors[0]=possibleposition[32]; //south |
---|
| 1511 | listOfNeighboors[3]=possibleposition[34]; //east |
---|
| 1512 | return listOfNeighboors[indexForSWNE]; |
---|
| 1513 | } |
---|
| 1514 | else if(findpos(pacLasVisPos,possibleposition[34])){ |
---|
| 1515 | listOfNeighboors[0]=possibleposition[30]; //south |
---|
| 1516 | listOfNeighboors[1]=possibleposition[33]; //west |
---|
| 1517 | listOfNeighboors[2]=possibleposition[92]; //north |
---|
| 1518 | listOfNeighboors[3]=possibleposition[35]; //east |
---|
| 1519 | return listOfNeighboors[indexForSWNE]; |
---|
| 1520 | } |
---|
| 1521 | else if(findpos(pacLasVisPos,possibleposition[35])){ |
---|
| 1522 | listOfNeighboors[1]=possibleposition[34]; //west |
---|
| 1523 | listOfNeighboors[2]=possibleposition[91]; //north |
---|
| 1524 | listOfNeighboors[3]=possibleposition[36]; //east |
---|
| 1525 | return listOfNeighboors[indexForSWNE]; |
---|
| 1526 | } |
---|
| 1527 | else if(findpos(pacLasVisPos,possibleposition[36])){ |
---|
| 1528 | listOfNeighboors[0]=possibleposition[28]; //south |
---|
| 1529 | listOfNeighboors[1]=possibleposition[35]; //west |
---|
| 1530 | return listOfNeighboors[indexForSWNE]; |
---|
| 1531 | } |
---|
| 1532 | else if(findpos(pacLasVisPos,possibleposition[37])){ |
---|
| 1533 | listOfNeighboors[0]=possibleposition[27]; //south |
---|
| 1534 | listOfNeighboors[3]=possibleposition[38]; //east |
---|
| 1535 | return listOfNeighboors[indexForSWNE]; |
---|
| 1536 | } |
---|
| 1537 | else if(findpos(pacLasVisPos,possibleposition[38])){ |
---|
| 1538 | listOfNeighboors[1]=possibleposition[37]; //west |
---|
| 1539 | listOfNeighboors[2]=possibleposition[39]; //north |
---|
| 1540 | listOfNeighboors[3]=possibleposition[9]; //east |
---|
| 1541 | return listOfNeighboors[indexForSWNE]; |
---|
| 1542 | } |
---|
| 1543 | else if(findpos(pacLasVisPos,possibleposition[39])){ |
---|
| 1544 | listOfNeighboors[0]=possibleposition[38]; //south |
---|
| 1545 | listOfNeighboors[1]=possibleposition[40]; //west |
---|
| 1546 | listOfNeighboors[2]=possibleposition[45]; //north |
---|
| 1547 | return listOfNeighboors[indexForSWNE]; |
---|
| 1548 | } |
---|
| 1549 | else if(findpos(pacLasVisPos,possibleposition[40])){ |
---|
| 1550 | listOfNeighboors[1]=possibleposition[41]; //west |
---|
| 1551 | //Not return in center |
---|
| 1552 | listOfNeighboors[3]=possibleposition[39]; //east |
---|
| 1553 | return listOfNeighboors[indexForSWNE]; |
---|
| 1554 | } |
---|
| 1555 | else if(findpos(pacLasVisPos,possibleposition[41])){ |
---|
| 1556 | listOfNeighboors[0]=possibleposition[35]; //south |
---|
| 1557 | listOfNeighboors[2]=possibleposition[43]; //north |
---|
| 1558 | listOfNeighboors[3]=possibleposition[40]; //east |
---|
| 1559 | return listOfNeighboors[indexForSWNE]; |
---|
| 1560 | } |
---|
| 1561 | else if(findpos(pacLasVisPos,possibleposition[42])){ |
---|
[12318] | 1562 | |
---|
| 1563 | if(indexForSWNE==1){//nothing westward |
---|
| 1564 | return pacLasVisPos; |
---|
| 1565 | } |
---|
| 1566 | |
---|
[12317] | 1567 | listOfNeighboors[0]=possibleposition[39]; //south |
---|
| 1568 | listOfNeighboors[2]=possibleposition[59]; //north |
---|
| 1569 | listOfNeighboors[3]=possibleposition[43]; //east |
---|
| 1570 | return listOfNeighboors[indexForSWNE]; |
---|
| 1571 | } |
---|
| 1572 | else if(findpos(pacLasVisPos,possibleposition[43])){ |
---|
| 1573 | listOfNeighboors[0]=possibleposition[41]; //south |
---|
| 1574 | listOfNeighboors[1]=possibleposition[42]; //west |
---|
| 1575 | listOfNeighboors[2]=possibleposition[46]; //north |
---|
| 1576 | return listOfNeighboors[indexForSWNE]; |
---|
| 1577 | } |
---|
| 1578 | else if(findpos(pacLasVisPos,possibleposition[44])){ |
---|
| 1579 | listOfNeighboors[0]=possibleposition[40]; //south |
---|
| 1580 | listOfNeighboors[2]=possibleposition[66]; //north |
---|
| 1581 | return listOfNeighboors[indexForSWNE]; |
---|
| 1582 | } |
---|
| 1583 | else if(findpos(pacLasVisPos,possibleposition[45])){ |
---|
| 1584 | listOfNeighboors[0]=possibleposition[39]; //south |
---|
| 1585 | listOfNeighboors[2]=possibleposition[49]; //north |
---|
| 1586 | listOfNeighboors[3]=possibleposition[10]; //east |
---|
| 1587 | return listOfNeighboors[indexForSWNE]; |
---|
| 1588 | } |
---|
| 1589 | else if(findpos(pacLasVisPos,possibleposition[46])){ |
---|
| 1590 | listOfNeighboors[0]=possibleposition[43]; //south |
---|
| 1591 | listOfNeighboors[3]=possibleposition[47]; //east |
---|
| 1592 | return listOfNeighboors[indexForSWNE]; |
---|
| 1593 | } |
---|
| 1594 | else if(findpos(pacLasVisPos,possibleposition[47])){ |
---|
| 1595 | listOfNeighboors[1]=possibleposition[46]; //west |
---|
| 1596 | listOfNeighboors[2]=possibleposition[52]; //north |
---|
| 1597 | listOfNeighboors[3]=possibleposition[66]; //east |
---|
| 1598 | return listOfNeighboors[indexForSWNE]; |
---|
| 1599 | } |
---|
| 1600 | else if(findpos(pacLasVisPos,possibleposition[48])){ |
---|
| 1601 | listOfNeighboors[1]=possibleposition[66]; //west |
---|
| 1602 | listOfNeighboors[2]=possibleposition[51]; //north |
---|
| 1603 | listOfNeighboors[3]=possibleposition[49]; //east |
---|
| 1604 | return listOfNeighboors[indexForSWNE]; |
---|
| 1605 | } |
---|
| 1606 | else if(findpos(pacLasVisPos,possibleposition[49])){ |
---|
| 1607 | listOfNeighboors[0]=possibleposition[45]; //south |
---|
| 1608 | listOfNeighboors[1]=possibleposition[48]; //west |
---|
| 1609 | return listOfNeighboors[indexForSWNE]; |
---|
| 1610 | } |
---|
| 1611 | else if(findpos(pacLasVisPos,possibleposition[50])){ |
---|
| 1612 | listOfNeighboors[1]=possibleposition[51]; //west |
---|
| 1613 | listOfNeighboors[2]=possibleposition[61]; //north |
---|
| 1614 | return listOfNeighboors[indexForSWNE]; |
---|
| 1615 | } |
---|
| 1616 | else if(findpos(pacLasVisPos,possibleposition[51])){ |
---|
| 1617 | listOfNeighboors[0]=possibleposition[48]; //south |
---|
| 1618 | listOfNeighboors[3]=possibleposition[50]; //east |
---|
| 1619 | return listOfNeighboors[indexForSWNE]; |
---|
| 1620 | } |
---|
| 1621 | else if(findpos(pacLasVisPos,possibleposition[52])){ |
---|
| 1622 | listOfNeighboors[0]=possibleposition[47]; //south |
---|
| 1623 | listOfNeighboors[1]=possibleposition[53]; //west |
---|
| 1624 | return listOfNeighboors[indexForSWNE]; |
---|
| 1625 | } |
---|
| 1626 | else if(findpos(pacLasVisPos,possibleposition[53])){ |
---|
| 1627 | listOfNeighboors[2]=possibleposition[58]; //north |
---|
| 1628 | listOfNeighboors[3]=possibleposition[52]; //east |
---|
| 1629 | return listOfNeighboors[indexForSWNE]; |
---|
| 1630 | } |
---|
| 1631 | else if(findpos(pacLasVisPos,possibleposition[54])){ |
---|
| 1632 | listOfNeighboors[0]=possibleposition[42]; //south |
---|
| 1633 | listOfNeighboors[1]=possibleposition[55]; //west |
---|
| 1634 | listOfNeighboors[2]=possibleposition[57]; //north |
---|
| 1635 | return listOfNeighboors[indexForSWNE]; |
---|
| 1636 | } |
---|
| 1637 | else if(findpos(pacLasVisPos,possibleposition[55])){ |
---|
| 1638 | listOfNeighboors[2]=possibleposition[56]; //north |
---|
| 1639 | listOfNeighboors[3]=possibleposition[54]; //east |
---|
| 1640 | return listOfNeighboors[indexForSWNE]; |
---|
| 1641 | } |
---|
| 1642 | else if(findpos(pacLasVisPos,possibleposition[56])){ |
---|
| 1643 | listOfNeighboors[0]=possibleposition[55]; //south |
---|
| 1644 | listOfNeighboors[2]=possibleposition[65]; //north |
---|
| 1645 | listOfNeighboors[3]=possibleposition[57]; //east |
---|
| 1646 | return listOfNeighboors[indexForSWNE]; |
---|
| 1647 | } |
---|
| 1648 | else if(findpos(pacLasVisPos,possibleposition[57])){ |
---|
| 1649 | listOfNeighboors[0]=possibleposition[54]; //south |
---|
| 1650 | listOfNeighboors[1]=possibleposition[56]; //west |
---|
| 1651 | listOfNeighboors[2]=possibleposition[64]; //north |
---|
| 1652 | listOfNeighboors[3]=possibleposition[58]; //east |
---|
| 1653 | return listOfNeighboors[indexForSWNE]; |
---|
| 1654 | } |
---|
| 1655 | else if(findpos(pacLasVisPos,possibleposition[58])){ |
---|
| 1656 | listOfNeighboors[0]=possibleposition[53]; //south |
---|
| 1657 | listOfNeighboors[1]=possibleposition[57]; //west |
---|
| 1658 | listOfNeighboors[3]=possibleposition[59]; //east |
---|
| 1659 | return listOfNeighboors[indexForSWNE]; |
---|
| 1660 | } |
---|
| 1661 | else if(findpos(pacLasVisPos,possibleposition[59])){ |
---|
| 1662 | listOfNeighboors[1]=possibleposition[58]; //west |
---|
| 1663 | listOfNeighboors[2]=possibleposition[63]; //north |
---|
| 1664 | listOfNeighboors[3]=possibleposition[60]; //east |
---|
| 1665 | return listOfNeighboors[indexForSWNE]; |
---|
| 1666 | } |
---|
| 1667 | else if(findpos(pacLasVisPos,possibleposition[60])){ |
---|
| 1668 | listOfNeighboors[1]=possibleposition[59]; //west |
---|
| 1669 | listOfNeighboors[2]=possibleposition[62]; //north |
---|
| 1670 | listOfNeighboors[3]=possibleposition[61]; //east |
---|
| 1671 | return listOfNeighboors[indexForSWNE]; |
---|
| 1672 | } |
---|
| 1673 | else if(findpos(pacLasVisPos,possibleposition[61])){ |
---|
| 1674 | listOfNeighboors[0]=possibleposition[50]; //south |
---|
| 1675 | listOfNeighboors[1]=possibleposition[60]; //west |
---|
| 1676 | listOfNeighboors[3]=possibleposition[13]; //east |
---|
| 1677 | return listOfNeighboors[indexForSWNE]; |
---|
| 1678 | } |
---|
| 1679 | else if(findpos(pacLasVisPos,possibleposition[62])){ |
---|
| 1680 | listOfNeighboors[0]=possibleposition[60]; //south |
---|
| 1681 | listOfNeighboors[3]=possibleposition[16]; //east |
---|
| 1682 | return listOfNeighboors[indexForSWNE]; |
---|
| 1683 | } |
---|
| 1684 | else if(findpos(pacLasVisPos,possibleposition[63])){ |
---|
| 1685 | listOfNeighboors[0]=possibleposition[59]; //south |
---|
| 1686 | listOfNeighboors[1]=possibleposition[64]; //west |
---|
| 1687 | return listOfNeighboors[indexForSWNE]; |
---|
| 1688 | } |
---|
| 1689 | else if(findpos(pacLasVisPos,possibleposition[64])){ |
---|
| 1690 | listOfNeighboors[0]=possibleposition[57]; //south |
---|
| 1691 | listOfNeighboors[1]=possibleposition[65]; //west |
---|
| 1692 | listOfNeighboors[3]=possibleposition[63]; //east |
---|
| 1693 | return listOfNeighboors[indexForSWNE]; |
---|
| 1694 | } |
---|
| 1695 | else if(findpos(pacLasVisPos,possibleposition[65])){ |
---|
| 1696 | listOfNeighboors[0]=possibleposition[56]; //south |
---|
| 1697 | listOfNeighboors[3]=possibleposition[64]; //east |
---|
| 1698 | return listOfNeighboors[indexForSWNE]; |
---|
| 1699 | } |
---|
| 1700 | else if(findpos(pacLasVisPos,possibleposition[66])){ |
---|
| 1701 | //Not back in center |
---|
| 1702 | listOfNeighboors[1]=possibleposition[47]; //west |
---|
| 1703 | listOfNeighboors[3]=possibleposition[48]; //east |
---|
| 1704 | return listOfNeighboors[indexForSWNE]; |
---|
| 1705 | } |
---|
| 1706 | |
---|
| 1707 | } |
---|
| 1708 | |
---|
| 1709 | |
---|
[11915] | 1710 | } |
---|