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