- Timestamp:
- Apr 21, 2019, 11:30:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
r12318 r12319 247 247 248 248 249 bool PacmanGhost::jeanfindpos(Vector3 one, Vector3 other){ 250 if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true; 251 return false; 252 } 253 254 void PacmanGhost::setNewTargetGhost(Vector3 goalToGo){ 255 256 this->target_x = goalToGo.x; 257 this->target_z = goalToGo.z; 258 this->ismoving = true; 259 } 249 260 250 261 … … 255 266 256 267 257 258 Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal){ 268 Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1){ 269 //this function should then somehow produce the algorithm and call all other functions 270 //and finally return the best neighboor of the actual position of the pacman 271 272 //(optional parameter) pointToAvoidP1 is a point that cannot be considered 273 274 275 graphVertex listOfVerticesM[67]; //our list of all possible graphs 276 graphVertex* actualVertex; //we will walk through the array with a pointer 277 278 if(start==goal){ // basic case 279 return start; 280 } 281 282 for(int an=0; an < 67; an++){ 283 listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file 284 if(start==possibleposition[an]){ 285 actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array 286 //cout<<an<<endl; 287 } 288 } 289 290 //graphVertex actualVertex= listOfVerticesM[an]; 291 292 actualVertex->alreadyVisited=true; //our start point is now visited 293 actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0 294 findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 295 // second parameter is an array ! //third is our global array 296 297 while(actualVertex->position!=goal){ 298 for(int h=0;h < 4; h++){ 299 if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex 300 301 //h=2 and 3 never reached 302 updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]); 303 } //we "update" the neighboors of our new visited vertex 304 305 } 306 307 actualVertex=findNextVertexToConsider(listOfVerticesM, pointToAvoidP1); 308 actualVertex->alreadyVisited=true; 309 //cout<<actualVertex->position<<endl; 310 if(actualVertex->position!=goal){ 311 findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 312 //we find the neighboors of our new visited vertex 313 } 314 } 315 316 //cout<<"meuejeeke"<<endl; never reached 317 318 //we should have reached our goal at this point 319 320 while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor 321 actualVertex=actualVertex->actuelPredecessor; 322 } 323 // the predecessor is our starting point, in other words we are now on an 324 //adjacent vertex of the start 325 326 return actualVertex->position; //we return the position of this - adjacent to start - vertex 327 } 328 329 //end of getShortestPath 330 331 332 int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){ 333 //cout<<hgj++<<endl; 334 Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z)); 335 336 return differenceVector.x+differenceVector.z; 337 } 338 339 void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){ 340 //apply this method to all non visited neighboors of a vertex. 341 // This method should always be run on a vertex after we marked it as visited. 342 if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors. 343 if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&& 344 (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + 345 graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case ! 346 347 neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + 348 graphDistance(vertex.position, neighboor.position); 349 neighboor.actuelPredecessor = &vertex; 350 } 351 } 352 } 353 354 void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3){ 355 //find nearest non visited neighboor of a given already visited vertex 356 //(optional parameter) pointToAvoidP3 is a point that cannot be considered 357 int shortestDistance = -1; 358 graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any. 359 //Also, if all neighboors are already visited, we return NULL, i.e. there is no 360 //nearest non visited neighboor. 361 for(int i=0; i < 4; i++){ 362 if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)&&(vertex.adjacentVertices[i]->position!=pointToAvoidP3)){ 363 if(shortestDistance==-1){ //(concerns line above) we want a non visited neighboor //(optional) if the position of the neighboor is the one we want 364 //to avoid, then we ignore it 365 366 shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); 367 nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! 368 //cout<<shortestDistance<<endl; 369 } 370 else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){ 371 shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position); 372 nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses ! 373 //cout<<(hgj++)%4<<endl; 374 } 375 } 376 } 377 vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses ! 378 //cout<<hgj++<<endl; 379 } 380 381 382 PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2){ //find next, nearest from start, non visited vertex in our listOfVertices array 383 //(optional parameter) pointToAvoidP2 is a point that cannot be considered 384 385 int shortestDistance = -1; 386 graphVertex* nextVertexToConsider; 387 388 for(int i=0; i < 67; i++){ //we loop over all possible positions 389 390 if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited 391 392 findNearestNonVisitedNeighboor(listOfVerticesP[i], pointToAvoidP2); //we update nearest neighboor 393 //of all visited vertices given that one of the nearest neighboor of a visited 394 // vertex is now also visited because it was chosen as next optimal vertex 395 396 if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate! 397 if(shortestDistance==-1){ //our first possible candidate 398 399 shortestDistance=graphDistance(listOfVerticesP[i].position, 400 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 401 listOfVerticesP[i].shortestDistanceToStart; 402 403 nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; 404 //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor 405 406 } 407 else if(shortestDistance > graphDistance(listOfVerticesP[i].position, 408 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 409 listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available 410 411 shortestDistance=graphDistance(listOfVerticesP[i].position, 412 listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 413 listOfVerticesP[i].shortestDistanceToStart; 414 415 nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor; 416 //we dont need the & because we are not giving the adress of the array element 417 //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor 418 } 419 } 420 } 421 //we want after all to return the nearest non visited neighboor 422 } 423 424 return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array 425 } 426 427 ////////////////////////////////////////////////////////////////////////////////////////////// 428 429 //if vertex already visited, call function on it and reapeat until you reach non visited vertex 430 // ---> not sure if a good idea because we risk infinite loop 431 432 //-215 -185 -135 -70 -20 0 20 70 135 185 215 433 434 //-195 -135 -85 -35 15 60 105 150 195 245 435 436 void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){ 437 438 439 if(findpos(actuelposition,possibleposition[0])){ 440 // we should use listOfVerticesP2[i] instead of possibleposition[i] I think 441 // so that all neighboors are "the same" 442 adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!! 443 adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); 444 adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ? 445 } 446 else if(findpos(actuelposition,possibleposition[1])){ 447 adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); 448 adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); 449 } 450 else if(findpos(actuelposition,possibleposition[2])){ 451 adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]); 452 adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); 453 } 454 else if(findpos(actuelposition,possibleposition[3])){ 455 adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]); 456 adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); 457 adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); 458 } 459 else if(findpos(actuelposition,possibleposition[4])){ 460 adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); 461 adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); 462 } 463 else if(findpos(actuelposition,possibleposition[5])){ 464 adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]); 465 adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); 466 } 467 else if(findpos(actuelposition,possibleposition[6])){ 468 adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]); 469 adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); 470 adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); 471 } 472 else if(findpos(actuelposition,possibleposition[7])){ 473 adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]); 474 adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); 475 } 476 else if(findpos(actuelposition,possibleposition[8])){ 477 adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]); 478 adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); 479 } 480 else if(findpos(actuelposition,possibleposition[9])){ 481 adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); 482 adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]); 483 adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); 484 adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); 485 } 486 else if(findpos(actuelposition,possibleposition[10])){ 487 adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); 488 adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); 489 adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); 490 } 491 else if(findpos(actuelposition,possibleposition[11])){ 492 adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); 493 adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); 494 adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); 495 } 496 else if(findpos(actuelposition,possibleposition[12])){ 497 adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); 498 adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); 499 } 500 else if(findpos(actuelposition,possibleposition[13])){ 501 adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]); 502 adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); 503 adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); 504 adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); 505 } 506 else if(findpos(actuelposition,possibleposition[14])){ 507 adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]); 508 adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); 509 adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); 510 } 511 else if(findpos(actuelposition,possibleposition[15])){ 512 adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]); 513 adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); 514 } 515 else if(findpos(actuelposition,possibleposition[16])){ 516 adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); 517 adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]); 518 adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); 519 } 520 else if(findpos(actuelposition,possibleposition[17])){ 521 adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); 522 adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); 523 } 524 else if(findpos(actuelposition,possibleposition[18])){ 525 adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); 526 adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); 527 } 528 else if(findpos(actuelposition,possibleposition[19])){ 529 adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]); 530 adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); 531 adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); 532 } 533 else if(findpos(actuelposition,possibleposition[20])){ 534 adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); 535 adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); 536 } 537 else if(findpos(actuelposition,possibleposition[21])){ 538 adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]); 539 adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); 540 } 541 else if(findpos(actuelposition,possibleposition[22])){ 542 adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]); 543 adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); 544 adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); 545 } 546 else if(findpos(actuelposition,possibleposition[23])){ 547 adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); 548 adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); 549 } 550 else if(findpos(actuelposition,possibleposition[24])){ 551 adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]); 552 adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); 553 } 554 else if(findpos(actuelposition,possibleposition[25])){ 555 adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]); 556 adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); 557 } 558 else if(findpos(actuelposition,possibleposition[26])){ 559 adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]); 560 adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]); 561 adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); 562 } 563 else if(findpos(actuelposition,possibleposition[27])){ 564 adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]); 565 adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); 566 adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); 567 } 568 else if(findpos(actuelposition,possibleposition[28])){ 569 adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); 570 adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); 571 adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); 572 } 573 else if(findpos(actuelposition,possibleposition[29])){ 574 adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]); 575 adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); 576 adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); 577 } 578 else if(findpos(actuelposition,possibleposition[30])){ 579 adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]); 580 adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]); 581 adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); 582 } 583 else if(findpos(actuelposition,possibleposition[31])){ 584 adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]); 585 adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); 586 } 587 else if(findpos(actuelposition,possibleposition[32])){ 588 adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]); 589 adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); 590 } 591 else if(findpos(actuelposition,possibleposition[33])){ 592 adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]); 593 adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); 594 } 595 else if(findpos(actuelposition,possibleposition[34])){ 596 adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]); 597 adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]); 598 adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); 599 adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); 600 601 } 602 else if(findpos(actuelposition,possibleposition[35])){ 603 adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); 604 adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]); 605 adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); 606 } 607 else if(findpos(actuelposition,possibleposition[36])){ 608 adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]); 609 adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); 610 } 611 else if(findpos(actuelposition,possibleposition[37])){ 612 adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]); 613 adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); 614 } 615 else if(findpos(actuelposition,possibleposition[38])){ 616 adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]); 617 adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]); 618 adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); 619 } 620 else if(findpos(actuelposition,possibleposition[39])){ 621 adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]); 622 adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); 623 adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); 624 } 625 else if(findpos(actuelposition,possibleposition[40])){ 626 adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); 627 adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); 628 } 629 else if(findpos(actuelposition,possibleposition[41])){ 630 adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]); 631 adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); 632 } 633 else if(findpos(actuelposition,possibleposition[42])){ 634 adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]); 635 adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); 636 adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); 637 } 638 else if(findpos(actuelposition,possibleposition[43])){ 639 adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]); 640 adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); 641 } 642 else if(findpos(actuelposition,possibleposition[44])){ 643 adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]); 644 adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); 645 } 646 else if(findpos(actuelposition,possibleposition[45])){ 647 adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]); 648 adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]); 649 adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); 650 } 651 else if(findpos(actuelposition,possibleposition[46])){ 652 adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]); 653 adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); 654 } 655 else if(findpos(actuelposition,possibleposition[47])){ 656 adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]); 657 adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); 658 adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); 659 } 660 else if(findpos(actuelposition,possibleposition[48])){ 661 adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]); 662 adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); 663 adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]); 664 } 665 else if(findpos(actuelposition,possibleposition[49])){ 666 adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]); 667 adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); 668 } 669 else if(findpos(actuelposition,possibleposition[50])){ 670 adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]); 671 adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); 672 } 673 else if(findpos(actuelposition,possibleposition[51])){ 674 adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); 675 adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); 676 } 677 else if(findpos(actuelposition,possibleposition[52])){ 678 adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); 679 adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); 680 } 681 else if(findpos(actuelposition,possibleposition[53])){ 682 adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]); 683 adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); 684 } 685 else if(findpos(actuelposition,possibleposition[54])){ 686 adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]); 687 adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); 688 adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); 689 } 690 else if(findpos(actuelposition,possibleposition[55])){ 691 adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); 692 adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); 693 } 694 else if(findpos(actuelposition,possibleposition[56])){ 695 adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]); 696 adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); 697 adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); 698 } 699 else if(findpos(actuelposition,possibleposition[57])){ 700 adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]); 701 adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); 702 adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); 703 adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); 704 705 } 706 else if(findpos(actuelposition,possibleposition[58])){ 707 adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]); 708 adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); 709 adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); 710 } 711 else if(findpos(actuelposition,possibleposition[59])){ 712 adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]); 713 adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); 714 adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); 715 } 716 else if(findpos(actuelposition,possibleposition[60])){ 717 adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); 718 adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]); 719 adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]); 720 } 721 else if(findpos(actuelposition,possibleposition[61])){ 722 adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]); 723 adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]); 724 adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); 725 } 726 else if(findpos(actuelposition,possibleposition[62])){ 727 adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]); 728 adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]); 729 } 730 else if(findpos(actuelposition,possibleposition[63])){ 731 adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]); 732 adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); 733 } 734 else if(findpos(actuelposition,possibleposition[64])){ 735 adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]); 736 adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]); 737 adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]); 738 } 739 else if(findpos(actuelposition,possibleposition[65])){ 740 adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]); 741 adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]); 742 } 743 else if(findpos(actuelposition,possibleposition[66])){ 744 adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]); 745 adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); 746 } 747 } 748 749 750 751 752 753 /*Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal){ 259 754 //this function should then somehow produce the algorithm and call all other functions 260 755 //and finally return the best neighboor of the actual position of the pacman … … 727 1222 adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]); 728 1223 } 729 } 1224 }*/ 730 1225 731 1226
Note: See TracChangeset
for help on using the changeset viewer.