Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12317)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12319)
@@ -13,4 +13,8 @@
 
         RegisterObject(PacmanPink);
+
+        this->target_x=0;
+        this->target_z=15;
+        this->lastPlayerPassedPoint=Vector3(70,10,-135);
           
     }
@@ -31,4 +35,12 @@
 
         this->actuelposition = this->getPosition();
+
+
+        for(int u=0; u < 67; u++){//always check if player passed a point
+            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
+            this->lastPlayerPassedPoint=possibleposition[u];
+                    }
+            }
+
         
         //Stop, if target arrived
@@ -53,5 +65,15 @@
             lockmove = true;
 
-            if(findPos(player.getPos(), player.lastPassedPoint)){
+            Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
+            
+            int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
+            this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
+
+
+            nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint);
+
+
+
+            /*if(findPos(player.getPos(), player.lastPassedPoint)){
             	// if player is on a point, for simplicity go to it
             Vector3 nextMove = getShortestPath(this->actuelposition, player.lastPassedPoint);
@@ -100,5 +122,6 @@
             	}
 
-            }
+            }*/
+            lockmove=false;
 
         }
@@ -106,432 +129,20 @@
 
 
-	/*
-	Vector3 diffVector (Vector3 start, Vector3 goal){
 
-		Vector3 result;
-		result.x=goal.x-start.x;
-		result.z=goal.z-start.z;
-		return result;
+
 	}
 
-	int findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){
-		//return 0 for south, 1 for west, 2 for north, 3 for east
-
-		Vector3 difference = diffVector(playerPosBefore, playerPos);
 
 
-		if((difference.z < 0)&&(difference.z>difference.x)){ //move south
+    void PacmanPink::nextMove( Vector3 pinkPosP, Vector3 playerPos, Vector3 pointToAvoidP11){
+    
+        Vector3 nextTarget;
 
-			return 0;
-		}
-		else if((difference.x < 0)&&(difference.x > difference.z )){//move west
+       nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
+    
+       setNewTargetGhost(nextTarget);
+    }
 
-			return 1;
-		}
-
-		else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north
-
-			return 2;
-		}
-
-		else if((difference.x>0)&&(difference.x>difference.z)){ //move east
-			return 3;
-
-		}
-
-		else { //default move west 
-
-		return 1;
-		}
-		
-
-	Vector3 getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){
-		//return the Vector3 point that Pinky should target to
-		//be in front of pacman
-
-		Vector3 listOfNeighboors[4];
-		//first element is south, 2nd west, 3d north, 4th east
-        
-
-
-        	if(findpos(pacLasVisPos,possibleposition[0])){
-        		//no south neighbor 
-        		listOfNeighboors[1]=possibleposition[19]; // west neighbor
-        		listOfNeighboors[2]=possibleposition[17]; //north
-        		listOfNeighboors[3]=possibleposition[1]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[1])){
-                listOfNeighboors[1]=possibleposition[0]; // west neighbor
-        		listOfNeighboors[2]=possibleposition[2]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[2])){
-            	listOfNeighboors[0]=possibleposition[1];  //south
-                listOfNeighboors[1]=possibleposition[3]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[3])){
-                listOfNeighboors[1]=possibleposition[4]; //west
-        		listOfNeighboors[2]=possibleposition[5]; //north
-        		listOfNeighboors[3]=possibleposition[2]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[4])){
-        		listOfNeighboors[2]=possibleposition[6]; //north
-        		listOfNeighboors[3]=possibleposition[3]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[5])){
-                listOfNeighboors[0]=possibleposition[3]; //south
-        		listOfNeighboors[3]=possibleposition[7]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[6])){
-                listOfNeighboors[0]=possibleposition[4]; //south
-                listOfNeighboors[1]=possibleposition[26]; //west
-        		listOfNeighboors[2]=possibleposition[9]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[7])){
-                listOfNeighboors[1]=possibleposition[5]; //west
-        		listOfNeighboors[2]=possibleposition[8]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[8])){
-                listOfNeighboors[0]=possibleposition[7]; //south
-                listOfNeighboors[1]=possibleposition[9]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[9])){
-                listOfNeighboors[0]=possibleposition[6]; //south
-                listOfNeighboors[1]=possibleposition[38]; //west
-        		listOfNeighboors[2]=possibleposition[10]; //north
-        		listOfNeighboors[3]=possibleposition[8]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[10])){
-                listOfNeighboors[0]=possibleposition[9]; //south
-                listOfNeighboors[1]=possibleposition[45]; //west
-        		listOfNeighboors[2]=possibleposition[11]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[11])){
-                listOfNeighboors[0]=possibleposition[10]; //south
-        		listOfNeighboors[2]=possibleposition[13]; //north
-        		listOfNeighboors[3]=possibleposition[12]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[12])){
-                listOfNeighboors[1]=possibleposition[11]; //west
-        		listOfNeighboors[2]=possibleposition[14]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[13])){
-                listOfNeighboors[0]=possibleposition[11]; //south
-                listOfNeighboors[1]=possibleposition[61]; //west
-        		listOfNeighboors[2]=possibleposition[16]; //north
-        		listOfNeighboors[3]=possibleposition[14]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[14])){
-                listOfNeighboors[0]=possibleposition[12]; //south
-                listOfNeighboors[1]=possibleposition[13]; //west
-        		listOfNeighboors[2]=possibleposition[15]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[15])){
-                listOfNeighboors[0]=possibleposition[14]; //south
-                listOfNeighboors[1]=possibleposition[16]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[16])){
-                listOfNeighboors[0]=possibleposition[13]; //south
-                listOfNeighboors[1]=possibleposition[62]; //west
-        		listOfNeighboors[2]=possibleposition[15]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[17])){
-                listOfNeighboors[0]=possibleposition[0]; //south
-        		listOfNeighboors[3]=possibleposition[25]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[18])){
-                listOfNeighboors[0]=possibleposition[19]; //south
-                listOfNeighboors[1]=possibleposition[24]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[19])){
-                listOfNeighboors[1]=possibleposition[20]; //west
-        		listOfNeighboors[2]=possibleposition[18]; //north
-        		listOfNeighboors[3]=possibleposition[0]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[20])){
-        		listOfNeighboors[2]=possibleposition[21]; //north
-        		listOfNeighboors[3]=possibleposition[19]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[21])){
-                listOfNeighboors[0]=possibleposition[20]; //south
-        		listOfNeighboors[3]=possibleposition[22]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[22])){
-                listOfNeighboors[1]=possibleposition[21]; //west
-        		listOfNeighboors[2]=possibleposition[31]; //north
-        		listOfNeighboors[3]=possibleposition[23]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[23])){
-                listOfNeighboors[1]=possibleposition[22]; //west
-        		listOfNeighboors[2]=possibleposition[30]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[24])){
-        		listOfNeighboors[2]=possibleposition[29]; //north
-        		listOfNeighboors[3]=possibleposition[18]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[25])){
-                listOfNeighboors[1]=possibleposition[17]; //west
-        		listOfNeighboors[2]=possibleposition[26]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[26])){
-                listOfNeighboors[0]=possibleposition[25]; //south
-                listOfNeighboors[1]=possibleposition[27]; //west
-        		listOfNeighboors[3]=possibleposition[6]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[27])){
-                listOfNeighboors[1]=possibleposition[28]; //west
-        		listOfNeighboors[2]=possibleposition[37]; //north
-        		listOfNeighboors[3]=possibleposition[26]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[28])){
-                listOfNeighboors[1]=possibleposition[29]; //west
-        		listOfNeighboors[2]=possibleposition[36]; //north
-        		listOfNeighboors[3]=possibleposition[27]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[29])){
-                listOfNeighboors[0]=possibleposition[24]; //south
-                listOfNeighboors[1]=possibleposition[30]; //west
-        		listOfNeighboors[3]=possibleposition[28]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[30])){
-                listOfNeighboors[0]=possibleposition[23]; //south
-        		listOfNeighboors[2]=possibleposition[34]; //north
-        		listOfNeighboors[3]=possibleposition[29]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[31])){
-                listOfNeighboors[0]=possibleposition[22]; //south
-                listOfNeighboors[1]=possibleposition[32]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[32])){
-        		listOfNeighboors[2]=possibleposition[33]; //north
-        		listOfNeighboors[3]=possibleposition[31]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[33])){
-                listOfNeighboors[0]=possibleposition[32]; //south
-        		listOfNeighboors[3]=possibleposition[34]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[34])){
-                listOfNeighboors[0]=possibleposition[30]; //south
-                listOfNeighboors[1]=possibleposition[33]; //west
-        		listOfNeighboors[2]=possibleposition[92]; //north
-        		listOfNeighboors[3]=possibleposition[35]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[35])){
-                listOfNeighboors[1]=possibleposition[34]; //west
-        		listOfNeighboors[2]=possibleposition[91]; //north
-        		listOfNeighboors[3]=possibleposition[36]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[36])){
-                listOfNeighboors[0]=possibleposition[28]; //south
-                listOfNeighboors[1]=possibleposition[35]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[37])){
-                listOfNeighboors[0]=possibleposition[27]; //south
-        		listOfNeighboors[3]=possibleposition[38]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[38])){
-                listOfNeighboors[1]=possibleposition[37]; //west
-        		listOfNeighboors[2]=possibleposition[39]; //north
-        		listOfNeighboors[3]=possibleposition[9]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[39])){
-                listOfNeighboors[0]=possibleposition[38]; //south
-                listOfNeighboors[1]=possibleposition[40]; //west
-        		listOfNeighboors[2]=possibleposition[45]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[40])){
-                listOfNeighboors[1]=possibleposition[41]; //west
-        		//Not return in center
-        		listOfNeighboors[3]=possibleposition[39]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[41])){
-                listOfNeighboors[0]=possibleposition[35]; //south
-        		listOfNeighboors[2]=possibleposition[43]; //north
-        		listOfNeighboors[3]=possibleposition[40]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[42])){
-                listOfNeighboors[0]=possibleposition[39]; //south
-        		listOfNeighboors[2]=possibleposition[59]; //north
-        		listOfNeighboors[3]=possibleposition[43]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[43])){
-                listOfNeighboors[0]=possibleposition[41]; //south
-                listOfNeighboors[1]=possibleposition[42]; //west
-        		listOfNeighboors[2]=possibleposition[46]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[44])){
-                listOfNeighboors[0]=possibleposition[40]; //south
-        		listOfNeighboors[2]=possibleposition[66]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[45])){
-                listOfNeighboors[0]=possibleposition[39]; //south
-        		listOfNeighboors[2]=possibleposition[49]; //north
-        		listOfNeighboors[3]=possibleposition[10]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[46])){
-                listOfNeighboors[0]=possibleposition[43]; //south
-        		listOfNeighboors[3]=possibleposition[47]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[47])){
-                listOfNeighboors[1]=possibleposition[46]; //west
-        		listOfNeighboors[2]=possibleposition[52]; //north
-        		listOfNeighboors[3]=possibleposition[66]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[48])){
-                listOfNeighboors[1]=possibleposition[66]; //west
-        		listOfNeighboors[2]=possibleposition[51]; //north
-        		listOfNeighboors[3]=possibleposition[49]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[49])){
-                listOfNeighboors[0]=possibleposition[45]; //south
-                listOfNeighboors[1]=possibleposition[48]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[50])){
-                listOfNeighboors[1]=possibleposition[51]; //west
-        		listOfNeighboors[2]=possibleposition[61]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[51])){
-                listOfNeighboors[0]=possibleposition[48]; //south
-        		listOfNeighboors[3]=possibleposition[50]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[52])){
-                listOfNeighboors[0]=possibleposition[47]; //south
-                listOfNeighboors[1]=possibleposition[53]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[53])){
-        		listOfNeighboors[2]=possibleposition[58]; //north
-        		listOfNeighboors[3]=possibleposition[52]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[54])){
-                listOfNeighboors[0]=possibleposition[42]; //south
-                listOfNeighboors[1]=possibleposition[55]; //west
-        		listOfNeighboors[2]=possibleposition[57]; //north
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[55])){
-        		listOfNeighboors[2]=possibleposition[56]; //north
-        		listOfNeighboors[3]=possibleposition[54]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[56])){
-                listOfNeighboors[0]=possibleposition[55]; //south
-        		listOfNeighboors[2]=possibleposition[65]; //north
-        		listOfNeighboors[3]=possibleposition[57]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[57])){
-                listOfNeighboors[0]=possibleposition[54]; //south
-                listOfNeighboors[1]=possibleposition[56]; //west
-        		listOfNeighboors[2]=possibleposition[64]; //north
-        		listOfNeighboors[3]=possibleposition[58]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[58])){
-                listOfNeighboors[0]=possibleposition[53]; //south
-                listOfNeighboors[1]=possibleposition[57]; //west
-        		listOfNeighboors[3]=possibleposition[59]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[59])){
-                listOfNeighboors[1]=possibleposition[58]; //west
-        		listOfNeighboors[2]=possibleposition[63]; //north
-        		listOfNeighboors[3]=possibleposition[60]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[60])){
-                listOfNeighboors[1]=possibleposition[59]; //west
-        		listOfNeighboors[2]=possibleposition[62]; //north
-        		listOfNeighboors[3]=possibleposition[61]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[61])){
-                listOfNeighboors[0]=possibleposition[50]; //south
-                listOfNeighboors[1]=possibleposition[60]; //west
-        		listOfNeighboors[3]=possibleposition[13]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[62])){
-                listOfNeighboors[0]=possibleposition[60]; //south
-        		listOfNeighboors[3]=possibleposition[16]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[63])){
-                listOfNeighboors[0]=possibleposition[59]; //south
-                listOfNeighboors[1]=possibleposition[64]; //west
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[64])){
-                listOfNeighboors[0]=possibleposition[57]; //south
-                listOfNeighboors[1]=possibleposition[65]; //west
-        		listOfNeighboors[3]=possibleposition[63]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[65])){
-                listOfNeighboors[0]=possibleposition[56]; //south
-        		listOfNeighboors[3]=possibleposition[64]; //east
-        		return listOfNeighboors[s];
-            }
-            else if(findpos(pacLasVisPos,possibleposition[66])){
-                //Not back in center
-                listOfNeighboors[1]=possibleposition[47]; //west
-        		listOfNeighboors[3]=possibleposition[48]; //east
-        		return listOfNeighboors[s];            
-        	}
-*/
-
-	}
+}
 
 	
