Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12325


Ignore:
Timestamp:
Apr 28, 2019, 1:07:32 AM (5 years ago)
Author:
peterf
Message:

Red and Pink seem to work better

Location:
code/branches/3DPacman_FS19/src/modules/pacman
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc

    r12323 r12325  
    102102                }
    103103                else{
     104                    if(findpos(this->lastPlayerPassedPoint, Vector3(-215,10,-195))){
    104105                    Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195));
    105106                    this->setNewTargetGhost(nextMoveP);
     107                    }
     108                    else{
     109                    Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195), this->lastPlayerPassedPoint);
     110                    this->setNewTargetGhost(nextMoveP);
     111                    }
    106112                }
    107113
     
    123129
    124130
    125             /*if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){
    126                 //no idea if 50 is large enough
    127 
    128                 //if near player, flee
    129 
    130                 this->isFleeing=true;
    131                 Vector3 nextMove=getShortestPath( brownPos,Vector3(-215, 10, -195));
    132                 setNewTargetGhost(nextMove);
    133 
    134             }
    135 
    136             else if((this->isFleeing==true)&&(!findpos(brownPos,Vector3(-215,10,-195)))){
    137                 //if fleeing, continue to flee
    138              Vector3 nextMove = getShortestPath(brownPos, Vector3(-215, 10, -195));
    139              setNewTargetGhost(nextMove);
    140         }
    141             else if ((this->isFleeing==true)&&(findpos(brownPos,Vector3(-215,10,-195)))){
    142                 //if fleeing and reached flee point, go back near player
    143             this->isFleeing=false;
    144             Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
    145             setNewTargetGhost(nextMove);
    146         }
    147             else{
    148                 //if not fleeing and not near player, go near player
    149                 Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
    150             setNewTargetGhost(nextMove);
    151             }
    152             if(this->isFleeing){
    153                 std::cout<<"fleeing"<<endl;
    154             }
    155         }*/
    156 
    157 
    158 
    159 
    160                 /*if((this->fleeing==true)&&(this->actuelposition!=(-215,10,-195))){
    161             //if fleeing, then go to corner map if not already there
    162                         fleeMode();
    163                 }
    164                 else{ // else go next to pacman
    165 
    166                         if(absoluteDistance(this->pos, player.pos)<10){//no idea if 10 ok
    167                 //if near player, flee away
    168                 fleemode();
    169                                 }
    170                         else{ //go to neighboor of player nearest to brown pacman
    171 
    172                         //first find nearest neighboor point of player to brown pacman
    173                         //we can maybe call getShortestPath recursively to do so
    174 
    175 player.pos.nearestneighboor=findPlayerNeighboorNearestToPacman(player.neighboors);
    176 //btw the array player.neighboor can be defined with a big list as we
    177 //already did several times for similar things
    178 
    179                 Vector3 nextMove = getShortestPath(this->actuelposition, player.pos.nearestneighboor);
    180                 setNewTargetBrown(nextMove);
    181                         }
    182 
    183                 }*/
    184131            lockmove=false; //NEVER FORGET THIS ONE !!!
    185132   
     
    204151
    205152
    206         void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){     
     153        /*void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){     
    207154            //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint
    208155
     
    515462                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
    516463                       }
    517     }
     464    }*/
    518465
    519466
     
    521468}
    522469
    523 
    524 
    525 
    526 
    527 
    528 
    529 
    530 
    531         /*int graphDistance(Vector3 start, Vector3 goal){
    532 
    533         Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
    534 
    535         return differenceVector.x+differenceVector.z;
    536     }*/
    537 
    538         /*void setNewTargetBrown(Vector3 goalToGo){
    539 
    540                                         this->target_x = goalToGo.x;
    541                     this->target_z = goalToGo.z;
    542                     this->ismoving = true;
    543         }*/
    544 
    545 
    546 
    547         /*int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){
    548 
    549 
    550                 Vector3 diffVector;
    551                 diffVector.x=pos2-pos1;
    552                 diffVector.y=pos2-pos1; //should always be 0
    553                 diffVector.z=pos2-pos1;
    554                 int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z));
    555                 return result;
    556         }*/
    557 
    558 
    559         /*void fleeMode(){ //flees to corner of the map
    560 
    561                 Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change
    562                 Vector3 nextMove = getShortestPath(this->actuelposition, cornerPos);
    563                 setNewTargetGhost(nextMove);
    564 
    565                 //while(this->actuelposition!=cornerPos){
    566        
    567                 continue moving and each time find next point to go until
    568                 we reach the corner
    569                 }
    570         }*/
    571 
    572 
    573         /*Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){
    574                 //find ,nearest to brown, player neighboor
    575 
    576                 int besTotDist=-1;
    577                 Vector3 curPos=this->pos;
    578                 Vector3  predPos;
    579                 Vector3 chosenNeighbor;
    580 
    581                 for(int i=0; i < 4; i++){
    582                         int totDist=0;
    583 
    584                         if(neighboorsOfPlayer[i]!=0){
    585                                 while(curPos!=neighboorsOfPlayer[i]){
    586 
    587                                         predPos=curPos;
    588                                         curPos = getShortestPath(curPos, neighboorsOfPlayer[i]);
    589                                         totDist+=graphDistance(curPos,predPos);
    590 
    591                                 }
    592                         }
    593 
    594                         if(besTotDist==-1){
    595                                 besTotDist=totDist;
    596                                 chosenNeighbor=neighboorsOfPlayer[i];
    597                         }
    598                         else if(besTotDist>totDist){
    599                                 besTotDist=totDist;
    600                                 chosenNeighbor=neighboorsOfPlayer[i];
    601                         }
    602                 }
    603                 return chosenNeighbor;
    604 
    605         }*/
    606 
    607 
    608         /*Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){
    609                 //uh, i think it does the same think as the function above
    610 
    611         Vector3 nextMove;
    612         int distCost=-1;
    613         for(int i=0; i < 4; i++){
    614                 int totDist=0;
    615                 Vector3 newCandidate=this->actuelposition;
    616                 Vector3 predPos;
    617 
    618             if(neighboorArray[i]!=NULL){
    619                 while(nextMove!=neighboorArray[i]){
    620                         predPos=newCandidate;
    621                         newCandidate=getShortestPath(newCandidate, neighboorArray[i]);
    622                         totDist+=graphDistance(predPos, newCandidate);
    623                     }
    624 
    625                     if(distCost==-1){
    626                 distCost=totDist;
    627                 nextMove=gneighboorArray[i];
    628                     }
    629                     else if(totDist<distCost){
    630                 distCost=totDist;
    631                 nextMove=neighboorArray[i];
    632                     }
    633             }
    634         }
    635         return nextMove;
    636 
    637     }*/
    638 
    639 
    640 
    641 
    642 
    643 
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h

    r12322 r12325  
    3737        bool isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]);
    3838
    39         void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
     39        //void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
    4040
    4141
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc

    r12324 r12325  
    784784            }
    785785        }
    786 
    787 
    788         /*Vector3 difference = diffVector(playerPosBefore, playerPos);
    789         if((difference.z < 0)&&(difference.z>difference.x)){ //move south
    790 
    791             return 0;
    792         }
    793         else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north
    794 
    795             return 2;
    796         }
    797         else if((difference.x < 0)&&(difference.x > difference.z )){//move west
    798 
    799             return 1;
    800         }
    801 
    802         else if((difference.x>0)&&(difference.x>difference.z)){ //move east
    803             return 3;
    804 
    805         }
    806 
    807         else { //default move west Can still be changed
    808 
    809         return 1;
    810             }*/
    811786       
    812787        }
     
    829804                listOfNeighboors[2]=possibleposition[17]; //north
    830805                listOfNeighboors[3]=possibleposition[1]; //east
    831                 return listOfNeighboors[indexForSWNE];
     806                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    832807            }
    833808            else if(findpos(pacLasVisPos,possibleposition[1])){
    834809                listOfNeighboors[1]=possibleposition[0]; // west neighbor
    835810                listOfNeighboors[2]=possibleposition[2]; //north
    836                 return listOfNeighboors[indexForSWNE];
     811                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    837812            }
    838813            else if(findpos(pacLasVisPos,possibleposition[2])){
    839814                listOfNeighboors[0]=possibleposition[1];  //south
    840815                listOfNeighboors[1]=possibleposition[3]; //west
    841                 return listOfNeighboors[indexForSWNE];
     816                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    842817            }
    843818            else if(findpos(pacLasVisPos,possibleposition[3])){
     
    845820                listOfNeighboors[2]=possibleposition[5]; //north
    846821                listOfNeighboors[3]=possibleposition[2]; //east
    847                 return listOfNeighboors[indexForSWNE];
     822                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    848823            }
    849824            else if(findpos(pacLasVisPos,possibleposition[4])){
    850825                listOfNeighboors[2]=possibleposition[6]; //north
    851826                listOfNeighboors[3]=possibleposition[3]; //east
    852                 return listOfNeighboors[indexForSWNE];
     827                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    853828            }
    854829            else if(findpos(pacLasVisPos,possibleposition[5])){
    855830                listOfNeighboors[0]=possibleposition[3]; //south
    856831                listOfNeighboors[3]=possibleposition[7]; //east
    857                 return listOfNeighboors[indexForSWNE];
     832                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    858833            }
    859834            else if(findpos(pacLasVisPos,possibleposition[6])){
     
    861836                listOfNeighboors[1]=possibleposition[26]; //west
    862837                listOfNeighboors[2]=possibleposition[9]; //north
    863                 return listOfNeighboors[indexForSWNE];
     838                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    864839            }
    865840            else if(findpos(pacLasVisPos,possibleposition[7])){
    866841                listOfNeighboors[1]=possibleposition[5]; //west
    867842                listOfNeighboors[2]=possibleposition[8]; //north
    868                 return listOfNeighboors[indexForSWNE];
     843                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    869844            }
    870845            else if(findpos(pacLasVisPos,possibleposition[8])){
    871846                listOfNeighboors[0]=possibleposition[7]; //south
    872847                listOfNeighboors[1]=possibleposition[9]; //west
    873                 return listOfNeighboors[indexForSWNE];
     848                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    874849            }
    875850            else if(findpos(pacLasVisPos,possibleposition[9])){
     
    878853                listOfNeighboors[2]=possibleposition[10]; //north
    879854                listOfNeighboors[3]=possibleposition[8]; //east
    880                 return listOfNeighboors[indexForSWNE];
     855                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    881856            }
    882857            else if(findpos(pacLasVisPos,possibleposition[10])){
     
    889864                listOfNeighboors[1]=possibleposition[45]; //west
    890865                listOfNeighboors[2]=possibleposition[11]; //north
    891                 return listOfNeighboors[indexForSWNE];
     866                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    892867            }
    893868            else if(findpos(pacLasVisPos,possibleposition[11])){
     
    895870                listOfNeighboors[2]=possibleposition[13]; //north
    896871                listOfNeighboors[3]=possibleposition[12]; //east
    897                 return listOfNeighboors[indexForSWNE];
     872                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    898873            }
    899874            else if(findpos(pacLasVisPos,possibleposition[12])){
    900875                listOfNeighboors[1]=possibleposition[11]; //west
    901876                listOfNeighboors[2]=possibleposition[14]; //north
    902                 return listOfNeighboors[indexForSWNE];
     877                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    903878            }
    904879            else if(findpos(pacLasVisPos,possibleposition[13])){
     
    907882                listOfNeighboors[2]=possibleposition[16]; //north
    908883                listOfNeighboors[3]=possibleposition[14]; //east
    909                 return listOfNeighboors[indexForSWNE];
     884                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    910885            }
    911886            else if(findpos(pacLasVisPos,possibleposition[14])){
     
    913888                listOfNeighboors[1]=possibleposition[13]; //west
    914889                listOfNeighboors[2]=possibleposition[15]; //north
    915                 return listOfNeighboors[indexForSWNE];
     890                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    916891            }
    917892            else if(findpos(pacLasVisPos,possibleposition[15])){
    918893                listOfNeighboors[0]=possibleposition[14]; //south
    919894                listOfNeighboors[1]=possibleposition[16]; //west
    920                 return listOfNeighboors[indexForSWNE];
     895                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    921896            }
    922897            else if(findpos(pacLasVisPos,possibleposition[16])){
     
    924899                listOfNeighboors[1]=possibleposition[62]; //west
    925900                listOfNeighboors[2]=possibleposition[15]; //north
    926                 return listOfNeighboors[indexForSWNE];
     901                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    927902            }
    928903            else if(findpos(pacLasVisPos,possibleposition[17])){
    929904                listOfNeighboors[0]=possibleposition[0]; //south
    930905                listOfNeighboors[3]=possibleposition[25]; //east
    931                 return listOfNeighboors[indexForSWNE];
     906                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    932907            }
    933908            else if(findpos(pacLasVisPos,possibleposition[18])){
    934909                listOfNeighboors[0]=possibleposition[19]; //south
    935910                listOfNeighboors[1]=possibleposition[24]; //west
    936                 return listOfNeighboors[indexForSWNE];
     911                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    937912            }
    938913            else if(findpos(pacLasVisPos,possibleposition[19])){
     
    940915                listOfNeighboors[2]=possibleposition[18]; //north
    941916                listOfNeighboors[3]=possibleposition[0]; //east
    942                 return listOfNeighboors[indexForSWNE];
     917                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    943918            }
    944919            else if(findpos(pacLasVisPos,possibleposition[20])){
    945920                listOfNeighboors[2]=possibleposition[21]; //north
    946921                listOfNeighboors[3]=possibleposition[19]; //east
    947                 return listOfNeighboors[indexForSWNE];
     922                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    948923            }
    949924            else if(findpos(pacLasVisPos,possibleposition[21])){
    950925                listOfNeighboors[0]=possibleposition[20]; //south
    951926                listOfNeighboors[3]=possibleposition[22]; //east
    952                 return listOfNeighboors[indexForSWNE];
     927                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    953928            }
    954929            else if(findpos(pacLasVisPos,possibleposition[22])){
     
    956931                listOfNeighboors[2]=possibleposition[31]; //north
    957932                listOfNeighboors[3]=possibleposition[23]; //east
    958                 return listOfNeighboors[indexForSWNE];
     933                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    959934            }
    960935            else if(findpos(pacLasVisPos,possibleposition[23])){
    961936                listOfNeighboors[1]=possibleposition[22]; //west
    962937                listOfNeighboors[2]=possibleposition[30]; //north
    963                 return listOfNeighboors[indexForSWNE];
     938                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    964939            }
    965940            else if(findpos(pacLasVisPos,possibleposition[24])){
    966941                listOfNeighboors[2]=possibleposition[29]; //north
    967942                listOfNeighboors[3]=possibleposition[18]; //east
    968                 return listOfNeighboors[indexForSWNE];
     943                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    969944            }
    970945            else if(findpos(pacLasVisPos,possibleposition[25])){
    971946                listOfNeighboors[1]=possibleposition[17]; //west
    972947                listOfNeighboors[2]=possibleposition[26]; //north
    973                 return listOfNeighboors[indexForSWNE];
     948                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    974949            }
    975950            else if(findpos(pacLasVisPos,possibleposition[26])){
     
    977952                listOfNeighboors[1]=possibleposition[27]; //west
    978953                listOfNeighboors[3]=possibleposition[6]; //east
    979                 return listOfNeighboors[indexForSWNE];
     954                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    980955            }
    981956            else if(findpos(pacLasVisPos,possibleposition[27])){
     
    983958                listOfNeighboors[2]=possibleposition[37]; //north
    984959                listOfNeighboors[3]=possibleposition[26]; //east
    985                 return listOfNeighboors[indexForSWNE];
     960                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    986961            }
    987962            else if(findpos(pacLasVisPos,possibleposition[28])){
     
    989964                listOfNeighboors[2]=possibleposition[36]; //north
    990965                listOfNeighboors[3]=possibleposition[27]; //east
    991                 return listOfNeighboors[indexForSWNE];
     966                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    992967            }
    993968            else if(findpos(pacLasVisPos,possibleposition[29])){
     
    995970                listOfNeighboors[1]=possibleposition[30]; //west
    996971                listOfNeighboors[3]=possibleposition[28]; //east
    997                 return listOfNeighboors[indexForSWNE];
     972                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    998973            }
    999974            else if(findpos(pacLasVisPos,possibleposition[30])){
     
    1001976                listOfNeighboors[2]=possibleposition[34]; //north
    1002977                listOfNeighboors[3]=possibleposition[29]; //east
    1003                 return listOfNeighboors[indexForSWNE];
     978                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    1004979            }
    1005980            else if(findpos(pacLasVisPos,possibleposition[31])){
    1006981                listOfNeighboors[0]=possibleposition[22]; //south
    1007982                listOfNeighboors[1]=possibleposition[32]; //west
    1008                 return listOfNeighboors[indexForSWNE];
     983                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    1009984            }
    1010985            else if(findpos(pacLasVisPos,possibleposition[32])){
    1011986                listOfNeighboors[2]=possibleposition[33]; //north
    1012987                listOfNeighboors[3]=possibleposition[31]; //east
    1013                 return listOfNeighboors[indexForSWNE];
     988                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    1014989            }
    1015990            else if(findpos(pacLasVisPos,possibleposition[33])){
    1016991                listOfNeighboors[0]=possibleposition[32]; //south
    1017992                listOfNeighboors[3]=possibleposition[34]; //east
    1018                 return listOfNeighboors[indexForSWNE];
     993                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    1019994            }
    1020995            else if(findpos(pacLasVisPos,possibleposition[34])){
     
    1023998                listOfNeighboors[2]=possibleposition[92]; //north
    1024999                listOfNeighboors[3]=possibleposition[35]; //east
    1025                 return listOfNeighboors[indexForSWNE];
     1000                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10261001            }
    10271002            else if(findpos(pacLasVisPos,possibleposition[35])){
     
    10291004                listOfNeighboors[2]=possibleposition[91]; //north
    10301005                listOfNeighboors[3]=possibleposition[36]; //east
    1031                 return listOfNeighboors[indexForSWNE];
     1006                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10321007            }
    10331008            else if(findpos(pacLasVisPos,possibleposition[36])){
    10341009                listOfNeighboors[0]=possibleposition[28]; //south
    10351010                listOfNeighboors[1]=possibleposition[35]; //west
    1036                 return listOfNeighboors[indexForSWNE];
     1011                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10371012            }
    10381013            else if(findpos(pacLasVisPos,possibleposition[37])){
    10391014                listOfNeighboors[0]=possibleposition[27]; //south
    10401015                listOfNeighboors[3]=possibleposition[38]; //east
    1041                 return listOfNeighboors[indexForSWNE];
     1016                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10421017            }
    10431018            else if(findpos(pacLasVisPos,possibleposition[38])){
     
    10451020                listOfNeighboors[2]=possibleposition[39]; //north
    10461021                listOfNeighboors[3]=possibleposition[9]; //east
    1047                 return listOfNeighboors[indexForSWNE];
     1022                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10481023            }
    10491024            else if(findpos(pacLasVisPos,possibleposition[39])){
     
    10511026                listOfNeighboors[1]=possibleposition[40]; //west
    10521027                listOfNeighboors[2]=possibleposition[45]; //north
    1053                 return listOfNeighboors[indexForSWNE];
     1028                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10541029            }
    10551030            else if(findpos(pacLasVisPos,possibleposition[40])){
     
    10571032                //Not return in center
    10581033                listOfNeighboors[3]=possibleposition[39]; //east
    1059                 return listOfNeighboors[indexForSWNE];
     1034                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10601035            }
    10611036            else if(findpos(pacLasVisPos,possibleposition[41])){
     
    10631038                listOfNeighboors[2]=possibleposition[43]; //north
    10641039                listOfNeighboors[3]=possibleposition[40]; //east
    1065                 return listOfNeighboors[indexForSWNE];
     1040                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10661041            }
    10671042            else if(findpos(pacLasVisPos,possibleposition[42])){
     
    10741049                listOfNeighboors[2]=possibleposition[59]; //north
    10751050                listOfNeighboors[3]=possibleposition[43]; //east
    1076                 return listOfNeighboors[indexForSWNE];
     1051                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10771052            }
    10781053            else if(findpos(pacLasVisPos,possibleposition[43])){
     
    10801055                listOfNeighboors[1]=possibleposition[42]; //west
    10811056                listOfNeighboors[2]=possibleposition[46]; //north
    1082                 return listOfNeighboors[indexForSWNE];
     1057                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10831058            }
    10841059            else if(findpos(pacLasVisPos,possibleposition[44])){
    10851060                listOfNeighboors[0]=possibleposition[40]; //south
    10861061                listOfNeighboors[2]=possibleposition[66]; //north
    1087                 return listOfNeighboors[indexForSWNE];
     1062                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10881063            }
    10891064            else if(findpos(pacLasVisPos,possibleposition[45])){
     
    10911066                listOfNeighboors[2]=possibleposition[49]; //north
    10921067                listOfNeighboors[3]=possibleposition[10]; //east
    1093                 return listOfNeighboors[indexForSWNE];
     1068                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10941069            }
    10951070            else if(findpos(pacLasVisPos,possibleposition[46])){
    10961071                listOfNeighboors[0]=possibleposition[43]; //south
    10971072                listOfNeighboors[3]=possibleposition[47]; //east
    1098                 return listOfNeighboors[indexForSWNE];
     1073                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    10991074            }
    11001075            else if(findpos(pacLasVisPos,possibleposition[47])){
     
    11021077                listOfNeighboors[2]=possibleposition[52]; //north
    11031078                listOfNeighboors[3]=possibleposition[66]; //east
    1104                 return listOfNeighboors[indexForSWNE];
     1079                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11051080            }
    11061081            else if(findpos(pacLasVisPos,possibleposition[48])){
     
    11081083                listOfNeighboors[2]=possibleposition[51]; //north
    11091084                listOfNeighboors[3]=possibleposition[49]; //east
    1110                 return listOfNeighboors[indexForSWNE];
     1085                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11111086            }
    11121087            else if(findpos(pacLasVisPos,possibleposition[49])){
    11131088                listOfNeighboors[0]=possibleposition[45]; //south
    11141089                listOfNeighboors[1]=possibleposition[48]; //west
    1115                 return listOfNeighboors[indexForSWNE];
     1090                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11161091            }
    11171092            else if(findpos(pacLasVisPos,possibleposition[50])){
    11181093                listOfNeighboors[1]=possibleposition[51]; //west
    11191094                listOfNeighboors[2]=possibleposition[61]; //north
    1120                 return listOfNeighboors[indexForSWNE];
     1095                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11211096            }
    11221097            else if(findpos(pacLasVisPos,possibleposition[51])){
    11231098                listOfNeighboors[0]=possibleposition[48]; //south
    11241099                listOfNeighboors[3]=possibleposition[50]; //east
    1125                 return listOfNeighboors[indexForSWNE];
     1100                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11261101            }
    11271102            else if(findpos(pacLasVisPos,possibleposition[52])){
    11281103                listOfNeighboors[0]=possibleposition[47]; //south
    11291104                listOfNeighboors[1]=possibleposition[53]; //west
    1130                 return listOfNeighboors[indexForSWNE];
     1105                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11311106            }
    11321107            else if(findpos(pacLasVisPos,possibleposition[53])){
    11331108                listOfNeighboors[2]=possibleposition[58]; //north
    11341109                listOfNeighboors[3]=possibleposition[52]; //east
    1135                 return listOfNeighboors[indexForSWNE];
     1110                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11361111            }
    11371112            else if(findpos(pacLasVisPos,possibleposition[54])){
     
    11391114                listOfNeighboors[1]=possibleposition[55]; //west
    11401115                listOfNeighboors[2]=possibleposition[57]; //north
    1141                 return listOfNeighboors[indexForSWNE];
     1116                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11421117            }
    11431118            else if(findpos(pacLasVisPos,possibleposition[55])){
    11441119                listOfNeighboors[2]=possibleposition[56]; //north
    11451120                listOfNeighboors[3]=possibleposition[54]; //east
    1146                 return listOfNeighboors[indexForSWNE];
     1121                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11471122            }
    11481123            else if(findpos(pacLasVisPos,possibleposition[56])){
     
    11501125                listOfNeighboors[2]=possibleposition[65]; //north
    11511126                listOfNeighboors[3]=possibleposition[57]; //east
    1152                 return listOfNeighboors[indexForSWNE];
     1127                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11531128            }
    11541129            else if(findpos(pacLasVisPos,possibleposition[57])){
     
    11571132                listOfNeighboors[2]=possibleposition[64]; //north
    11581133                listOfNeighboors[3]=possibleposition[58]; //east
    1159                 return listOfNeighboors[indexForSWNE];
     1134                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11601135            }
    11611136            else if(findpos(pacLasVisPos,possibleposition[58])){
     
    11631138                listOfNeighboors[1]=possibleposition[57]; //west
    11641139                listOfNeighboors[3]=possibleposition[59]; //east
    1165                 return listOfNeighboors[indexForSWNE];
     1140                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11661141            }
    11671142            else if(findpos(pacLasVisPos,possibleposition[59])){
     
    11691144                listOfNeighboors[2]=possibleposition[63]; //north
    11701145                listOfNeighboors[3]=possibleposition[60]; //east
    1171                 return listOfNeighboors[indexForSWNE];
     1146                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11721147            }
    11731148            else if(findpos(pacLasVisPos,possibleposition[60])){
     
    11751150                listOfNeighboors[2]=possibleposition[62]; //north
    11761151                listOfNeighboors[3]=possibleposition[61]; //east
    1177                 return listOfNeighboors[indexForSWNE];
     1152                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11781153            }
    11791154            else if(findpos(pacLasVisPos,possibleposition[61])){
     
    11811156                listOfNeighboors[1]=possibleposition[60]; //west
    11821157                listOfNeighboors[3]=possibleposition[13]; //east
    1183                 return listOfNeighboors[indexForSWNE];
     1158                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11841159            }
    11851160            else if(findpos(pacLasVisPos,possibleposition[62])){
    11861161                listOfNeighboors[0]=possibleposition[60]; //south
    11871162                listOfNeighboors[3]=possibleposition[16]; //east
    1188                 return listOfNeighboors[indexForSWNE];
     1163                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11891164            }
    11901165            else if(findpos(pacLasVisPos,possibleposition[63])){
    11911166                listOfNeighboors[0]=possibleposition[59]; //south
    11921167                listOfNeighboors[1]=possibleposition[64]; //west
    1193                 return listOfNeighboors[indexForSWNE];
     1168                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    11941169            }
    11951170            else if(findpos(pacLasVisPos,possibleposition[64])){
     
    11971172                listOfNeighboors[1]=possibleposition[65]; //west
    11981173                listOfNeighboors[3]=possibleposition[63]; //east
    1199                 return listOfNeighboors[indexForSWNE];
     1174                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    12001175            }
    12011176            else if(findpos(pacLasVisPos,possibleposition[65])){
    12021177                listOfNeighboors[0]=possibleposition[56]; //south
    12031178                listOfNeighboors[3]=possibleposition[64]; //east
    1204                 return listOfNeighboors[indexForSWNE];
     1179                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
    12051180            }
    12061181            else if(findpos(pacLasVisPos,possibleposition[66])){
     
    12081183                listOfNeighboors[1]=possibleposition[47]; //west
    12091184                listOfNeighboors[3]=possibleposition[48]; //east
    1210                 return listOfNeighboors[indexForSWNE];           
    1211             }
    1212 
    1213         }
     1185                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);           
     1186            }
     1187
     1188        }
     1189
     1190
     1191
     1192
     1193///////////////////////
     1194
     1195
     1196
     1197
     1198
     1199    Vector3 PacmanGhost::frontPosition(){
     1200
     1201    Vector3 neighborPos[4] = {Vector3(-1,-1,-1)};
     1202    Vector3 frontPoint = Vector3(0,-1,0);
     1203
     1204
     1205    findNeighboorPositions(this->lastPlayerPassedPoint, neighborPos, possibleposition);
     1206
     1207    for(int i=0; i<4; i++){
     1208
     1209     if((neighborPos[i]!=Vector3(-1,-1,-1))&&(neighborPos[i].y==10)){
     1210     //y==10 to ignore many unwanted strange positions that pop up otherwise and create SIGSEV
     1211       
     1212        if(frontPoint==Vector3(0,-1,0)){
     1213            frontPoint=neighborPos[i];
     1214
     1215                        }
     1216        else if (graphDistance(this->getPlayerPos(), frontPoint)>graphDistance(this->getPlayerPos(), neighborPos[i])){
     1217            frontPoint=neighborPos[i];
     1218                        }
     1219
     1220                    }
     1221        std::cout<<"bra"<<frontPoint<<endl;
     1222                }
     1223
     1224    if(frontPoint==Vector3(0,-1,0)){
     1225        //default
     1226        return this->lastPlayerPassedPoint;
     1227            }
     1228    else{
     1229        std::cout<<frontPoint<<endl;
     1230        return frontPoint;
     1231            }
     1232    }
     1233
     1234
     1235
     1236
     1237
     1238
     1239    void PacmanGhost::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){     
     1240            //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint
     1241
     1242            if(findpos(actuelposition,possibleposition[0])){
     1243               
     1244
     1245                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);  //need to do it everywhere !!!
     1246                adjacentPositions[1]=positionArray[17]; //graphVertex(possibleposition[17]);
     1247                adjacentPositions[2]=positionArray[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
     1248            }
     1249            else if(findpos(actuelposition,possibleposition[1])){
     1250                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
     1251                adjacentPositions[1]=positionArray[2]; //graphVertex(possibleposition[2]);
     1252            }
     1253            else if(findpos(actuelposition,possibleposition[2])){
     1254                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);
     1255                adjacentPositions[1]=positionArray[3]; //graphVertex(possibleposition[3]);
     1256            }
     1257            else if(findpos(actuelposition,possibleposition[3])){
     1258                adjacentPositions[0]=positionArray[2]; //graphVertex(possibleposition[2]);
     1259                adjacentPositions[1]=positionArray[4]; //graphVertex(possibleposition[4]);
     1260                adjacentPositions[2]=positionArray[5]; //graphVertex(possibleposition[5]);
     1261            }
     1262            else if(findpos(actuelposition,possibleposition[4])){
     1263                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
     1264                adjacentPositions[1]=positionArray[6]; //graphVertex(possibleposition[6]);
     1265            }
     1266            else if(findpos(actuelposition,possibleposition[5])){
     1267                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
     1268                adjacentPositions[1]=positionArray[7]; //graphVertex(possibleposition[7]);
     1269            }
     1270            else if(findpos(actuelposition,possibleposition[6])){
     1271                adjacentPositions[0]=positionArray[4]; //graphVertex(possibleposition[4]);
     1272                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
     1273                adjacentPositions[2]=positionArray[26]; //graphVertex(possibleposition[26]);
     1274            }
     1275            else if(findpos(actuelposition,possibleposition[7])){
     1276                adjacentPositions[0]=positionArray[5]; //graphVertex(possibleposition[5]);
     1277                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
     1278            }
     1279            else if(findpos(actuelposition,possibleposition[8])){
     1280                adjacentPositions[0]=positionArray[7]; //graphVertex(possibleposition[7]);
     1281                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
     1282            }
     1283            else if(findpos(actuelposition,possibleposition[9])){
     1284                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
     1285                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
     1286                adjacentPositions[2]=positionArray[10]; //graphVertex(possibleposition[10]);
     1287                adjacentPositions[3]=positionArray[38]; //graphVertex(possibleposition[38]);
     1288            }
     1289            else if(findpos(actuelposition,possibleposition[10])){
     1290                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
     1291                adjacentPositions[1]=positionArray[11]; //graphVertex(possibleposition[11]);
     1292                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
     1293            }
     1294            else if(findpos(actuelposition,possibleposition[11])){
     1295                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
     1296                adjacentPositions[1]=positionArray[12]; //graphVertex(possibleposition[12]);
     1297                adjacentPositions[2]=positionArray[13]; //graphVertex(possibleposition[13]);
     1298            }
     1299            else if(findpos(actuelposition,possibleposition[12])){
     1300                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
     1301                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
     1302            }
     1303            else if(findpos(actuelposition,possibleposition[13])){
     1304                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
     1305                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
     1306                adjacentPositions[2]=positionArray[16]; //graphVertex(possibleposition[16]);
     1307                adjacentPositions[3]=positionArray[61]; //graphVertex(possibleposition[61]);
     1308            }
     1309            else if(findpos(actuelposition,possibleposition[14])){
     1310                adjacentPositions[0]=positionArray[12]; //graphVertex(possibleposition[12]);
     1311                adjacentPositions[1]=positionArray[13]; //graphVertex(possibleposition[13]);
     1312                adjacentPositions[2]=positionArray[15]; //graphVertex(possibleposition[15]);
     1313            }
     1314            else if(findpos(actuelposition,possibleposition[15])){
     1315                adjacentPositions[0]=positionArray[14]; //graphVertex(possibleposition[14]);
     1316                adjacentPositions[1]=positionArray[16]; //graphVertex(possibleposition[16]);
     1317            }
     1318            else if(findpos(actuelposition,possibleposition[16])){
     1319                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
     1320                adjacentPositions[1]=positionArray[15]; //graphVertex(possibleposition[15]);
     1321                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
     1322            }
     1323            else if(findpos(actuelposition,possibleposition[17])){
     1324                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
     1325                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
     1326            }
     1327            else if(findpos(actuelposition,possibleposition[18])){
     1328                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
     1329                adjacentPositions[1]=positionArray[24]; //graphVertex(possibleposition[24]);               
     1330            }
     1331            else if(findpos(actuelposition,possibleposition[19])){
     1332                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
     1333                adjacentPositions[1]=positionArray[18]; //graphVertex(possibleposition[18]);
     1334                adjacentPositions[2]=positionArray[20]; //graphVertex(possibleposition[20]);
     1335                         }
     1336            else if(findpos(actuelposition,possibleposition[20])){
     1337                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
     1338                adjacentPositions[1]=positionArray[21]; //graphVertex(possibleposition[21]);
     1339                       }
     1340            else if(findpos(actuelposition,possibleposition[21])){
     1341                adjacentPositions[0]=positionArray[20]; //graphVertex(possibleposition[20]);
     1342                adjacentPositions[1]=positionArray[22]; //graphVertex(possibleposition[22]);
     1343                       }
     1344            else if(findpos(actuelposition,possibleposition[22])){
     1345                adjacentPositions[0]=positionArray[21]; //graphVertex(possibleposition[21]);
     1346                adjacentPositions[1]=positionArray[23]; //graphVertex(possibleposition[23]);
     1347                adjacentPositions[2]=positionArray[31]; //graphVertex(possibleposition[31]);
     1348                          }
     1349            else if(findpos(actuelposition,possibleposition[23])){
     1350                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
     1351                adjacentPositions[1]=positionArray[30]; //graphVertex(possibleposition[30]);
     1352                       }
     1353            else if(findpos(actuelposition,possibleposition[24])){
     1354                adjacentPositions[0]=positionArray[18]; //graphVertex(possibleposition[18]);
     1355                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
     1356                       }
     1357            else if(findpos(actuelposition,possibleposition[25])){
     1358                adjacentPositions[0]=positionArray[17]; //graphVertex(possibleposition[17]);
     1359                adjacentPositions[1]=positionArray[26]; //graphVertex(possibleposition[26]);
     1360                       }
     1361            else if(findpos(actuelposition,possibleposition[26])){
     1362                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
     1363                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
     1364                adjacentPositions[2]=positionArray[27]; //graphVertex(possibleposition[27]);
     1365                         }
     1366            else if(findpos(actuelposition,possibleposition[27])){
     1367                adjacentPositions[0]=positionArray[26]; //graphVertex(possibleposition[26]);
     1368                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
     1369                adjacentPositions[2]=positionArray[37]; //graphVertex(possibleposition[37]);
     1370                          }
     1371            else if(findpos(actuelposition,possibleposition[28])){
     1372                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
     1373                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
     1374                adjacentPositions[2]=positionArray[36]; //graphVertex(possibleposition[36]);
     1375                          }
     1376            else if(findpos(actuelposition,possibleposition[29])){
     1377                adjacentPositions[0]=positionArray[24]; //graphVertex(possibleposition[24]);
     1378                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
     1379                adjacentPositions[2]=positionArray[30]; //graphVertex(possibleposition[30]);
     1380                          }
     1381            else if(findpos(actuelposition,possibleposition[30])){
     1382                adjacentPositions[0]=positionArray[23]; //graphVertex(possibleposition[23]);
     1383                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
     1384                adjacentPositions[2]=positionArray[34]; //graphVertex(possibleposition[34]);
     1385                          }
     1386            else if(findpos(actuelposition,possibleposition[31])){
     1387                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
     1388                adjacentPositions[1]=positionArray[32]; //graphVertex(possibleposition[32]);
     1389                       }
     1390            else if(findpos(actuelposition,possibleposition[32])){
     1391                adjacentPositions[0]=positionArray[31]; //graphVertex(possibleposition[31]);
     1392                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
     1393                       }
     1394            else if(findpos(actuelposition,possibleposition[33])){
     1395                adjacentPositions[0]=positionArray[32]; //graphVertex(possibleposition[32]);
     1396                adjacentPositions[1]=positionArray[34]; //graphVertex(possibleposition[34]);
     1397                       }
     1398            else if(findpos(actuelposition,possibleposition[34])){
     1399                adjacentPositions[0]=positionArray[30]; //graphVertex(possibleposition[30]);
     1400                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
     1401                adjacentPositions[2]=positionArray[35]; //graphVertex(possibleposition[35]);
     1402                adjacentPositions[3]=positionArray[42]; //graphVertex(possibleposition[42]);
     1403               
     1404            }
     1405            else if(findpos(actuelposition,possibleposition[35])){
     1406                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
     1407                adjacentPositions[1]=positionArray[36]; //graphVertex(possibleposition[36]);
     1408                adjacentPositions[2]=positionArray[41]; //graphVertex(possibleposition[41]);
     1409                          }
     1410            else if(findpos(actuelposition,possibleposition[36])){
     1411                adjacentPositions[0]=positionArray[28]; //graphVertex(possibleposition[28]);
     1412                adjacentPositions[1]=positionArray[35]; //graphVertex(possibleposition[35]);
     1413                       }
     1414            else if(findpos(actuelposition,possibleposition[37])){
     1415                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
     1416                adjacentPositions[1]=positionArray[38]; //graphVertex(possibleposition[38]);
     1417                       }
     1418            else if(findpos(actuelposition,possibleposition[38])){
     1419                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
     1420                adjacentPositions[1]=positionArray[37]; //graphVertex(possibleposition[37]);
     1421                adjacentPositions[2]=positionArray[39]; //graphVertex(possibleposition[39]);
     1422                         }
     1423            else if(findpos(actuelposition,possibleposition[39])){
     1424                adjacentPositions[0]=positionArray[38]; //graphVertex(possibleposition[38]);
     1425                adjacentPositions[1]=positionArray[40]; //graphVertex(possibleposition[40]);
     1426                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
     1427                          }
     1428            else if(findpos(actuelposition,possibleposition[40])){
     1429                adjacentPositions[0]=positionArray[39]; //graphVertex(possibleposition[39]);
     1430                adjacentPositions[1]=positionArray[41]; //graphVertex(possibleposition[41]);
     1431            }
     1432            else if(findpos(actuelposition,possibleposition[41])){
     1433                adjacentPositions[0]=positionArray[35]; //graphVertex(possibleposition[35]);
     1434                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
     1435                       }
     1436            else if(findpos(actuelposition,possibleposition[42])){
     1437                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
     1438                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
     1439                adjacentPositions[2]=positionArray[54]; //graphVertex(possibleposition[54]);
     1440                          }
     1441            else if(findpos(actuelposition,possibleposition[43])){
     1442                adjacentPositions[0]=positionArray[41]; //graphVertex(possibleposition[41]);
     1443                adjacentPositions[1]=positionArray[46]; //graphVertex(possibleposition[46]);
     1444                       }
     1445            else if(findpos(actuelposition,possibleposition[44])){
     1446                adjacentPositions[0]=positionArray[40]; //graphVertex(possibleposition[40]);
     1447                adjacentPositions[1]=positionArray[66]; //graphVertex(possibleposition[66]);
     1448                       }
     1449            else if(findpos(actuelposition,possibleposition[45])){
     1450                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
     1451                adjacentPositions[1]=positionArray[39]; //graphVertex(possibleposition[39]);
     1452                adjacentPositions[2]=positionArray[49]; //graphVertex(possibleposition[49]);
     1453                          }
     1454            else if(findpos(actuelposition,possibleposition[46])){
     1455                adjacentPositions[0]=positionArray[43]; //graphVertex(possibleposition[43]);
     1456                adjacentPositions[1]=positionArray[47]; //graphVertex(possibleposition[47]);
     1457                       }
     1458            else if(findpos(actuelposition,possibleposition[47])){
     1459                adjacentPositions[0]=positionArray[46]; //graphVertex(possibleposition[46]);
     1460                adjacentPositions[1]=positionArray[52]; //graphVertex(possibleposition[52]);
     1461                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
     1462                          }
     1463            else if(findpos(actuelposition,possibleposition[48])){
     1464                adjacentPositions[0]=positionArray[49]; //graphVertex(possibleposition[49]);
     1465                adjacentPositions[1]=positionArray[51]; //graphVertex(possibleposition[51]);
     1466                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
     1467                          }
     1468            else if(findpos(actuelposition,possibleposition[49])){
     1469                adjacentPositions[0]=positionArray[45]; //graphVertex(possibleposition[45]);
     1470                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
     1471                       }
     1472            else if(findpos(actuelposition,possibleposition[50])){
     1473                adjacentPositions[0]=positionArray[51]; //graphVertex(possibleposition[51]);
     1474                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
     1475                       }
     1476            else if(findpos(actuelposition,possibleposition[51])){
     1477                adjacentPositions[0]=positionArray[48]; //graphVertex(possibleposition[48]);
     1478                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
     1479                       }
     1480            else if(findpos(actuelposition,possibleposition[52])){
     1481                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
     1482                adjacentPositions[1]=positionArray[53]; //graphVertex(possibleposition[53]);
     1483                       }
     1484            else if(findpos(actuelposition,possibleposition[53])){
     1485                adjacentPositions[0]=positionArray[52]; //graphVertex(possibleposition[52]);
     1486                adjacentPositions[1]=positionArray[58]; //graphVertex(possibleposition[58]);
     1487                       }
     1488            else if(findpos(actuelposition,possibleposition[54])){
     1489                adjacentPositions[0]=positionArray[42]; //graphVertex(possibleposition[42]);
     1490                adjacentPositions[1]=positionArray[55]; //graphVertex(possibleposition[55]);
     1491                adjacentPositions[2]=positionArray[57]; //graphVertex(possibleposition[57]);
     1492                          }
     1493            else if(findpos(actuelposition,possibleposition[55])){
     1494                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
     1495                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
     1496                       }
     1497            else if(findpos(actuelposition,possibleposition[56])){
     1498                adjacentPositions[0]=positionArray[55]; //graphVertex(possibleposition[55]);
     1499                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
     1500                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
     1501                          }
     1502            else if(findpos(actuelposition,possibleposition[57])){
     1503                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
     1504                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
     1505                adjacentPositions[2]=positionArray[58]; //graphVertex(possibleposition[58]);
     1506                adjacentPositions[3]=positionArray[64]; //graphVertex(possibleposition[64]);
     1507               
     1508            }
     1509            else if(findpos(actuelposition,possibleposition[58])){
     1510                adjacentPositions[0]=positionArray[53]; //graphVertex(possibleposition[53]);
     1511                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
     1512                adjacentPositions[2]=positionArray[59]; //graphVertex(possibleposition[59]);
     1513                          }
     1514            else if(findpos(actuelposition,possibleposition[59])){
     1515                adjacentPositions[0]=positionArray[58]; //graphVertex(possibleposition[58]);
     1516                adjacentPositions[1]=positionArray[59]; //graphVertex(possibleposition[59]);
     1517                adjacentPositions[2]=positionArray[63]; //graphVertex(possibleposition[63]);
     1518                          }
     1519            else if(findpos(actuelposition,possibleposition[60])){
     1520                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
     1521                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
     1522                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
     1523                          }
     1524            else if(findpos(actuelposition,possibleposition[61])){
     1525                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
     1526                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
     1527                adjacentPositions[2]=positionArray[60]; //graphVertex(possibleposition[60]);
     1528                          }
     1529            else if(findpos(actuelposition,possibleposition[62])){
     1530                adjacentPositions[0]=positionArray[16]; //graphVertex(possibleposition[16]);
     1531                adjacentPositions[1]=positionArray[60]; //graphVertex(possibleposition[60]);
     1532                       }
     1533            else if(findpos(actuelposition,possibleposition[63])){
     1534                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
     1535                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
     1536                       }
     1537            else if(findpos(actuelposition,possibleposition[64])){
     1538                adjacentPositions[0]=positionArray[57]; //graphVertex(possibleposition[57]);
     1539                adjacentPositions[1]=positionArray[63]; //graphVertex(possibleposition[63]);
     1540                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
     1541                          }
     1542            else if(findpos(actuelposition,possibleposition[65])){
     1543                adjacentPositions[0]=positionArray[56]; //graphVertex(possibleposition[56]);
     1544                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
     1545                       }
     1546            else if(findpos(actuelposition,possibleposition[66])){
     1547                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
     1548                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
     1549                       }
     1550    }
    12141551
    12151552
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h

    r12320 r12325  
    135135
    136136
     137
     138
     139
     140    void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
     141
     142    Vector3 frontPosition();
     143
    137144    };
    138145
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc

    r12324 r12325  
    4545
    4646        int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
    47         this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    48         /*std::cout<<this->pointInFrontOfPlayer<<endl;
    49         std::cout<<this->lastPlayerPassedPoint<<endl;*/
     47        this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
     48        std::cout<<this->pointInFrontOfPlayer<<endl;
     49        std::cout<<this->lastPlayerPassedPoint<<endl;
    5050       
    5151        //Stop, if target arrived
     
    9292            //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    9393           
    94             std::cout<<this->lastPlayerPassedPoint<<endl;
     94            //std::cout<<this->lastPlayerPassedPoint<<endl;
    9595
    96             std::cout<<this->pointInFrontOfPlayer<<endl;
     96            //std::cout<<this->pointInFrontOfPlayer<<endl;
    9797            nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint);
    9898
     
    114114        Vector3 nextTarget;
    115115
    116         if(playerPos==pointToAvoidP11){
     116        if(playerPos==pointToAvoidP11){ //SIGSEV if playerPos==pointToAvoidP11 otherwise
    117117            nextTarget = getShortestPath(pinkPosP, playerPos);
    118118        }
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc

    r12323 r12325  
    6464        }*/
    6565
     66            std::cout<<this->lastPlayerPassedPoint<<endl;
     67            std::cout<<this->pointInFrontOfPlayer<<endl;
    6668
    6769
     
    109111
    110112            int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
    111             this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
     113            this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    112114
    113115
     
    146148        Vector3 nextTarget;
    147149
     150        if(redPosP!=playerPos){
    148151           nextTarget = getShortestPath(redPosP, playerPos);
    149        
    150            setNewTargetGhost(nextTarget);
     152       setNewTargetGhost(nextTarget);
     153        }
    151154        }
    152155
    153 
    154 
    155     //save last checkpoint crossed by player
    156     /*
    157         void PacmanGelb::tick(float dt){ //last passed point of player
    158             for(int u=0; u < 67; u++){
    159             if(findpos(this->getPosition(), possibleposition[u])){
    160             this->lastPassedPoint=possibleposition[u];
    161                     }
    162                 }
    163         }
    164     */
    165 
    166156}
Note: See TracChangeset for help on using the changeset viewer.