[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 | |
---|
[12316] | 249 | |
---|
| 250 | |
---|
| 251 | /// |
---|
| 252 | //// getShortestPath ///////// |
---|
| 253 | /// |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal){ |
---|
| 259 | //this function should then somehow produce the algorithm and call all other functions |
---|
| 260 | //and finally return the best neighboor of the actual position of the pacman |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | graphVertex listOfVerticesM[67]; //our list of all possible graphs |
---|
| 264 | graphVertex* actualVertex;// = new graphVertex(); //we will walk through the array with a pointer |
---|
| 265 | |
---|
| 266 | if(start==goal){ // basic case |
---|
| 267 | return start; |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | for(int an=0; an < 67; an++){ |
---|
| 271 | listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file |
---|
| 272 | if(start==possibleposition[an]){ |
---|
| 273 | actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array |
---|
| 274 | //cout<<an<<endl; |
---|
| 275 | } |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | actualVertex->alreadyVisited=true; //our start point is now visited |
---|
| 279 | actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0 |
---|
| 280 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 281 | // second parameter is an array ! //third is our global array |
---|
| 282 | |
---|
| 283 | while(actualVertex->position!=goal){ |
---|
| 284 | for(int h=0;h < 4; h++){ |
---|
| 285 | if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex |
---|
| 286 | |
---|
| 287 | //h=2 and 3 never reached |
---|
| 288 | updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]); |
---|
| 289 | } //we "update" the neighboors of our new visited vertex |
---|
| 290 | |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | actualVertex=findNextVertexToConsider(listOfVerticesM); |
---|
| 294 | actualVertex->alreadyVisited=true; |
---|
| 295 | //cout<<actualVertex->position<<endl; |
---|
| 296 | if(actualVertex->position!=goal){ |
---|
| 297 | findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); |
---|
| 298 | //we find the neighboors of our new visited vertex |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | //cout<<"meuejeeke"<<endl; never reached |
---|
| 303 | |
---|
| 304 | //we should have reached our goal at this point |
---|
| 305 | |
---|
| 306 | while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor |
---|
| 307 | actualVertex=actualVertex->actuelPredecessor; |
---|
| 308 | } |
---|
| 309 | // the predecessor is our starting point, in other words we are now on an |
---|
| 310 | //adjacent vertex of the start |
---|
| 311 | |
---|
| 312 | return actualVertex->position; //we return the position of this - adjacent to start - vertex |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | //end of getShortestPath |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){ |
---|
| 319 | //cout<<hgj++<<endl; |
---|
| 320 | Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); |
---|
| 321 | |
---|
| 322 | return differenceVector.x+differenceVector.z; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ |
---|
| 326 | //apply this method to all non visited neighboors of a vertex. |
---|
| 327 | // This method should always be run on a vertex after we marked it as visited. |
---|
| 328 | if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. |
---|
| 329 | if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&& |
---|
| 330 | (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + |
---|
| 331 | graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case ! |
---|
| 332 | |
---|
| 333 | neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + |
---|
| 334 | graphDistance(vertex.position, neighboor.position); |
---|
| 335 | neighboor.actuelPredecessor = &vertex; |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex){ |
---|
| 341 | //find nearest non visited neighboor of a given already visited vertex |
---|
| 342 | int shortestDistance = -1; |
---|
| 343 | graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any. |
---|
| 344 | //Also, if all neighboors are already visited, we return nullptr, i.e. there is no |
---|
| 345 | //nearest non visited neighboor. |
---|
| 346 | for(int i=0; i < 4; i++){ |
---|
| 347 | if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)){ |
---|
| 348 | if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor |
---|
| 349 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 350 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 351 | //cout<<shortestDistance<<endl; |
---|
| 352 | } |
---|
| 353 | else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ |
---|
| 354 | shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); |
---|
| 355 | nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! |
---|
| 356 | //cout<<(hgj++)%4<<endl; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses ! |
---|
| 361 | //cout<<hgj++<<endl; |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex in our listOfVertices array |
---|
| 366 | |
---|
| 367 | int shortestDistance = -1; |
---|
| 368 | graphVertex* nextVertexToConsider; |
---|
| 369 | |
---|
| 370 | for(int i=0; i < 67; i++){ //we loop over all possible positions |
---|
| 371 | |
---|
| 372 | if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited |
---|
| 373 | |
---|
| 374 | findNearestNonVisitedNeighboor(listOfVerticesP[i]); //we update nearest neighboor |
---|
| 375 | //of all visited vertices given that one of the nearest neighboor of a visited |
---|
| 376 | // vertex is now also visited because it was chosen as next optimal vertex |
---|
| 377 | |
---|
| 378 | if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate! |
---|
| 379 | if(shortestDistance==-1){ //our first possible candidate |
---|
| 380 | |
---|
| 381 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 382 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 383 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 384 | |
---|
| 385 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 386 | //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor |
---|
| 387 | |
---|
| 388 | } |
---|
| 389 | else if(shortestDistance > graphDistance(listOfVerticesP[i].position, |
---|
| 390 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 391 | listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available |
---|
| 392 | |
---|
| 393 | shortestDistance=graphDistance(listOfVerticesP[i].position, |
---|
| 394 | listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + |
---|
| 395 | listOfVerticesP[i].shortestDistanceToStart; |
---|
| 396 | |
---|
| 397 | nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; |
---|
| 398 | //we dont need the & because we are not giving the adress of the array element |
---|
| 399 | //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | } |
---|
| 403 | //we want after all to return the nearest non visited neighboor |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 410 | |
---|
| 411 | //if vertex already visited, call function on it and reapeat until you reach non visited vertex |
---|
| 412 | // ---> not sure if a good idea because we risk infinite loop |
---|
| 413 | |
---|
| 414 | //-215 -185 -135 -70 -20 0 20 70 135 185 215 |
---|
| 415 | |
---|
| 416 | //-195 -135 -85 -35 15 60 105 150 195 245 |
---|
| 417 | |
---|
| 418 | void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){ |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | if(findpos(actuelposition,possibleposition[0])){ |
---|
| 422 | // we should use listOfVerticesP2[i] instead of possibleposition[i] I think |
---|
| 423 | // so that all neighboors are "the same" |
---|
| 424 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!! |
---|
| 425 | adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 426 | adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ? |
---|
| 427 | } |
---|
| 428 | else if(findpos(actuelposition,possibleposition[1])){ |
---|
| 429 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 430 | adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 431 | } |
---|
| 432 | else if(findpos(actuelposition,possibleposition[2])){ |
---|
| 433 | adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); |
---|
| 434 | adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 435 | } |
---|
| 436 | else if(findpos(actuelposition,possibleposition[3])){ |
---|
| 437 | adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); |
---|
| 438 | adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 439 | adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 440 | } |
---|
| 441 | else if(findpos(actuelposition,possibleposition[4])){ |
---|
| 442 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 443 | adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 444 | } |
---|
| 445 | else if(findpos(actuelposition,possibleposition[5])){ |
---|
| 446 | adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); |
---|
| 447 | adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 448 | } |
---|
| 449 | else if(findpos(actuelposition,possibleposition[6])){ |
---|
| 450 | adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); |
---|
| 451 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 452 | adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 453 | } |
---|
| 454 | else if(findpos(actuelposition,possibleposition[7])){ |
---|
| 455 | adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); |
---|
| 456 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 457 | } |
---|
| 458 | else if(findpos(actuelposition,possibleposition[8])){ |
---|
| 459 | adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); |
---|
| 460 | adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 461 | } |
---|
| 462 | else if(findpos(actuelposition,possibleposition[9])){ |
---|
| 463 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 464 | adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); |
---|
| 465 | adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 466 | adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 467 | } |
---|
| 468 | else if(findpos(actuelposition,possibleposition[10])){ |
---|
| 469 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 470 | adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 471 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 472 | } |
---|
| 473 | else if(findpos(actuelposition,possibleposition[11])){ |
---|
| 474 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 475 | adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 476 | adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 477 | } |
---|
| 478 | else if(findpos(actuelposition,possibleposition[12])){ |
---|
| 479 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 480 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 481 | } |
---|
| 482 | else if(findpos(actuelposition,possibleposition[13])){ |
---|
| 483 | adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); |
---|
| 484 | adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 485 | adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 486 | adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 487 | } |
---|
| 488 | else if(findpos(actuelposition,possibleposition[14])){ |
---|
| 489 | adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); |
---|
| 490 | adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 491 | adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 492 | } |
---|
| 493 | else if(findpos(actuelposition,possibleposition[15])){ |
---|
| 494 | adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); |
---|
| 495 | adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 496 | } |
---|
| 497 | else if(findpos(actuelposition,possibleposition[16])){ |
---|
| 498 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 499 | adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); |
---|
| 500 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 501 | } |
---|
| 502 | else if(findpos(actuelposition,possibleposition[17])){ |
---|
| 503 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 504 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 505 | } |
---|
| 506 | else if(findpos(actuelposition,possibleposition[18])){ |
---|
| 507 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 508 | adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 509 | } |
---|
| 510 | else if(findpos(actuelposition,possibleposition[19])){ |
---|
| 511 | adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); |
---|
| 512 | adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 513 | adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 514 | } |
---|
| 515 | else if(findpos(actuelposition,possibleposition[20])){ |
---|
| 516 | adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); |
---|
| 517 | adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 518 | } |
---|
| 519 | else if(findpos(actuelposition,possibleposition[21])){ |
---|
| 520 | adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); |
---|
| 521 | adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 522 | } |
---|
| 523 | else if(findpos(actuelposition,possibleposition[22])){ |
---|
| 524 | adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); |
---|
| 525 | adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 526 | adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 527 | } |
---|
| 528 | else if(findpos(actuelposition,possibleposition[23])){ |
---|
| 529 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 530 | adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 531 | } |
---|
| 532 | else if(findpos(actuelposition,possibleposition[24])){ |
---|
| 533 | adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); |
---|
| 534 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 535 | } |
---|
| 536 | else if(findpos(actuelposition,possibleposition[25])){ |
---|
| 537 | adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); |
---|
| 538 | adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 539 | } |
---|
| 540 | else if(findpos(actuelposition,possibleposition[26])){ |
---|
| 541 | adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); |
---|
| 542 | adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); |
---|
| 543 | adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 544 | } |
---|
| 545 | else if(findpos(actuelposition,possibleposition[27])){ |
---|
| 546 | adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); |
---|
| 547 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 548 | adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 549 | } |
---|
| 550 | else if(findpos(actuelposition,possibleposition[28])){ |
---|
| 551 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 552 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 553 | adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 554 | } |
---|
| 555 | else if(findpos(actuelposition,possibleposition[29])){ |
---|
| 556 | adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); |
---|
| 557 | adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 558 | adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 559 | } |
---|
| 560 | else if(findpos(actuelposition,possibleposition[30])){ |
---|
| 561 | adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); |
---|
| 562 | adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); |
---|
| 563 | adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 564 | } |
---|
| 565 | else if(findpos(actuelposition,possibleposition[31])){ |
---|
| 566 | adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); |
---|
| 567 | adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 568 | } |
---|
| 569 | else if(findpos(actuelposition,possibleposition[32])){ |
---|
| 570 | adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); |
---|
| 571 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 572 | } |
---|
| 573 | else if(findpos(actuelposition,possibleposition[33])){ |
---|
| 574 | adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); |
---|
| 575 | adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 576 | } |
---|
| 577 | else if(findpos(actuelposition,possibleposition[34])){ |
---|
| 578 | adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); |
---|
| 579 | adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); |
---|
| 580 | adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 581 | adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 582 | |
---|
| 583 | } |
---|
| 584 | else if(findpos(actuelposition,possibleposition[35])){ |
---|
| 585 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 586 | adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); |
---|
| 587 | adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 588 | } |
---|
| 589 | else if(findpos(actuelposition,possibleposition[36])){ |
---|
| 590 | adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); |
---|
| 591 | adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 592 | } |
---|
| 593 | else if(findpos(actuelposition,possibleposition[37])){ |
---|
| 594 | adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); |
---|
| 595 | adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 596 | } |
---|
| 597 | else if(findpos(actuelposition,possibleposition[38])){ |
---|
| 598 | adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); |
---|
| 599 | adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); |
---|
| 600 | adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 601 | } |
---|
| 602 | else if(findpos(actuelposition,possibleposition[39])){ |
---|
| 603 | adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); |
---|
| 604 | adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 605 | adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 606 | } |
---|
| 607 | else if(findpos(actuelposition,possibleposition[40])){ |
---|
| 608 | adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 609 | adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 610 | } |
---|
| 611 | else if(findpos(actuelposition,possibleposition[41])){ |
---|
| 612 | adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); |
---|
| 613 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 614 | } |
---|
| 615 | else if(findpos(actuelposition,possibleposition[42])){ |
---|
| 616 | adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); |
---|
| 617 | adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 618 | adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 619 | } |
---|
| 620 | else if(findpos(actuelposition,possibleposition[43])){ |
---|
| 621 | adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); |
---|
| 622 | adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 623 | } |
---|
| 624 | else if(findpos(actuelposition,possibleposition[44])){ |
---|
| 625 | adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); |
---|
| 626 | adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 627 | } |
---|
| 628 | else if(findpos(actuelposition,possibleposition[45])){ |
---|
| 629 | adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); |
---|
| 630 | adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); |
---|
| 631 | adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 632 | } |
---|
| 633 | else if(findpos(actuelposition,possibleposition[46])){ |
---|
| 634 | adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); |
---|
| 635 | adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 636 | } |
---|
| 637 | else if(findpos(actuelposition,possibleposition[47])){ |
---|
| 638 | adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); |
---|
| 639 | adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 640 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 641 | } |
---|
| 642 | else if(findpos(actuelposition,possibleposition[48])){ |
---|
| 643 | adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); |
---|
| 644 | adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 645 | adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); |
---|
| 646 | } |
---|
| 647 | else if(findpos(actuelposition,possibleposition[49])){ |
---|
| 648 | adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); |
---|
| 649 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 650 | } |
---|
| 651 | else if(findpos(actuelposition,possibleposition[50])){ |
---|
| 652 | adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); |
---|
| 653 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 654 | } |
---|
| 655 | else if(findpos(actuelposition,possibleposition[51])){ |
---|
| 656 | adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 657 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 658 | } |
---|
| 659 | else if(findpos(actuelposition,possibleposition[52])){ |
---|
| 660 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 661 | adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 662 | } |
---|
| 663 | else if(findpos(actuelposition,possibleposition[53])){ |
---|
| 664 | adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); |
---|
| 665 | adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 666 | } |
---|
| 667 | else if(findpos(actuelposition,possibleposition[54])){ |
---|
| 668 | adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); |
---|
| 669 | adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 670 | adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 671 | } |
---|
| 672 | else if(findpos(actuelposition,possibleposition[55])){ |
---|
| 673 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 674 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 675 | } |
---|
| 676 | else if(findpos(actuelposition,possibleposition[56])){ |
---|
| 677 | adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); |
---|
| 678 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 679 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 680 | } |
---|
| 681 | else if(findpos(actuelposition,possibleposition[57])){ |
---|
| 682 | adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); |
---|
| 683 | adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 684 | adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 685 | adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 686 | |
---|
| 687 | } |
---|
| 688 | else if(findpos(actuelposition,possibleposition[58])){ |
---|
| 689 | adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); |
---|
| 690 | adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 691 | adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 692 | } |
---|
| 693 | else if(findpos(actuelposition,possibleposition[59])){ |
---|
| 694 | adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); |
---|
| 695 | adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 696 | adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 697 | } |
---|
| 698 | else if(findpos(actuelposition,possibleposition[60])){ |
---|
| 699 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 700 | adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); |
---|
| 701 | adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); |
---|
| 702 | } |
---|
| 703 | else if(findpos(actuelposition,possibleposition[61])){ |
---|
| 704 | adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); |
---|
| 705 | adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); |
---|
| 706 | adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 707 | } |
---|
| 708 | else if(findpos(actuelposition,possibleposition[62])){ |
---|
| 709 | adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); |
---|
| 710 | adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); |
---|
| 711 | } |
---|
| 712 | else if(findpos(actuelposition,possibleposition[63])){ |
---|
| 713 | adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); |
---|
| 714 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 715 | } |
---|
| 716 | else if(findpos(actuelposition,possibleposition[64])){ |
---|
| 717 | adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); |
---|
| 718 | adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); |
---|
| 719 | adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); |
---|
| 720 | } |
---|
| 721 | else if(findpos(actuelposition,possibleposition[65])){ |
---|
| 722 | adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); |
---|
| 723 | adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); |
---|
| 724 | } |
---|
| 725 | else if(findpos(actuelposition,possibleposition[66])){ |
---|
| 726 | adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); |
---|
| 727 | adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); |
---|
| 728 | } |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | |
---|
[12317] | 732 | |
---|
| 733 | |
---|
| 734 | //functions taken from PacmanPink |
---|
| 735 | |
---|
| 736 | |
---|
| 737 | |
---|
| 738 | |
---|
| 739 | |
---|
| 740 | Vector3 PacmanGhost::diffVector (Vector3 start, Vector3 goal){ |
---|
| 741 | |
---|
| 742 | Vector3 result; |
---|
| 743 | result.x=goal.x-start.x; |
---|
| 744 | result.z=goal.z-start.z; |
---|
| 745 | return result; |
---|
| 746 | } |
---|
| 747 | |
---|
[12318] | 748 | |
---|
| 749 | bool PacmanGhost::playerFindPos(Vector3 one, Vector3 other){ |
---|
| 750 | if((abs(one.x - other.x)<15) && (abs(one.z - other.z)<15)) return true; |
---|
| 751 | return false; |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | |
---|
| 755 | |
---|
| 756 | |
---|
[12317] | 757 | int PacmanGhost::findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){ |
---|
| 758 | //return 0 for south, 1 for west, 2 for north, 3 for east |
---|
| 759 | |
---|
| 760 | |
---|
[12318] | 761 | if(playerFindPos(playerPosBefore, playerPos)){ |
---|
| 762 | //if player is still near last crossed point |
---|
[12317] | 763 | |
---|
[12318] | 764 | return 4; //return the last crossed point for simplicity |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | |
---|
| 768 | if(abs(playerPos.x-playerPosBefore.x)<14){ //player is moving vertically |
---|
| 769 | if((playerPos.z-playerPosBefore.z)<0){//move west |
---|
| 770 | return 0; |
---|
| 771 | } |
---|
| 772 | if((playerPos.z-playerPosBefore.z)>0){//move east |
---|
| 773 | return 2; |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | if(abs(playerPos.z-playerPosBefore.z)<14){ //player is moving horizontally |
---|
| 778 | if((playerPos.x-playerPosBefore.x)<0){//move south |
---|
| 779 | return 1; |
---|
| 780 | } |
---|
| 781 | if((playerPos.x-playerPosBefore.x)>0){//move north |
---|
| 782 | return 3; |
---|
| 783 | } |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | |
---|
| 787 | /*Vector3 difference = diffVector(playerPosBefore, playerPos); |
---|
[12317] | 788 | if((difference.z < 0)&&(difference.z>difference.x)){ //move south |
---|
| 789 | |
---|
| 790 | return 0; |
---|
| 791 | } |
---|
| 792 | else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north |
---|
| 793 | |
---|
| 794 | return 2; |
---|
| 795 | } |
---|
| 796 | else if((difference.x < 0)&&(difference.x > difference.z )){//move west |
---|
| 797 | |
---|
| 798 | return 1; |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | else if((difference.x>0)&&(difference.x>difference.z)){ //move east |
---|
| 802 | return 3; |
---|
| 803 | |
---|
| 804 | } |
---|
| 805 | |
---|
| 806 | else { //default move west Can still be changed |
---|
| 807 | |
---|
| 808 | return 1; |
---|
[12318] | 809 | }*/ |
---|
[12317] | 810 | |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | Vector3 PacmanGhost::getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){ |
---|
| 814 | //return the Vector3 point that Pinky should target to |
---|
| 815 | //be in front of pacman |
---|
| 816 | |
---|
[12318] | 817 | if(indexForSWNE==4){ |
---|
| 818 | std::cout<<"Ryukyu"<<endl; |
---|
| 819 | return pacLasVisPos; |
---|
| 820 | } |
---|
| 821 | |
---|
[12317] | 822 | Vector3 listOfNeighboors[4]; |
---|
| 823 | //first element is south, 2nd west, 3d north, 4th east |
---|
| 824 | |
---|
| 825 | if(findpos(pacLasVisPos,possibleposition[0])){ |
---|
| 826 | //no south neighbor |
---|
| 827 | listOfNeighboors[1]=possibleposition[19]; // west neighbor |
---|
| 828 | listOfNeighboors[2]=possibleposition[17]; //north |
---|
| 829 | listOfNeighboors[3]=possibleposition[1]; //east |
---|
| 830 | return listOfNeighboors[indexForSWNE]; |
---|
| 831 | } |
---|
| 832 | else if(findpos(pacLasVisPos,possibleposition[1])){ |
---|
| 833 | listOfNeighboors[1]=possibleposition[0]; // west neighbor |
---|
| 834 | listOfNeighboors[2]=possibleposition[2]; //north |
---|
| 835 | return listOfNeighboors[indexForSWNE]; |
---|
| 836 | } |
---|
| 837 | else if(findpos(pacLasVisPos,possibleposition[2])){ |
---|
| 838 | listOfNeighboors[0]=possibleposition[1]; //south |
---|
| 839 | listOfNeighboors[1]=possibleposition[3]; //west |
---|
| 840 | return listOfNeighboors[indexForSWNE]; |
---|
| 841 | } |
---|
| 842 | else if(findpos(pacLasVisPos,possibleposition[3])){ |
---|
| 843 | listOfNeighboors[1]=possibleposition[4]; //west |
---|
| 844 | listOfNeighboors[2]=possibleposition[5]; //north |
---|
| 845 | listOfNeighboors[3]=possibleposition[2]; //east |
---|
| 846 | return listOfNeighboors[indexForSWNE]; |
---|
| 847 | } |
---|
| 848 | else if(findpos(pacLasVisPos,possibleposition[4])){ |
---|
| 849 | listOfNeighboors[2]=possibleposition[6]; //north |
---|
| 850 | listOfNeighboors[3]=possibleposition[3]; //east |
---|
| 851 | return listOfNeighboors[indexForSWNE]; |
---|
| 852 | } |
---|
| 853 | else if(findpos(pacLasVisPos,possibleposition[5])){ |
---|
| 854 | listOfNeighboors[0]=possibleposition[3]; //south |
---|
| 855 | listOfNeighboors[3]=possibleposition[7]; //east |
---|
| 856 | return listOfNeighboors[indexForSWNE]; |
---|
| 857 | } |
---|
| 858 | else if(findpos(pacLasVisPos,possibleposition[6])){ |
---|
| 859 | listOfNeighboors[0]=possibleposition[4]; //south |
---|
| 860 | listOfNeighboors[1]=possibleposition[26]; //west |
---|
| 861 | listOfNeighboors[2]=possibleposition[9]; //north |
---|
| 862 | return listOfNeighboors[indexForSWNE]; |
---|
| 863 | } |
---|
| 864 | else if(findpos(pacLasVisPos,possibleposition[7])){ |
---|
| 865 | listOfNeighboors[1]=possibleposition[5]; //west |
---|
| 866 | listOfNeighboors[2]=possibleposition[8]; //north |
---|
| 867 | return listOfNeighboors[indexForSWNE]; |
---|
| 868 | } |
---|
| 869 | else if(findpos(pacLasVisPos,possibleposition[8])){ |
---|
| 870 | listOfNeighboors[0]=possibleposition[7]; //south |
---|
| 871 | listOfNeighboors[1]=possibleposition[9]; //west |
---|
| 872 | return listOfNeighboors[indexForSWNE]; |
---|
| 873 | } |
---|
| 874 | else if(findpos(pacLasVisPos,possibleposition[9])){ |
---|
| 875 | listOfNeighboors[0]=possibleposition[6]; //south |
---|
| 876 | listOfNeighboors[1]=possibleposition[38]; //west |
---|
| 877 | listOfNeighboors[2]=possibleposition[10]; //north |
---|
| 878 | listOfNeighboors[3]=possibleposition[8]; //east |
---|
| 879 | return listOfNeighboors[indexForSWNE]; |
---|
| 880 | } |
---|
| 881 | else if(findpos(pacLasVisPos,possibleposition[10])){ |
---|
[12318] | 882 | |
---|
| 883 | if(indexForSWNE==3){ //nothing eastward |
---|
| 884 | return pacLasVisPos; |
---|
| 885 | } |
---|
| 886 | |
---|
[12317] | 887 | listOfNeighboors[0]=possibleposition[9]; //south |
---|
| 888 | listOfNeighboors[1]=possibleposition[45]; //west |
---|
| 889 | listOfNeighboors[2]=possibleposition[11]; //north |
---|
| 890 | return listOfNeighboors[indexForSWNE]; |
---|
| 891 | } |
---|
| 892 | else if(findpos(pacLasVisPos,possibleposition[11])){ |
---|
| 893 | listOfNeighboors[0]=possibleposition[10]; //south |
---|
| 894 | listOfNeighboors[2]=possibleposition[13]; //north |
---|
| 895 | listOfNeighboors[3]=possibleposition[12]; //east |
---|
| 896 | return listOfNeighboors[indexForSWNE]; |
---|
| 897 | } |
---|
| 898 | else if(findpos(pacLasVisPos,possibleposition[12])){ |
---|
| 899 | listOfNeighboors[1]=possibleposition[11]; //west |
---|
| 900 | listOfNeighboors[2]=possibleposition[14]; //north |
---|
| 901 | return listOfNeighboors[indexForSWNE]; |
---|
| 902 | } |
---|
| 903 | else if(findpos(pacLasVisPos,possibleposition[13])){ |
---|
| 904 | listOfNeighboors[0]=possibleposition[11]; //south |
---|
| 905 | listOfNeighboors[1]=possibleposition[61]; //west |
---|
| 906 | listOfNeighboors[2]=possibleposition[16]; //north |
---|
| 907 | listOfNeighboors[3]=possibleposition[14]; //east |
---|
| 908 | return listOfNeighboors[indexForSWNE]; |
---|
| 909 | } |
---|
| 910 | else if(findpos(pacLasVisPos,possibleposition[14])){ |
---|
| 911 | listOfNeighboors[0]=possibleposition[12]; //south |
---|
| 912 | listOfNeighboors[1]=possibleposition[13]; //west |
---|
| 913 | listOfNeighboors[2]=possibleposition[15]; //north |
---|
| 914 | return listOfNeighboors[indexForSWNE]; |
---|
| 915 | } |
---|
| 916 | else if(findpos(pacLasVisPos,possibleposition[15])){ |
---|
| 917 | listOfNeighboors[0]=possibleposition[14]; //south |
---|
| 918 | listOfNeighboors[1]=possibleposition[16]; //west |
---|
| 919 | return listOfNeighboors[indexForSWNE]; |
---|
| 920 | } |
---|
| 921 | else if(findpos(pacLasVisPos,possibleposition[16])){ |
---|
| 922 | listOfNeighboors[0]=possibleposition[13]; //south |
---|
| 923 | listOfNeighboors[1]=possibleposition[62]; //west |
---|
| 924 | listOfNeighboors[2]=possibleposition[15]; //north |
---|
| 925 | return listOfNeighboors[indexForSWNE]; |
---|
| 926 | } |
---|
| 927 | else if(findpos(pacLasVisPos,possibleposition[17])){ |
---|
| 928 | listOfNeighboors[0]=possibleposition[0]; //south |
---|
| 929 | listOfNeighboors[3]=possibleposition[25]; //east |
---|
| 930 | return listOfNeighboors[indexForSWNE]; |
---|
| 931 | } |
---|
| 932 | else if(findpos(pacLasVisPos,possibleposition[18])){ |
---|
| 933 | listOfNeighboors[0]=possibleposition[19]; //south |
---|
| 934 | listOfNeighboors[1]=possibleposition[24]; //west |
---|
| 935 | return listOfNeighboors[indexForSWNE]; |
---|
| 936 | } |
---|
| 937 | else if(findpos(pacLasVisPos,possibleposition[19])){ |
---|
| 938 | listOfNeighboors[1]=possibleposition[20]; //west |
---|
| 939 | listOfNeighboors[2]=possibleposition[18]; //north |
---|
| 940 | listOfNeighboors[3]=possibleposition[0]; //east |
---|
| 941 | return listOfNeighboors[indexForSWNE]; |
---|
| 942 | } |
---|
| 943 | else if(findpos(pacLasVisPos,possibleposition[20])){ |
---|
| 944 | listOfNeighboors[2]=possibleposition[21]; //north |
---|
| 945 | listOfNeighboors[3]=possibleposition[19]; //east |
---|
| 946 | return listOfNeighboors[indexForSWNE]; |
---|
| 947 | } |
---|
| 948 | else if(findpos(pacLasVisPos,possibleposition[21])){ |
---|
| 949 | listOfNeighboors[0]=possibleposition[20]; //south |
---|
| 950 | listOfNeighboors[3]=possibleposition[22]; //east |
---|
| 951 | return listOfNeighboors[indexForSWNE]; |
---|
| 952 | } |
---|
| 953 | else if(findpos(pacLasVisPos,possibleposition[22])){ |
---|
| 954 | listOfNeighboors[1]=possibleposition[21]; //west |
---|
| 955 | listOfNeighboors[2]=possibleposition[31]; //north |
---|
| 956 | listOfNeighboors[3]=possibleposition[23]; //east |
---|
| 957 | return listOfNeighboors[indexForSWNE]; |
---|
| 958 | } |
---|
| 959 | else if(findpos(pacLasVisPos,possibleposition[23])){ |
---|
| 960 | listOfNeighboors[1]=possibleposition[22]; //west |
---|
| 961 | listOfNeighboors[2]=possibleposition[30]; //north |
---|
| 962 | return listOfNeighboors[indexForSWNE]; |
---|
| 963 | } |
---|
| 964 | else if(findpos(pacLasVisPos,possibleposition[24])){ |
---|
| 965 | listOfNeighboors[2]=possibleposition[29]; //north |
---|
| 966 | listOfNeighboors[3]=possibleposition[18]; //east |
---|
| 967 | return listOfNeighboors[indexForSWNE]; |
---|
| 968 | } |
---|
| 969 | else if(findpos(pacLasVisPos,possibleposition[25])){ |
---|
| 970 | listOfNeighboors[1]=possibleposition[17]; //west |
---|
| 971 | listOfNeighboors[2]=possibleposition[26]; //north |
---|
| 972 | return listOfNeighboors[indexForSWNE]; |
---|
| 973 | } |
---|
| 974 | else if(findpos(pacLasVisPos,possibleposition[26])){ |
---|
| 975 | listOfNeighboors[0]=possibleposition[25]; //south |
---|
| 976 | listOfNeighboors[1]=possibleposition[27]; //west |
---|
| 977 | listOfNeighboors[3]=possibleposition[6]; //east |
---|
| 978 | return listOfNeighboors[indexForSWNE]; |
---|
| 979 | } |
---|
| 980 | else if(findpos(pacLasVisPos,possibleposition[27])){ |
---|
| 981 | listOfNeighboors[1]=possibleposition[28]; //west |
---|
| 982 | listOfNeighboors[2]=possibleposition[37]; //north |
---|
| 983 | listOfNeighboors[3]=possibleposition[26]; //east |
---|
| 984 | return listOfNeighboors[indexForSWNE]; |
---|
| 985 | } |
---|
| 986 | else if(findpos(pacLasVisPos,possibleposition[28])){ |
---|
| 987 | listOfNeighboors[1]=possibleposition[29]; //west |
---|
| 988 | listOfNeighboors[2]=possibleposition[36]; //north |
---|
| 989 | listOfNeighboors[3]=possibleposition[27]; //east |
---|
| 990 | return listOfNeighboors[indexForSWNE]; |
---|
| 991 | } |
---|
| 992 | else if(findpos(pacLasVisPos,possibleposition[29])){ |
---|
| 993 | listOfNeighboors[0]=possibleposition[24]; //south |
---|
| 994 | listOfNeighboors[1]=possibleposition[30]; //west |
---|
| 995 | listOfNeighboors[3]=possibleposition[28]; //east |
---|
| 996 | return listOfNeighboors[indexForSWNE]; |
---|
| 997 | } |
---|
| 998 | else if(findpos(pacLasVisPos,possibleposition[30])){ |
---|
| 999 | listOfNeighboors[0]=possibleposition[23]; //south |
---|
| 1000 | listOfNeighboors[2]=possibleposition[34]; //north |
---|
| 1001 | listOfNeighboors[3]=possibleposition[29]; //east |
---|
| 1002 | return listOfNeighboors[indexForSWNE]; |
---|
| 1003 | } |
---|
| 1004 | else if(findpos(pacLasVisPos,possibleposition[31])){ |
---|
| 1005 | listOfNeighboors[0]=possibleposition[22]; //south |
---|
| 1006 | listOfNeighboors[1]=possibleposition[32]; //west |
---|
| 1007 | return listOfNeighboors[indexForSWNE]; |
---|
| 1008 | } |
---|
| 1009 | else if(findpos(pacLasVisPos,possibleposition[32])){ |
---|
| 1010 | listOfNeighboors[2]=possibleposition[33]; //north |
---|
| 1011 | listOfNeighboors[3]=possibleposition[31]; //east |
---|
| 1012 | return listOfNeighboors[indexForSWNE]; |
---|
| 1013 | } |
---|
| 1014 | else if(findpos(pacLasVisPos,possibleposition[33])){ |
---|
| 1015 | listOfNeighboors[0]=possibleposition[32]; //south |
---|
| 1016 | listOfNeighboors[3]=possibleposition[34]; //east |
---|
| 1017 | return listOfNeighboors[indexForSWNE]; |
---|
| 1018 | } |
---|
| 1019 | else if(findpos(pacLasVisPos,possibleposition[34])){ |
---|
| 1020 | listOfNeighboors[0]=possibleposition[30]; //south |
---|
| 1021 | listOfNeighboors[1]=possibleposition[33]; //west |
---|
| 1022 | listOfNeighboors[2]=possibleposition[92]; //north |
---|
| 1023 | listOfNeighboors[3]=possibleposition[35]; //east |
---|
| 1024 | return listOfNeighboors[indexForSWNE]; |
---|
| 1025 | } |
---|
| 1026 | else if(findpos(pacLasVisPos,possibleposition[35])){ |
---|
| 1027 | listOfNeighboors[1]=possibleposition[34]; //west |
---|
| 1028 | listOfNeighboors[2]=possibleposition[91]; //north |
---|
| 1029 | listOfNeighboors[3]=possibleposition[36]; //east |
---|
| 1030 | return listOfNeighboors[indexForSWNE]; |
---|
| 1031 | } |
---|
| 1032 | else if(findpos(pacLasVisPos,possibleposition[36])){ |
---|
| 1033 | listOfNeighboors[0]=possibleposition[28]; //south |
---|
| 1034 | listOfNeighboors[1]=possibleposition[35]; //west |
---|
| 1035 | return listOfNeighboors[indexForSWNE]; |
---|
| 1036 | } |
---|
| 1037 | else if(findpos(pacLasVisPos,possibleposition[37])){ |
---|
| 1038 | listOfNeighboors[0]=possibleposition[27]; //south |
---|
| 1039 | listOfNeighboors[3]=possibleposition[38]; //east |
---|
| 1040 | return listOfNeighboors[indexForSWNE]; |
---|
| 1041 | } |
---|
| 1042 | else if(findpos(pacLasVisPos,possibleposition[38])){ |
---|
| 1043 | listOfNeighboors[1]=possibleposition[37]; //west |
---|
| 1044 | listOfNeighboors[2]=possibleposition[39]; //north |
---|
| 1045 | listOfNeighboors[3]=possibleposition[9]; //east |
---|
| 1046 | return listOfNeighboors[indexForSWNE]; |
---|
| 1047 | } |
---|
| 1048 | else if(findpos(pacLasVisPos,possibleposition[39])){ |
---|
| 1049 | listOfNeighboors[0]=possibleposition[38]; //south |
---|
| 1050 | listOfNeighboors[1]=possibleposition[40]; //west |
---|
| 1051 | listOfNeighboors[2]=possibleposition[45]; //north |
---|
| 1052 | return listOfNeighboors[indexForSWNE]; |
---|
| 1053 | } |
---|
| 1054 | else if(findpos(pacLasVisPos,possibleposition[40])){ |
---|
| 1055 | listOfNeighboors[1]=possibleposition[41]; //west |
---|
| 1056 | //Not return in center |
---|
| 1057 | listOfNeighboors[3]=possibleposition[39]; //east |
---|
| 1058 | return listOfNeighboors[indexForSWNE]; |
---|
| 1059 | } |
---|
| 1060 | else if(findpos(pacLasVisPos,possibleposition[41])){ |
---|
| 1061 | listOfNeighboors[0]=possibleposition[35]; //south |
---|
| 1062 | listOfNeighboors[2]=possibleposition[43]; //north |
---|
| 1063 | listOfNeighboors[3]=possibleposition[40]; //east |
---|
| 1064 | return listOfNeighboors[indexForSWNE]; |
---|
| 1065 | } |
---|
| 1066 | else if(findpos(pacLasVisPos,possibleposition[42])){ |
---|
[12318] | 1067 | |
---|
| 1068 | if(indexForSWNE==1){//nothing westward |
---|
| 1069 | return pacLasVisPos; |
---|
| 1070 | } |
---|
| 1071 | |
---|
[12317] | 1072 | listOfNeighboors[0]=possibleposition[39]; //south |
---|
| 1073 | listOfNeighboors[2]=possibleposition[59]; //north |
---|
| 1074 | listOfNeighboors[3]=possibleposition[43]; //east |
---|
| 1075 | return listOfNeighboors[indexForSWNE]; |
---|
| 1076 | } |
---|
| 1077 | else if(findpos(pacLasVisPos,possibleposition[43])){ |
---|
| 1078 | listOfNeighboors[0]=possibleposition[41]; //south |
---|
| 1079 | listOfNeighboors[1]=possibleposition[42]; //west |
---|
| 1080 | listOfNeighboors[2]=possibleposition[46]; //north |
---|
| 1081 | return listOfNeighboors[indexForSWNE]; |
---|
| 1082 | } |
---|
| 1083 | else if(findpos(pacLasVisPos,possibleposition[44])){ |
---|
| 1084 | listOfNeighboors[0]=possibleposition[40]; //south |
---|
| 1085 | listOfNeighboors[2]=possibleposition[66]; //north |
---|
| 1086 | return listOfNeighboors[indexForSWNE]; |
---|
| 1087 | } |
---|
| 1088 | else if(findpos(pacLasVisPos,possibleposition[45])){ |
---|
| 1089 | listOfNeighboors[0]=possibleposition[39]; //south |
---|
| 1090 | listOfNeighboors[2]=possibleposition[49]; //north |
---|
| 1091 | listOfNeighboors[3]=possibleposition[10]; //east |
---|
| 1092 | return listOfNeighboors[indexForSWNE]; |
---|
| 1093 | } |
---|
| 1094 | else if(findpos(pacLasVisPos,possibleposition[46])){ |
---|
| 1095 | listOfNeighboors[0]=possibleposition[43]; //south |
---|
| 1096 | listOfNeighboors[3]=possibleposition[47]; //east |
---|
| 1097 | return listOfNeighboors[indexForSWNE]; |
---|
| 1098 | } |
---|
| 1099 | else if(findpos(pacLasVisPos,possibleposition[47])){ |
---|
| 1100 | listOfNeighboors[1]=possibleposition[46]; //west |
---|
| 1101 | listOfNeighboors[2]=possibleposition[52]; //north |
---|
| 1102 | listOfNeighboors[3]=possibleposition[66]; //east |
---|
| 1103 | return listOfNeighboors[indexForSWNE]; |
---|
| 1104 | } |
---|
| 1105 | else if(findpos(pacLasVisPos,possibleposition[48])){ |
---|
| 1106 | listOfNeighboors[1]=possibleposition[66]; //west |
---|
| 1107 | listOfNeighboors[2]=possibleposition[51]; //north |
---|
| 1108 | listOfNeighboors[3]=possibleposition[49]; //east |
---|
| 1109 | return listOfNeighboors[indexForSWNE]; |
---|
| 1110 | } |
---|
| 1111 | else if(findpos(pacLasVisPos,possibleposition[49])){ |
---|
| 1112 | listOfNeighboors[0]=possibleposition[45]; //south |
---|
| 1113 | listOfNeighboors[1]=possibleposition[48]; //west |
---|
| 1114 | return listOfNeighboors[indexForSWNE]; |
---|
| 1115 | } |
---|
| 1116 | else if(findpos(pacLasVisPos,possibleposition[50])){ |
---|
| 1117 | listOfNeighboors[1]=possibleposition[51]; //west |
---|
| 1118 | listOfNeighboors[2]=possibleposition[61]; //north |
---|
| 1119 | return listOfNeighboors[indexForSWNE]; |
---|
| 1120 | } |
---|
| 1121 | else if(findpos(pacLasVisPos,possibleposition[51])){ |
---|
| 1122 | listOfNeighboors[0]=possibleposition[48]; //south |
---|
| 1123 | listOfNeighboors[3]=possibleposition[50]; //east |
---|
| 1124 | return listOfNeighboors[indexForSWNE]; |
---|
| 1125 | } |
---|
| 1126 | else if(findpos(pacLasVisPos,possibleposition[52])){ |
---|
| 1127 | listOfNeighboors[0]=possibleposition[47]; //south |
---|
| 1128 | listOfNeighboors[1]=possibleposition[53]; //west |
---|
| 1129 | return listOfNeighboors[indexForSWNE]; |
---|
| 1130 | } |
---|
| 1131 | else if(findpos(pacLasVisPos,possibleposition[53])){ |
---|
| 1132 | listOfNeighboors[2]=possibleposition[58]; //north |
---|
| 1133 | listOfNeighboors[3]=possibleposition[52]; //east |
---|
| 1134 | return listOfNeighboors[indexForSWNE]; |
---|
| 1135 | } |
---|
| 1136 | else if(findpos(pacLasVisPos,possibleposition[54])){ |
---|
| 1137 | listOfNeighboors[0]=possibleposition[42]; //south |
---|
| 1138 | listOfNeighboors[1]=possibleposition[55]; //west |
---|
| 1139 | listOfNeighboors[2]=possibleposition[57]; //north |
---|
| 1140 | return listOfNeighboors[indexForSWNE]; |
---|
| 1141 | } |
---|
| 1142 | else if(findpos(pacLasVisPos,possibleposition[55])){ |
---|
| 1143 | listOfNeighboors[2]=possibleposition[56]; //north |
---|
| 1144 | listOfNeighboors[3]=possibleposition[54]; //east |
---|
| 1145 | return listOfNeighboors[indexForSWNE]; |
---|
| 1146 | } |
---|
| 1147 | else if(findpos(pacLasVisPos,possibleposition[56])){ |
---|
| 1148 | listOfNeighboors[0]=possibleposition[55]; //south |
---|
| 1149 | listOfNeighboors[2]=possibleposition[65]; //north |
---|
| 1150 | listOfNeighboors[3]=possibleposition[57]; //east |
---|
| 1151 | return listOfNeighboors[indexForSWNE]; |
---|
| 1152 | } |
---|
| 1153 | else if(findpos(pacLasVisPos,possibleposition[57])){ |
---|
| 1154 | listOfNeighboors[0]=possibleposition[54]; //south |
---|
| 1155 | listOfNeighboors[1]=possibleposition[56]; //west |
---|
| 1156 | listOfNeighboors[2]=possibleposition[64]; //north |
---|
| 1157 | listOfNeighboors[3]=possibleposition[58]; //east |
---|
| 1158 | return listOfNeighboors[indexForSWNE]; |
---|
| 1159 | } |
---|
| 1160 | else if(findpos(pacLasVisPos,possibleposition[58])){ |
---|
| 1161 | listOfNeighboors[0]=possibleposition[53]; //south |
---|
| 1162 | listOfNeighboors[1]=possibleposition[57]; //west |
---|
| 1163 | listOfNeighboors[3]=possibleposition[59]; //east |
---|
| 1164 | return listOfNeighboors[indexForSWNE]; |
---|
| 1165 | } |
---|
| 1166 | else if(findpos(pacLasVisPos,possibleposition[59])){ |
---|
| 1167 | listOfNeighboors[1]=possibleposition[58]; //west |
---|
| 1168 | listOfNeighboors[2]=possibleposition[63]; //north |
---|
| 1169 | listOfNeighboors[3]=possibleposition[60]; //east |
---|
| 1170 | return listOfNeighboors[indexForSWNE]; |
---|
| 1171 | } |
---|
| 1172 | else if(findpos(pacLasVisPos,possibleposition[60])){ |
---|
| 1173 | listOfNeighboors[1]=possibleposition[59]; //west |
---|
| 1174 | listOfNeighboors[2]=possibleposition[62]; //north |
---|
| 1175 | listOfNeighboors[3]=possibleposition[61]; //east |
---|
| 1176 | return listOfNeighboors[indexForSWNE]; |
---|
| 1177 | } |
---|
| 1178 | else if(findpos(pacLasVisPos,possibleposition[61])){ |
---|
| 1179 | listOfNeighboors[0]=possibleposition[50]; //south |
---|
| 1180 | listOfNeighboors[1]=possibleposition[60]; //west |
---|
| 1181 | listOfNeighboors[3]=possibleposition[13]; //east |
---|
| 1182 | return listOfNeighboors[indexForSWNE]; |
---|
| 1183 | } |
---|
| 1184 | else if(findpos(pacLasVisPos,possibleposition[62])){ |
---|
| 1185 | listOfNeighboors[0]=possibleposition[60]; //south |
---|
| 1186 | listOfNeighboors[3]=possibleposition[16]; //east |
---|
| 1187 | return listOfNeighboors[indexForSWNE]; |
---|
| 1188 | } |
---|
| 1189 | else if(findpos(pacLasVisPos,possibleposition[63])){ |
---|
| 1190 | listOfNeighboors[0]=possibleposition[59]; //south |
---|
| 1191 | listOfNeighboors[1]=possibleposition[64]; //west |
---|
| 1192 | return listOfNeighboors[indexForSWNE]; |
---|
| 1193 | } |
---|
| 1194 | else if(findpos(pacLasVisPos,possibleposition[64])){ |
---|
| 1195 | listOfNeighboors[0]=possibleposition[57]; //south |
---|
| 1196 | listOfNeighboors[1]=possibleposition[65]; //west |
---|
| 1197 | listOfNeighboors[3]=possibleposition[63]; //east |
---|
| 1198 | return listOfNeighboors[indexForSWNE]; |
---|
| 1199 | } |
---|
| 1200 | else if(findpos(pacLasVisPos,possibleposition[65])){ |
---|
| 1201 | listOfNeighboors[0]=possibleposition[56]; //south |
---|
| 1202 | listOfNeighboors[3]=possibleposition[64]; //east |
---|
| 1203 | return listOfNeighboors[indexForSWNE]; |
---|
| 1204 | } |
---|
| 1205 | else if(findpos(pacLasVisPos,possibleposition[66])){ |
---|
| 1206 | //Not back in center |
---|
| 1207 | listOfNeighboors[1]=possibleposition[47]; //west |
---|
| 1208 | listOfNeighboors[3]=possibleposition[48]; //east |
---|
| 1209 | return listOfNeighboors[indexForSWNE]; |
---|
| 1210 | } |
---|
| 1211 | |
---|
| 1212 | } |
---|
| 1213 | |
---|
| 1214 | |
---|
[11915] | 1215 | } |
---|