- Timestamp:
- Apr 28, 2019, 1:07:32 AM (5 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.