Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2019, 4:49:54 PM (5 years ago)
Author:
peterf
Message:

PacmanPink seems to work most of the time now

File:
1 edited

Legend:

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

    r12322 r12324  
    1717        this->target_z=15;
    1818        this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135);
     19        this->pointInFrontOfPlayer=Vector3(0,0,0);
    1920         
    2021    }
     
    3839
    3940        for(int u=0; u < 67; u++){//always check if player passed a point
    40             if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
    41             this->lastPlayerPassedPoint=possibleposition[u];
    42                     }
     41            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 
     42                    this->lastPlayerPassedPoint=possibleposition[u];       
     43                }
    4344            }
    4445
     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;*/
    4550       
    4651        //Stop, if target arrived
     
    6873            this->ismoving=false;
    6974        }
     75        else if(this->pointInFrontOfPlayer==Vector3(0,0,0)){
     76            std::cout<<"arheeuuuu"<<endl;
     77
     78            Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
     79
     80            setNewTargetGhost(getShortestPath(pinkPos, this->lastPlayerPassedPoint));
     81
     82
     83        }
    7084        //Check on which position the ghost has arrived and set new target
    7185         else{
     
    7488
    7589            Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
     90
     91            //int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
     92            //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    7693           
    7794            std::cout<<this->lastPlayerPassedPoint<<endl;
    78 
    79             int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
    80             this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    8195
    8296            std::cout<<this->pointInFrontOfPlayer<<endl;
     
    8498
    8599
    86 
    87             /*if(findPos(player.getPos(), player.lastPassedPoint)){
    88                 // if player is on a point, for simplicity go to it
    89             Vector3 nextMove = getShortestPath(this->actuelposition, player.lastPassedPoint);
    90             setNewTargetPink(nextMove);
    91             }
    92 
    93             else{ //if player is not on a point either go to next neighboor, or if no
    94             //neighboor in player direction available, go to last point passed by player.
    95 
    96             int dir=findPlayerTravDir(player.lastPassedPoint, player.getPos());
    97             //not in other sense!
    98 
    99             Vector3[] neighboors;
    100             findNeighboor(player.lastPassedPoint, neighboors);
    101             //we need to create function that finds neighboors of player last point
    102             //We can use and even should use the part of the tick random function
    103             // that determines the neighboors. But array neighboor should be in form
    104             // south-west-north-east respectively to array index.
    105 
    106             for(int s=0; s < 4; s++){
    107                 //find next neighboor between player and player.lastPassedPoint
    108                 if((neighboors[s]!=NULL)&&(s==dir)){
    109                         if(dir==0){
    110                                 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
    111                                 setNewTargetPink(nextMove);
    112                         }
    113                         else if(dir==1){
    114                                 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
    115                                 setNewTargetPink(nextMove);
    116                         }
    117                         else if(dir==2){
    118                                 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
    119                                 setNewTargetPink(nextMove);
    120                         }
    121                         else{//last is default
    122                                 Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
    123                                 setNewTargetPink(nextMove);
    124                                         }
    125                         }
    126                 else{//if no further point after last player point possible
    127                         //then simply go to this last point.
    128                 Vector3 nextMove=getShortestPath(this->actuelposition, player.lastPassedPoint);
    129                         setNewTargetPink(nextMove);
    130                         }
    131 
    132                 }
    133 
    134             }*/
    135100            lockmove=false;
    136101
     
    149114        Vector3 nextTarget;
    150115
    151        nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
     116        if(playerPos==pointToAvoidP11){
     117            nextTarget = getShortestPath(pinkPosP, playerPos);
     118        }
     119        else{
     120        nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
     121        }
    152122   
    153123       setNewTargetGhost(nextTarget);
Note: See TracChangeset for help on using the changeset viewer.