Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12322)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12324)
@@ -17,4 +17,5 @@
         this->target_z=15;
         this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135);
+        this->pointInFrontOfPlayer=Vector3(0,0,0);
           
     }
@@ -38,9 +39,13 @@
 
         for(int u=0; u < 67; u++){//always check if player passed a point
-            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
-            this->lastPlayerPassedPoint=possibleposition[u];
-                    }
+            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){ 
+                    this->lastPlayerPassedPoint=possibleposition[u];        
+                }
             }
 
+        int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
+        this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
+        /*std::cout<<this->pointInFrontOfPlayer<<endl;
+        std::cout<<this->lastPlayerPassedPoint<<endl;*/
         
         //Stop, if target arrived
@@ -68,4 +73,13 @@
             this->ismoving=false;
         }
+        else if(this->pointInFrontOfPlayer==Vector3(0,0,0)){
+            std::cout<<"arheeuuuu"<<endl;
+
+            Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
+
+            setNewTargetGhost(getShortestPath(pinkPos, this->lastPlayerPassedPoint));
+
+
+        }
         //Check on which position the ghost has arrived and set new target
          else{
@@ -74,9 +88,9 @@
 
             Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
+
+            //int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
+            //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
             
             std::cout<<this->lastPlayerPassedPoint<<endl;
-
-            int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
-            this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
 
             std::cout<<this->pointInFrontOfPlayer<<endl;
@@ -84,53 +98,4 @@
 
 
-
-            /*if(findPos(player.getPos(), player.lastPassedPoint)){
-            	// if player is on a point, for simplicity go to it
-            Vector3 nextMove = getShortestPath(this->actuelposition, player.lastPassedPoint);
-            setNewTargetPink(nextMove);
-            }
-
-            else{ //if player is not on a point either go to next neighboor, or if no 
-            //neighboor in player direction available, go to last point passed by player.
-
-            int dir=findPlayerTravDir(player.lastPassedPoint, player.getPos());
-            //not in other sense!
-
-            Vector3[] neighboors;
-            findNeighboor(player.lastPassedPoint, neighboors);
-            //we need to create function that finds neighboors of player last point
-            //We can use and even should use the part of the tick random function
-            // that determines the neighboors. But array neighboor should be in form
-            // south-west-north-east respectively to array index.
-
-            for(int s=0; s < 4; s++){
-            	//find next neighboor between player and player.lastPassedPoint
-            	if((neighboors[s]!=NULL)&&(s==dir)){
-            		if(dir==0){
-            			Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
-            			setNewTargetPink(nextMove);
-            		}
-            		else if(dir==1){
-            			Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
-            			setNewTargetPink(nextMove);
-            		}
-            		else if(dir==2){
-            			Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
-            			setNewTargetPink(nextMove);
-            		}
-            		else{//last is default
-            			Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
-            			setNewTargetPink(nextMove);
-            				}
-            		}
-            	else{//if no further point after last player point possible
-            		//then simply go to this last point.
-            	Vector3 nextMove=getShortestPath(this->actuelposition, player.lastPassedPoint);
-            		setNewTargetPink(nextMove);
-            		}
-
-            	}
-
-            }*/
             lockmove=false;
 
@@ -149,5 +114,10 @@
         Vector3 nextTarget;
 
-       nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
+        if(playerPos==pointToAvoidP11){
+            nextTarget = getShortestPath(pinkPosP, playerPos);
+        }
+        else{
+        nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
+        }
     
        setNewTargetGhost(nextTarget);
