Changeset 12325 for code/branches/3DPacman_FS19/src
- Timestamp:
- Apr 28, 2019, 1:07:32 AM (6 years ago)
- 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 102 102 } 103 103 else{ 104 if(findpos(this->lastPlayerPassedPoint, Vector3(-215,10,-195))){ 104 105 Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195)); 105 106 this->setNewTargetGhost(nextMoveP); 107 } 108 else{ 109 Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195), this->lastPlayerPassedPoint); 110 this->setNewTargetGhost(nextMoveP); 111 } 106 112 } 107 113 … … 123 129 124 130 125 /*if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){126 //no idea if 50 is large enough127 128 //if near player, flee129 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 flee138 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 player143 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 player149 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 there162 fleeMode();163 }164 else{ // else go next to pacman165 166 if(absoluteDistance(this->pos, player.pos)<10){//no idea if 10 ok167 //if near player, flee away168 fleemode();169 }170 else{ //go to neighboor of player nearest to brown pacman171 172 //first find nearest neighboor point of player to brown pacman173 //we can maybe call getShortestPath recursively to do so174 175 player.pos.nearestneighboor=findPlayerNeighboorNearestToPacman(player.neighboors);176 //btw the array player.neighboor can be defined with a big list as we177 //already did several times for similar things178 179 Vector3 nextMove = getShortestPath(this->actuelposition, player.pos.nearestneighboor);180 setNewTargetBrown(nextMove);181 }182 183 }*/184 131 lockmove=false; //NEVER FORGET THIS ONE !!! 185 132 … … 204 151 205 152 206 void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){153 /*void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){ 207 154 //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint 208 155 … … 515 462 adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]); 516 463 } 517 } 464 }*/ 518 465 519 466 … … 521 468 } 522 469 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 0553 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 map560 561 Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change562 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 until568 we reach the corner569 }570 }*/571 572 573 /*Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){574 //find ,nearest to brown, player neighboor575 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 above610 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 37 37 bool isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]); 38 38 39 void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);39 //void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]); 40 40 41 41 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
r12324 r12325 784 784 } 785 785 } 786 787 788 /*Vector3 difference = diffVector(playerPosBefore, playerPos);789 if((difference.z < 0)&&(difference.z>difference.x)){ //move south790 791 return 0;792 }793 else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north794 795 return 2;796 }797 else if((difference.x < 0)&&(difference.x > difference.z )){//move west798 799 return 1;800 }801 802 else if((difference.x>0)&&(difference.x>difference.z)){ //move east803 return 3;804 805 }806 807 else { //default move west Can still be changed808 809 return 1;810 }*/811 786 812 787 } … … 829 804 listOfNeighboors[2]=possibleposition[17]; //north 830 805 listOfNeighboors[3]=possibleposition[1]; //east 831 return listOfNeighboors[indexForSWNE]; 806 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 832 807 } 833 808 else if(findpos(pacLasVisPos,possibleposition[1])){ 834 809 listOfNeighboors[1]=possibleposition[0]; // west neighbor 835 810 listOfNeighboors[2]=possibleposition[2]; //north 836 return listOfNeighboors[indexForSWNE]; 811 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 837 812 } 838 813 else if(findpos(pacLasVisPos,possibleposition[2])){ 839 814 listOfNeighboors[0]=possibleposition[1]; //south 840 815 listOfNeighboors[1]=possibleposition[3]; //west 841 return listOfNeighboors[indexForSWNE]; 816 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 842 817 } 843 818 else if(findpos(pacLasVisPos,possibleposition[3])){ … … 845 820 listOfNeighboors[2]=possibleposition[5]; //north 846 821 listOfNeighboors[3]=possibleposition[2]; //east 847 return listOfNeighboors[indexForSWNE]; 822 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 848 823 } 849 824 else if(findpos(pacLasVisPos,possibleposition[4])){ 850 825 listOfNeighboors[2]=possibleposition[6]; //north 851 826 listOfNeighboors[3]=possibleposition[3]; //east 852 return listOfNeighboors[indexForSWNE]; 827 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 853 828 } 854 829 else if(findpos(pacLasVisPos,possibleposition[5])){ 855 830 listOfNeighboors[0]=possibleposition[3]; //south 856 831 listOfNeighboors[3]=possibleposition[7]; //east 857 return listOfNeighboors[indexForSWNE]; 832 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 858 833 } 859 834 else if(findpos(pacLasVisPos,possibleposition[6])){ … … 861 836 listOfNeighboors[1]=possibleposition[26]; //west 862 837 listOfNeighboors[2]=possibleposition[9]; //north 863 return listOfNeighboors[indexForSWNE]; 838 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 864 839 } 865 840 else if(findpos(pacLasVisPos,possibleposition[7])){ 866 841 listOfNeighboors[1]=possibleposition[5]; //west 867 842 listOfNeighboors[2]=possibleposition[8]; //north 868 return listOfNeighboors[indexForSWNE]; 843 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 869 844 } 870 845 else if(findpos(pacLasVisPos,possibleposition[8])){ 871 846 listOfNeighboors[0]=possibleposition[7]; //south 872 847 listOfNeighboors[1]=possibleposition[9]; //west 873 return listOfNeighboors[indexForSWNE]; 848 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 874 849 } 875 850 else if(findpos(pacLasVisPos,possibleposition[9])){ … … 878 853 listOfNeighboors[2]=possibleposition[10]; //north 879 854 listOfNeighboors[3]=possibleposition[8]; //east 880 return listOfNeighboors[indexForSWNE]; 855 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 881 856 } 882 857 else if(findpos(pacLasVisPos,possibleposition[10])){ … … 889 864 listOfNeighboors[1]=possibleposition[45]; //west 890 865 listOfNeighboors[2]=possibleposition[11]; //north 891 return listOfNeighboors[indexForSWNE]; 866 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 892 867 } 893 868 else if(findpos(pacLasVisPos,possibleposition[11])){ … … 895 870 listOfNeighboors[2]=possibleposition[13]; //north 896 871 listOfNeighboors[3]=possibleposition[12]; //east 897 return listOfNeighboors[indexForSWNE]; 872 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 898 873 } 899 874 else if(findpos(pacLasVisPos,possibleposition[12])){ 900 875 listOfNeighboors[1]=possibleposition[11]; //west 901 876 listOfNeighboors[2]=possibleposition[14]; //north 902 return listOfNeighboors[indexForSWNE]; 877 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 903 878 } 904 879 else if(findpos(pacLasVisPos,possibleposition[13])){ … … 907 882 listOfNeighboors[2]=possibleposition[16]; //north 908 883 listOfNeighboors[3]=possibleposition[14]; //east 909 return listOfNeighboors[indexForSWNE]; 884 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 910 885 } 911 886 else if(findpos(pacLasVisPos,possibleposition[14])){ … … 913 888 listOfNeighboors[1]=possibleposition[13]; //west 914 889 listOfNeighboors[2]=possibleposition[15]; //north 915 return listOfNeighboors[indexForSWNE]; 890 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 916 891 } 917 892 else if(findpos(pacLasVisPos,possibleposition[15])){ 918 893 listOfNeighboors[0]=possibleposition[14]; //south 919 894 listOfNeighboors[1]=possibleposition[16]; //west 920 return listOfNeighboors[indexForSWNE]; 895 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 921 896 } 922 897 else if(findpos(pacLasVisPos,possibleposition[16])){ … … 924 899 listOfNeighboors[1]=possibleposition[62]; //west 925 900 listOfNeighboors[2]=possibleposition[15]; //north 926 return listOfNeighboors[indexForSWNE]; 901 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 927 902 } 928 903 else if(findpos(pacLasVisPos,possibleposition[17])){ 929 904 listOfNeighboors[0]=possibleposition[0]; //south 930 905 listOfNeighboors[3]=possibleposition[25]; //east 931 return listOfNeighboors[indexForSWNE]; 906 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 932 907 } 933 908 else if(findpos(pacLasVisPos,possibleposition[18])){ 934 909 listOfNeighboors[0]=possibleposition[19]; //south 935 910 listOfNeighboors[1]=possibleposition[24]; //west 936 return listOfNeighboors[indexForSWNE]; 911 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 937 912 } 938 913 else if(findpos(pacLasVisPos,possibleposition[19])){ … … 940 915 listOfNeighboors[2]=possibleposition[18]; //north 941 916 listOfNeighboors[3]=possibleposition[0]; //east 942 return listOfNeighboors[indexForSWNE]; 917 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 943 918 } 944 919 else if(findpos(pacLasVisPos,possibleposition[20])){ 945 920 listOfNeighboors[2]=possibleposition[21]; //north 946 921 listOfNeighboors[3]=possibleposition[19]; //east 947 return listOfNeighboors[indexForSWNE]; 922 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 948 923 } 949 924 else if(findpos(pacLasVisPos,possibleposition[21])){ 950 925 listOfNeighboors[0]=possibleposition[20]; //south 951 926 listOfNeighboors[3]=possibleposition[22]; //east 952 return listOfNeighboors[indexForSWNE]; 927 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 953 928 } 954 929 else if(findpos(pacLasVisPos,possibleposition[22])){ … … 956 931 listOfNeighboors[2]=possibleposition[31]; //north 957 932 listOfNeighboors[3]=possibleposition[23]; //east 958 return listOfNeighboors[indexForSWNE]; 933 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 959 934 } 960 935 else if(findpos(pacLasVisPos,possibleposition[23])){ 961 936 listOfNeighboors[1]=possibleposition[22]; //west 962 937 listOfNeighboors[2]=possibleposition[30]; //north 963 return listOfNeighboors[indexForSWNE]; 938 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 964 939 } 965 940 else if(findpos(pacLasVisPos,possibleposition[24])){ 966 941 listOfNeighboors[2]=possibleposition[29]; //north 967 942 listOfNeighboors[3]=possibleposition[18]; //east 968 return listOfNeighboors[indexForSWNE]; 943 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 969 944 } 970 945 else if(findpos(pacLasVisPos,possibleposition[25])){ 971 946 listOfNeighboors[1]=possibleposition[17]; //west 972 947 listOfNeighboors[2]=possibleposition[26]; //north 973 return listOfNeighboors[indexForSWNE]; 948 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 974 949 } 975 950 else if(findpos(pacLasVisPos,possibleposition[26])){ … … 977 952 listOfNeighboors[1]=possibleposition[27]; //west 978 953 listOfNeighboors[3]=possibleposition[6]; //east 979 return listOfNeighboors[indexForSWNE]; 954 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 980 955 } 981 956 else if(findpos(pacLasVisPos,possibleposition[27])){ … … 983 958 listOfNeighboors[2]=possibleposition[37]; //north 984 959 listOfNeighboors[3]=possibleposition[26]; //east 985 return listOfNeighboors[indexForSWNE]; 960 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 986 961 } 987 962 else if(findpos(pacLasVisPos,possibleposition[28])){ … … 989 964 listOfNeighboors[2]=possibleposition[36]; //north 990 965 listOfNeighboors[3]=possibleposition[27]; //east 991 return listOfNeighboors[indexForSWNE]; 966 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 992 967 } 993 968 else if(findpos(pacLasVisPos,possibleposition[29])){ … … 995 970 listOfNeighboors[1]=possibleposition[30]; //west 996 971 listOfNeighboors[3]=possibleposition[28]; //east 997 return listOfNeighboors[indexForSWNE]; 972 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 998 973 } 999 974 else if(findpos(pacLasVisPos,possibleposition[30])){ … … 1001 976 listOfNeighboors[2]=possibleposition[34]; //north 1002 977 listOfNeighboors[3]=possibleposition[29]; //east 1003 return listOfNeighboors[indexForSWNE]; 978 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1004 979 } 1005 980 else if(findpos(pacLasVisPos,possibleposition[31])){ 1006 981 listOfNeighboors[0]=possibleposition[22]; //south 1007 982 listOfNeighboors[1]=possibleposition[32]; //west 1008 return listOfNeighboors[indexForSWNE]; 983 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1009 984 } 1010 985 else if(findpos(pacLasVisPos,possibleposition[32])){ 1011 986 listOfNeighboors[2]=possibleposition[33]; //north 1012 987 listOfNeighboors[3]=possibleposition[31]; //east 1013 return listOfNeighboors[indexForSWNE]; 988 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1014 989 } 1015 990 else if(findpos(pacLasVisPos,possibleposition[33])){ 1016 991 listOfNeighboors[0]=possibleposition[32]; //south 1017 992 listOfNeighboors[3]=possibleposition[34]; //east 1018 return listOfNeighboors[indexForSWNE]; 993 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1019 994 } 1020 995 else if(findpos(pacLasVisPos,possibleposition[34])){ … … 1023 998 listOfNeighboors[2]=possibleposition[92]; //north 1024 999 listOfNeighboors[3]=possibleposition[35]; //east 1025 return listOfNeighboors[indexForSWNE]; 1000 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1026 1001 } 1027 1002 else if(findpos(pacLasVisPos,possibleposition[35])){ … … 1029 1004 listOfNeighboors[2]=possibleposition[91]; //north 1030 1005 listOfNeighboors[3]=possibleposition[36]; //east 1031 return listOfNeighboors[indexForSWNE]; 1006 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1032 1007 } 1033 1008 else if(findpos(pacLasVisPos,possibleposition[36])){ 1034 1009 listOfNeighboors[0]=possibleposition[28]; //south 1035 1010 listOfNeighboors[1]=possibleposition[35]; //west 1036 return listOfNeighboors[indexForSWNE]; 1011 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1037 1012 } 1038 1013 else if(findpos(pacLasVisPos,possibleposition[37])){ 1039 1014 listOfNeighboors[0]=possibleposition[27]; //south 1040 1015 listOfNeighboors[3]=possibleposition[38]; //east 1041 return listOfNeighboors[indexForSWNE]; 1016 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1042 1017 } 1043 1018 else if(findpos(pacLasVisPos,possibleposition[38])){ … … 1045 1020 listOfNeighboors[2]=possibleposition[39]; //north 1046 1021 listOfNeighboors[3]=possibleposition[9]; //east 1047 return listOfNeighboors[indexForSWNE]; 1022 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1048 1023 } 1049 1024 else if(findpos(pacLasVisPos,possibleposition[39])){ … … 1051 1026 listOfNeighboors[1]=possibleposition[40]; //west 1052 1027 listOfNeighboors[2]=possibleposition[45]; //north 1053 return listOfNeighboors[indexForSWNE]; 1028 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1054 1029 } 1055 1030 else if(findpos(pacLasVisPos,possibleposition[40])){ … … 1057 1032 //Not return in center 1058 1033 listOfNeighboors[3]=possibleposition[39]; //east 1059 return listOfNeighboors[indexForSWNE]; 1034 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1060 1035 } 1061 1036 else if(findpos(pacLasVisPos,possibleposition[41])){ … … 1063 1038 listOfNeighboors[2]=possibleposition[43]; //north 1064 1039 listOfNeighboors[3]=possibleposition[40]; //east 1065 return listOfNeighboors[indexForSWNE]; 1040 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1066 1041 } 1067 1042 else if(findpos(pacLasVisPos,possibleposition[42])){ … … 1074 1049 listOfNeighboors[2]=possibleposition[59]; //north 1075 1050 listOfNeighboors[3]=possibleposition[43]; //east 1076 return listOfNeighboors[indexForSWNE]; 1051 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1077 1052 } 1078 1053 else if(findpos(pacLasVisPos,possibleposition[43])){ … … 1080 1055 listOfNeighboors[1]=possibleposition[42]; //west 1081 1056 listOfNeighboors[2]=possibleposition[46]; //north 1082 return listOfNeighboors[indexForSWNE]; 1057 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1083 1058 } 1084 1059 else if(findpos(pacLasVisPos,possibleposition[44])){ 1085 1060 listOfNeighboors[0]=possibleposition[40]; //south 1086 1061 listOfNeighboors[2]=possibleposition[66]; //north 1087 return listOfNeighboors[indexForSWNE]; 1062 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1088 1063 } 1089 1064 else if(findpos(pacLasVisPos,possibleposition[45])){ … … 1091 1066 listOfNeighboors[2]=possibleposition[49]; //north 1092 1067 listOfNeighboors[3]=possibleposition[10]; //east 1093 return listOfNeighboors[indexForSWNE]; 1068 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1094 1069 } 1095 1070 else if(findpos(pacLasVisPos,possibleposition[46])){ 1096 1071 listOfNeighboors[0]=possibleposition[43]; //south 1097 1072 listOfNeighboors[3]=possibleposition[47]; //east 1098 return listOfNeighboors[indexForSWNE]; 1073 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1099 1074 } 1100 1075 else if(findpos(pacLasVisPos,possibleposition[47])){ … … 1102 1077 listOfNeighboors[2]=possibleposition[52]; //north 1103 1078 listOfNeighboors[3]=possibleposition[66]; //east 1104 return listOfNeighboors[indexForSWNE]; 1079 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1105 1080 } 1106 1081 else if(findpos(pacLasVisPos,possibleposition[48])){ … … 1108 1083 listOfNeighboors[2]=possibleposition[51]; //north 1109 1084 listOfNeighboors[3]=possibleposition[49]; //east 1110 return listOfNeighboors[indexForSWNE]; 1085 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1111 1086 } 1112 1087 else if(findpos(pacLasVisPos,possibleposition[49])){ 1113 1088 listOfNeighboors[0]=possibleposition[45]; //south 1114 1089 listOfNeighboors[1]=possibleposition[48]; //west 1115 return listOfNeighboors[indexForSWNE]; 1090 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1116 1091 } 1117 1092 else if(findpos(pacLasVisPos,possibleposition[50])){ 1118 1093 listOfNeighboors[1]=possibleposition[51]; //west 1119 1094 listOfNeighboors[2]=possibleposition[61]; //north 1120 return listOfNeighboors[indexForSWNE]; 1095 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1121 1096 } 1122 1097 else if(findpos(pacLasVisPos,possibleposition[51])){ 1123 1098 listOfNeighboors[0]=possibleposition[48]; //south 1124 1099 listOfNeighboors[3]=possibleposition[50]; //east 1125 return listOfNeighboors[indexForSWNE]; 1100 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1126 1101 } 1127 1102 else if(findpos(pacLasVisPos,possibleposition[52])){ 1128 1103 listOfNeighboors[0]=possibleposition[47]; //south 1129 1104 listOfNeighboors[1]=possibleposition[53]; //west 1130 return listOfNeighboors[indexForSWNE]; 1105 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1131 1106 } 1132 1107 else if(findpos(pacLasVisPos,possibleposition[53])){ 1133 1108 listOfNeighboors[2]=possibleposition[58]; //north 1134 1109 listOfNeighboors[3]=possibleposition[52]; //east 1135 return listOfNeighboors[indexForSWNE]; 1110 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1136 1111 } 1137 1112 else if(findpos(pacLasVisPos,possibleposition[54])){ … … 1139 1114 listOfNeighboors[1]=possibleposition[55]; //west 1140 1115 listOfNeighboors[2]=possibleposition[57]; //north 1141 return listOfNeighboors[indexForSWNE]; 1116 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1142 1117 } 1143 1118 else if(findpos(pacLasVisPos,possibleposition[55])){ 1144 1119 listOfNeighboors[2]=possibleposition[56]; //north 1145 1120 listOfNeighboors[3]=possibleposition[54]; //east 1146 return listOfNeighboors[indexForSWNE]; 1121 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1147 1122 } 1148 1123 else if(findpos(pacLasVisPos,possibleposition[56])){ … … 1150 1125 listOfNeighboors[2]=possibleposition[65]; //north 1151 1126 listOfNeighboors[3]=possibleposition[57]; //east 1152 return listOfNeighboors[indexForSWNE]; 1127 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1153 1128 } 1154 1129 else if(findpos(pacLasVisPos,possibleposition[57])){ … … 1157 1132 listOfNeighboors[2]=possibleposition[64]; //north 1158 1133 listOfNeighboors[3]=possibleposition[58]; //east 1159 return listOfNeighboors[indexForSWNE]; 1134 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1160 1135 } 1161 1136 else if(findpos(pacLasVisPos,possibleposition[58])){ … … 1163 1138 listOfNeighboors[1]=possibleposition[57]; //west 1164 1139 listOfNeighboors[3]=possibleposition[59]; //east 1165 return listOfNeighboors[indexForSWNE]; 1140 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1166 1141 } 1167 1142 else if(findpos(pacLasVisPos,possibleposition[59])){ … … 1169 1144 listOfNeighboors[2]=possibleposition[63]; //north 1170 1145 listOfNeighboors[3]=possibleposition[60]; //east 1171 return listOfNeighboors[indexForSWNE]; 1146 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1172 1147 } 1173 1148 else if(findpos(pacLasVisPos,possibleposition[60])){ … … 1175 1150 listOfNeighboors[2]=possibleposition[62]; //north 1176 1151 listOfNeighboors[3]=possibleposition[61]; //east 1177 return listOfNeighboors[indexForSWNE]; 1152 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1178 1153 } 1179 1154 else if(findpos(pacLasVisPos,possibleposition[61])){ … … 1181 1156 listOfNeighboors[1]=possibleposition[60]; //west 1182 1157 listOfNeighboors[3]=possibleposition[13]; //east 1183 return listOfNeighboors[indexForSWNE]; 1158 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1184 1159 } 1185 1160 else if(findpos(pacLasVisPos,possibleposition[62])){ 1186 1161 listOfNeighboors[0]=possibleposition[60]; //south 1187 1162 listOfNeighboors[3]=possibleposition[16]; //east 1188 return listOfNeighboors[indexForSWNE]; 1163 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1189 1164 } 1190 1165 else if(findpos(pacLasVisPos,possibleposition[63])){ 1191 1166 listOfNeighboors[0]=possibleposition[59]; //south 1192 1167 listOfNeighboors[1]=possibleposition[64]; //west 1193 return listOfNeighboors[indexForSWNE]; 1168 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1194 1169 } 1195 1170 else if(findpos(pacLasVisPos,possibleposition[64])){ … … 1197 1172 listOfNeighboors[1]=possibleposition[65]; //west 1198 1173 listOfNeighboors[3]=possibleposition[63]; //east 1199 return listOfNeighboors[indexForSWNE]; 1174 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1200 1175 } 1201 1176 else if(findpos(pacLasVisPos,possibleposition[65])){ 1202 1177 listOfNeighboors[0]=possibleposition[56]; //south 1203 1178 listOfNeighboors[3]=possibleposition[64]; //east 1204 return listOfNeighboors[indexForSWNE]; 1179 return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z); 1205 1180 } 1206 1181 else if(findpos(pacLasVisPos,possibleposition[66])){ … … 1208 1183 listOfNeighboors[1]=possibleposition[47]; //west 1209 1184 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 } 1214 1551 1215 1552 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
r12320 r12325 135 135 136 136 137 138 139 140 void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]); 141 142 Vector3 frontPosition(); 143 137 144 }; 138 145 -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
r12324 r12325 45 45 46 46 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; 50 50 51 51 //Stop, if target arrived … … 92 92 //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 93 93 94 std::cout<<this->lastPlayerPassedPoint<<endl;94 //std::cout<<this->lastPlayerPassedPoint<<endl; 95 95 96 std::cout<<this->pointInFrontOfPlayer<<endl;96 //std::cout<<this->pointInFrontOfPlayer<<endl; 97 97 nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint); 98 98 … … 114 114 Vector3 nextTarget; 115 115 116 if(playerPos==pointToAvoidP11){ 116 if(playerPos==pointToAvoidP11){ //SIGSEV if playerPos==pointToAvoidP11 otherwise 117 117 nextTarget = getShortestPath(pinkPosP, playerPos); 118 118 } -
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
r12323 r12325 64 64 }*/ 65 65 66 std::cout<<this->lastPlayerPassedPoint<<endl; 67 std::cout<<this->pointInFrontOfPlayer<<endl; 66 68 67 69 … … 109 111 110 112 int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos()); 111 this->pointInFrontOfPlayer= getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);113 this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV); 112 114 113 115 … … 146 148 Vector3 nextTarget; 147 149 150 if(redPosP!=playerPos){ 148 151 nextTarget = getShortestPath(redPosP, playerPos); 149 150 setNewTargetGhost(nextTarget); 152 setNewTargetGhost(nextTarget); 153 } 151 154 } 152 155 153 154 155 //save last checkpoint crossed by player156 /*157 void PacmanGelb::tick(float dt){ //last passed point of player158 for(int u=0; u < 67; u++){159 if(findpos(this->getPosition(), possibleposition[u])){160 this->lastPassedPoint=possibleposition[u];161 }162 }163 }164 */165 166 156 }
Note: See TracChangeset
for help on using the changeset viewer.