Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc	(revision 12325)
@@ -102,6 +102,12 @@
                 }
                 else{
+                    if(findpos(this->lastPlayerPassedPoint, Vector3(-215,10,-195))){
                     Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195));
                     this->setNewTargetGhost(nextMoveP);
+                    }
+                    else{
+                    Vector3 nextMoveP = getShortestPath(brownPos, Vector3(-215,10,-195), this->lastPlayerPassedPoint);
+                    this->setNewTargetGhost(nextMoveP);
+                    }
                 }
 
@@ -123,63 +129,4 @@
 
 
-            /*if(absoluteDistance(this->lastPlayerPassedPoint, this->actuelposition)<50){
-                //no idea if 50 is large enough 
-
-                //if near player, flee
-
-                this->isFleeing=true;
-                Vector3 nextMove=getShortestPath( brownPos,Vector3(-215, 10, -195));
-                setNewTargetGhost(nextMove);
-
-            }
-
-            else if((this->isFleeing==true)&&(!findpos(brownPos,Vector3(-215,10,-195)))){
-                //if fleeing, continue to flee
-             Vector3 nextMove = getShortestPath(brownPos, Vector3(-215, 10, -195));
-             setNewTargetGhost(nextMove);
-        }
-            else if ((this->isFleeing==true)&&(findpos(brownPos,Vector3(-215,10,-195)))){
-                //if fleeing and reached flee point, go back near player
-            this->isFleeing=false;
-            Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
-            setNewTargetGhost(nextMove);
-        }
-            else{
-                //if not fleeing and not near player, go near player
-                Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);
-            setNewTargetGhost(nextMove);
-            }
-            if(this->isFleeing){
-                std::cout<<"fleeing"<<endl;
-            }
-        }*/
-
-
-
-
-        	/*if((this->fleeing==true)&&(this->actuelposition!=(-215,10,-195))){
-            //if fleeing, then go to corner map if not already there
-        		fleeMode();
-        	}
-        	else{ // else go next to pacman
-
-        		if(absoluteDistance(this->pos, player.pos)<10){//no idea if 10 ok
-        	//if near player, flee away
-        	fleemode();
-        			}
-        		else{ //go to neighboor of player nearest to brown pacman
-
-        		//first find nearest neighboor point of player to brown pacman
-        		//we can maybe call getShortestPath recursively to do so
-
-player.pos.nearestneighboor=findPlayerNeighboorNearestToPacman(player.neighboors);
-//btw the array player.neighboor can be defined with a big list as we
-//already did several times for similar things
-
-        	Vector3 nextMove = getShortestPath(this->actuelposition, player.pos.nearestneighboor);
-        	setNewTargetBrown(nextMove);
-        		}
-
-        	}*/
             lockmove=false; //NEVER FORGET THIS ONE !!!
    
@@ -204,5 +151,5 @@
 
 
-        void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){      
+        /*void PacmanBrown::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){      
             //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint
 
@@ -515,5 +462,5 @@
                 adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
                        }
-    }
+    }*/
 
 
@@ -521,123 +468,2 @@
 }
 
-
-
-
-
-
-
-
-
-	/*int graphDistance(Vector3 start, Vector3 goal){
-
-        Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
-
-        return differenceVector.x+differenceVector.z;
-    }*/
-
-	/*void setNewTargetBrown(Vector3 goalToGo){
-
-					this->target_x = goalToGo.x;
-                    this->target_z = goalToGo.z; 
-                    this->ismoving = true;
-	}*/
-
-
-
-	/*int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){
-
-
-		Vector3 diffVector;
-		diffVector.x=pos2-pos1;
-		diffVector.y=pos2-pos1; //should always be 0
-		diffVector.z=pos2-pos1;
-		int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z));
-		return result;
-	}*/
-
-
-	/*void fleeMode(){ //flees to corner of the map
-
-		Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change
-		Vector3 nextMove = getShortestPath(this->actuelposition, cornerPos);
-		setNewTargetGhost(nextMove);
-
-		//while(this->actuelposition!=cornerPos){
-	
-		continue moving and each time find next point to go until
-		we reach the corner
-		}
-	}*/
-
-
-	/*Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){
-		//find ,nearest to brown, player neighboor 
-
-		int besTotDist=-1;
-		Vector3 curPos=this->pos;
-		Vector3  predPos;
-		Vector3 chosenNeighbor;
-
-		for(int i=0; i < 4; i++){
-			int totDist=0;
-
-			if(neighboorsOfPlayer[i]!=0){
-				while(curPos!=neighboorsOfPlayer[i]){
-
-					predPos=curPos;
-					curPos = getShortestPath(curPos, neighboorsOfPlayer[i]);
-					totDist+=graphDistance(curPos,predPos);
-
-				}
-			}
-
-			if(besTotDist==-1){
-				besTotDist=totDist;
-				chosenNeighbor=neighboorsOfPlayer[i];
-			}
-			else if(besTotDist>totDist){
-				besTotDist=totDist;
-				chosenNeighbor=neighboorsOfPlayer[i];
-			}
-		}
-		return chosenNeighbor;
-
-	}*/
-
-
-	/*Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){
-		//uh, i think it does the same think as the function above
-
-        Vector3 nextMove;
-        int distCost=-1;
-        for(int i=0; i < 4; i++){
-        	int totDist=0;
-        	Vector3 newCandidate=this->actuelposition;
-        	Vector3 predPos;
-
-            if(neighboorArray[i]!=NULL){
-                while(nextMove!=neighboorArray[i]){
-                	predPos=newCandidate;
-                	newCandidate=getShortestPath(newCandidate, neighboorArray[i]);
-                	totDist+=graphDistance(predPos, newCandidate);
-                    }
-
-                    if(distCost==-1){
-                distCost=totDist;
-                nextMove=gneighboorArray[i];
-                    }
-                    else if(totDist<distCost){
-                distCost=totDist;
-                nextMove=neighboorArray[i];
-                    }
-            }
-        }
-        return nextMove;
-
-    }*/
-
-
-
-
-
-
Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h	(revision 12325)
@@ -37,5 +37,5 @@
         bool isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]);
 
-        void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
+        //void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
 
 
Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc	(revision 12325)
@@ -784,29 +784,4 @@
             }
         }
-
-
-        /*Vector3 difference = diffVector(playerPosBefore, playerPos);
-        if((difference.z < 0)&&(difference.z>difference.x)){ //move south
-
-            return 0;
-        }
-        else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north
-
-            return 2;
-        }
-        else if((difference.x < 0)&&(difference.x > difference.z )){//move west
-
-            return 1;
-        }
-
-        else if((difference.x>0)&&(difference.x>difference.z)){ //move east
-            return 3;
-
-        }
-
-        else { //default move west Can still be changed
-
-        return 1;
-            }*/
         
         }
@@ -829,15 +804,15 @@
                 listOfNeighboors[2]=possibleposition[17]; //north
                 listOfNeighboors[3]=possibleposition[1]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[1])){
                 listOfNeighboors[1]=possibleposition[0]; // west neighbor
                 listOfNeighboors[2]=possibleposition[2]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[2])){
                 listOfNeighboors[0]=possibleposition[1];  //south
                 listOfNeighboors[1]=possibleposition[3]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[3])){
@@ -845,15 +820,15 @@
                 listOfNeighboors[2]=possibleposition[5]; //north
                 listOfNeighboors[3]=possibleposition[2]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[4])){
                 listOfNeighboors[2]=possibleposition[6]; //north
                 listOfNeighboors[3]=possibleposition[3]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[5])){
                 listOfNeighboors[0]=possibleposition[3]; //south
                 listOfNeighboors[3]=possibleposition[7]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[6])){
@@ -861,15 +836,15 @@
                 listOfNeighboors[1]=possibleposition[26]; //west
                 listOfNeighboors[2]=possibleposition[9]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[7])){
                 listOfNeighboors[1]=possibleposition[5]; //west
                 listOfNeighboors[2]=possibleposition[8]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[8])){
                 listOfNeighboors[0]=possibleposition[7]; //south
                 listOfNeighboors[1]=possibleposition[9]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[9])){
@@ -878,5 +853,5 @@
                 listOfNeighboors[2]=possibleposition[10]; //north
                 listOfNeighboors[3]=possibleposition[8]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[10])){
@@ -889,5 +864,5 @@
                 listOfNeighboors[1]=possibleposition[45]; //west
                 listOfNeighboors[2]=possibleposition[11]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[11])){
@@ -895,10 +870,10 @@
                 listOfNeighboors[2]=possibleposition[13]; //north
                 listOfNeighboors[3]=possibleposition[12]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[12])){
                 listOfNeighboors[1]=possibleposition[11]; //west
                 listOfNeighboors[2]=possibleposition[14]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[13])){
@@ -907,5 +882,5 @@
                 listOfNeighboors[2]=possibleposition[16]; //north
                 listOfNeighboors[3]=possibleposition[14]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[14])){
@@ -913,10 +888,10 @@
                 listOfNeighboors[1]=possibleposition[13]; //west
                 listOfNeighboors[2]=possibleposition[15]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[15])){
                 listOfNeighboors[0]=possibleposition[14]; //south
                 listOfNeighboors[1]=possibleposition[16]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[16])){
@@ -924,15 +899,15 @@
                 listOfNeighboors[1]=possibleposition[62]; //west
                 listOfNeighboors[2]=possibleposition[15]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[17])){
                 listOfNeighboors[0]=possibleposition[0]; //south
                 listOfNeighboors[3]=possibleposition[25]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[18])){
                 listOfNeighboors[0]=possibleposition[19]; //south
                 listOfNeighboors[1]=possibleposition[24]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[19])){
@@ -940,15 +915,15 @@
                 listOfNeighboors[2]=possibleposition[18]; //north
                 listOfNeighboors[3]=possibleposition[0]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[20])){
                 listOfNeighboors[2]=possibleposition[21]; //north
                 listOfNeighboors[3]=possibleposition[19]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[21])){
                 listOfNeighboors[0]=possibleposition[20]; //south
                 listOfNeighboors[3]=possibleposition[22]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[22])){
@@ -956,20 +931,20 @@
                 listOfNeighboors[2]=possibleposition[31]; //north
                 listOfNeighboors[3]=possibleposition[23]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[23])){
                 listOfNeighboors[1]=possibleposition[22]; //west
                 listOfNeighboors[2]=possibleposition[30]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[24])){
                 listOfNeighboors[2]=possibleposition[29]; //north
                 listOfNeighboors[3]=possibleposition[18]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[25])){
                 listOfNeighboors[1]=possibleposition[17]; //west
                 listOfNeighboors[2]=possibleposition[26]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[26])){
@@ -977,5 +952,5 @@
                 listOfNeighboors[1]=possibleposition[27]; //west
                 listOfNeighboors[3]=possibleposition[6]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[27])){
@@ -983,5 +958,5 @@
                 listOfNeighboors[2]=possibleposition[37]; //north
                 listOfNeighboors[3]=possibleposition[26]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[28])){
@@ -989,5 +964,5 @@
                 listOfNeighboors[2]=possibleposition[36]; //north
                 listOfNeighboors[3]=possibleposition[27]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[29])){
@@ -995,5 +970,5 @@
                 listOfNeighboors[1]=possibleposition[30]; //west
                 listOfNeighboors[3]=possibleposition[28]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[30])){
@@ -1001,20 +976,20 @@
                 listOfNeighboors[2]=possibleposition[34]; //north
                 listOfNeighboors[3]=possibleposition[29]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[31])){
                 listOfNeighboors[0]=possibleposition[22]; //south
                 listOfNeighboors[1]=possibleposition[32]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[32])){
                 listOfNeighboors[2]=possibleposition[33]; //north
                 listOfNeighboors[3]=possibleposition[31]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[33])){
                 listOfNeighboors[0]=possibleposition[32]; //south
                 listOfNeighboors[3]=possibleposition[34]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[34])){
@@ -1023,5 +998,5 @@
                 listOfNeighboors[2]=possibleposition[92]; //north
                 listOfNeighboors[3]=possibleposition[35]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[35])){
@@ -1029,15 +1004,15 @@
                 listOfNeighboors[2]=possibleposition[91]; //north
                 listOfNeighboors[3]=possibleposition[36]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[36])){
                 listOfNeighboors[0]=possibleposition[28]; //south
                 listOfNeighboors[1]=possibleposition[35]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[37])){
                 listOfNeighboors[0]=possibleposition[27]; //south
                 listOfNeighboors[3]=possibleposition[38]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[38])){
@@ -1045,5 +1020,5 @@
                 listOfNeighboors[2]=possibleposition[39]; //north
                 listOfNeighboors[3]=possibleposition[9]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[39])){
@@ -1051,5 +1026,5 @@
                 listOfNeighboors[1]=possibleposition[40]; //west
                 listOfNeighboors[2]=possibleposition[45]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[40])){
@@ -1057,5 +1032,5 @@
                 //Not return in center
                 listOfNeighboors[3]=possibleposition[39]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[41])){
@@ -1063,5 +1038,5 @@
                 listOfNeighboors[2]=possibleposition[43]; //north
                 listOfNeighboors[3]=possibleposition[40]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[42])){
@@ -1074,5 +1049,5 @@
                 listOfNeighboors[2]=possibleposition[59]; //north
                 listOfNeighboors[3]=possibleposition[43]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[43])){
@@ -1080,10 +1055,10 @@
                 listOfNeighboors[1]=possibleposition[42]; //west
                 listOfNeighboors[2]=possibleposition[46]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[44])){
                 listOfNeighboors[0]=possibleposition[40]; //south
                 listOfNeighboors[2]=possibleposition[66]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[45])){
@@ -1091,10 +1066,10 @@
                 listOfNeighboors[2]=possibleposition[49]; //north
                 listOfNeighboors[3]=possibleposition[10]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[46])){
                 listOfNeighboors[0]=possibleposition[43]; //south
                 listOfNeighboors[3]=possibleposition[47]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[47])){
@@ -1102,5 +1077,5 @@
                 listOfNeighboors[2]=possibleposition[52]; //north
                 listOfNeighboors[3]=possibleposition[66]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[48])){
@@ -1108,30 +1083,30 @@
                 listOfNeighboors[2]=possibleposition[51]; //north
                 listOfNeighboors[3]=possibleposition[49]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[49])){
                 listOfNeighboors[0]=possibleposition[45]; //south
                 listOfNeighboors[1]=possibleposition[48]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[50])){
                 listOfNeighboors[1]=possibleposition[51]; //west
                 listOfNeighboors[2]=possibleposition[61]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[51])){
                 listOfNeighboors[0]=possibleposition[48]; //south
                 listOfNeighboors[3]=possibleposition[50]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[52])){
                 listOfNeighboors[0]=possibleposition[47]; //south
                 listOfNeighboors[1]=possibleposition[53]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[53])){
                 listOfNeighboors[2]=possibleposition[58]; //north
                 listOfNeighboors[3]=possibleposition[52]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[54])){
@@ -1139,10 +1114,10 @@
                 listOfNeighboors[1]=possibleposition[55]; //west
                 listOfNeighboors[2]=possibleposition[57]; //north
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[55])){
                 listOfNeighboors[2]=possibleposition[56]; //north
                 listOfNeighboors[3]=possibleposition[54]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[56])){
@@ -1150,5 +1125,5 @@
                 listOfNeighboors[2]=possibleposition[65]; //north
                 listOfNeighboors[3]=possibleposition[57]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[57])){
@@ -1157,5 +1132,5 @@
                 listOfNeighboors[2]=possibleposition[64]; //north
                 listOfNeighboors[3]=possibleposition[58]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[58])){
@@ -1163,5 +1138,5 @@
                 listOfNeighboors[1]=possibleposition[57]; //west
                 listOfNeighboors[3]=possibleposition[59]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[59])){
@@ -1169,5 +1144,5 @@
                 listOfNeighboors[2]=possibleposition[63]; //north
                 listOfNeighboors[3]=possibleposition[60]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[60])){
@@ -1175,5 +1150,5 @@
                 listOfNeighboors[2]=possibleposition[62]; //north
                 listOfNeighboors[3]=possibleposition[61]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[61])){
@@ -1181,15 +1156,15 @@
                 listOfNeighboors[1]=possibleposition[60]; //west
                 listOfNeighboors[3]=possibleposition[13]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[62])){
                 listOfNeighboors[0]=possibleposition[60]; //south
                 listOfNeighboors[3]=possibleposition[16]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[63])){
                 listOfNeighboors[0]=possibleposition[59]; //south
                 listOfNeighboors[1]=possibleposition[64]; //west
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[64])){
@@ -1197,10 +1172,10 @@
                 listOfNeighboors[1]=possibleposition[65]; //west
                 listOfNeighboors[3]=possibleposition[63]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[65])){
                 listOfNeighboors[0]=possibleposition[56]; //south
                 listOfNeighboors[3]=possibleposition[64]; //east
-                return listOfNeighboors[indexForSWNE];
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
             }
             else if(findpos(pacLasVisPos,possibleposition[66])){
@@ -1208,8 +1183,370 @@
                 listOfNeighboors[1]=possibleposition[47]; //west
                 listOfNeighboors[3]=possibleposition[48]; //east
-                return listOfNeighboors[indexForSWNE];            
-            }
-
-        }
+                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);            
+            }
+
+        }
+
+
+
+
+///////////////////////
+
+
+
+
+
+    Vector3 PacmanGhost::frontPosition(){
+
+    Vector3 neighborPos[4] = {Vector3(-1,-1,-1)};
+    Vector3 frontPoint = Vector3(0,-1,0);
+
+
+    findNeighboorPositions(this->lastPlayerPassedPoint, neighborPos, possibleposition);
+
+    for(int i=0; i<4; i++){
+
+     if((neighborPos[i]!=Vector3(-1,-1,-1))&&(neighborPos[i].y==10)){
+     //y==10 to ignore many unwanted strange positions that pop up otherwise and create SIGSEV
+        
+        if(frontPoint==Vector3(0,-1,0)){
+            frontPoint=neighborPos[i];
+
+                        }
+        else if (graphDistance(this->getPlayerPos(), frontPoint)>graphDistance(this->getPlayerPos(), neighborPos[i])){
+            frontPoint=neighborPos[i];
+                        }
+
+                    }
+        std::cout<<"bra"<<frontPoint<<endl;
+                }
+
+    if(frontPoint==Vector3(0,-1,0)){
+        //default
+        return this->lastPlayerPassedPoint;
+            }
+    else{
+        std::cout<<frontPoint<<endl;
+        return frontPoint;
+            }
+    }
+
+
+
+
+
+
+    void PacmanGhost::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){      
+            //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint
+
+            if(findpos(actuelposition,possibleposition[0])){
+                
+
+                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);  //need to do it everywhere !!!
+                adjacentPositions[1]=positionArray[17]; //graphVertex(possibleposition[17]);
+                adjacentPositions[2]=positionArray[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
+            }
+            else if(findpos(actuelposition,possibleposition[1])){
+                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
+                adjacentPositions[1]=positionArray[2]; //graphVertex(possibleposition[2]);
+            }
+            else if(findpos(actuelposition,possibleposition[2])){
+                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);
+                adjacentPositions[1]=positionArray[3]; //graphVertex(possibleposition[3]);
+            }
+            else if(findpos(actuelposition,possibleposition[3])){
+                adjacentPositions[0]=positionArray[2]; //graphVertex(possibleposition[2]);
+                adjacentPositions[1]=positionArray[4]; //graphVertex(possibleposition[4]);
+                adjacentPositions[2]=positionArray[5]; //graphVertex(possibleposition[5]);
+            }
+            else if(findpos(actuelposition,possibleposition[4])){
+                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
+                adjacentPositions[1]=positionArray[6]; //graphVertex(possibleposition[6]);
+            }
+            else if(findpos(actuelposition,possibleposition[5])){
+                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
+                adjacentPositions[1]=positionArray[7]; //graphVertex(possibleposition[7]);
+            }
+            else if(findpos(actuelposition,possibleposition[6])){
+                adjacentPositions[0]=positionArray[4]; //graphVertex(possibleposition[4]);
+                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
+                adjacentPositions[2]=positionArray[26]; //graphVertex(possibleposition[26]);
+            }
+            else if(findpos(actuelposition,possibleposition[7])){
+                adjacentPositions[0]=positionArray[5]; //graphVertex(possibleposition[5]);
+                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
+            }
+            else if(findpos(actuelposition,possibleposition[8])){
+                adjacentPositions[0]=positionArray[7]; //graphVertex(possibleposition[7]);
+                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
+            }
+            else if(findpos(actuelposition,possibleposition[9])){
+                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
+                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
+                adjacentPositions[2]=positionArray[10]; //graphVertex(possibleposition[10]);
+                adjacentPositions[3]=positionArray[38]; //graphVertex(possibleposition[38]);
+            }
+            else if(findpos(actuelposition,possibleposition[10])){
+                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
+                adjacentPositions[1]=positionArray[11]; //graphVertex(possibleposition[11]);
+                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
+            }
+            else if(findpos(actuelposition,possibleposition[11])){
+                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
+                adjacentPositions[1]=positionArray[12]; //graphVertex(possibleposition[12]);
+                adjacentPositions[2]=positionArray[13]; //graphVertex(possibleposition[13]);
+            }
+            else if(findpos(actuelposition,possibleposition[12])){
+                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
+                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
+            }
+            else if(findpos(actuelposition,possibleposition[13])){
+                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
+                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
+                adjacentPositions[2]=positionArray[16]; //graphVertex(possibleposition[16]);
+                adjacentPositions[3]=positionArray[61]; //graphVertex(possibleposition[61]);
+            }
+            else if(findpos(actuelposition,possibleposition[14])){
+                adjacentPositions[0]=positionArray[12]; //graphVertex(possibleposition[12]);
+                adjacentPositions[1]=positionArray[13]; //graphVertex(possibleposition[13]);
+                adjacentPositions[2]=positionArray[15]; //graphVertex(possibleposition[15]);
+            }
+            else if(findpos(actuelposition,possibleposition[15])){
+                adjacentPositions[0]=positionArray[14]; //graphVertex(possibleposition[14]);
+                adjacentPositions[1]=positionArray[16]; //graphVertex(possibleposition[16]);
+            }
+            else if(findpos(actuelposition,possibleposition[16])){
+                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
+                adjacentPositions[1]=positionArray[15]; //graphVertex(possibleposition[15]);
+                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
+            }
+            else if(findpos(actuelposition,possibleposition[17])){
+                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
+                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
+            }
+            else if(findpos(actuelposition,possibleposition[18])){
+                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
+                adjacentPositions[1]=positionArray[24]; //graphVertex(possibleposition[24]);                
+            }
+            else if(findpos(actuelposition,possibleposition[19])){
+                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
+                adjacentPositions[1]=positionArray[18]; //graphVertex(possibleposition[18]);
+                adjacentPositions[2]=positionArray[20]; //graphVertex(possibleposition[20]);
+                         }
+            else if(findpos(actuelposition,possibleposition[20])){
+                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
+                adjacentPositions[1]=positionArray[21]; //graphVertex(possibleposition[21]);
+                       }
+            else if(findpos(actuelposition,possibleposition[21])){
+                adjacentPositions[0]=positionArray[20]; //graphVertex(possibleposition[20]);
+                adjacentPositions[1]=positionArray[22]; //graphVertex(possibleposition[22]);
+                       }
+            else if(findpos(actuelposition,possibleposition[22])){
+                adjacentPositions[0]=positionArray[21]; //graphVertex(possibleposition[21]);
+                adjacentPositions[1]=positionArray[23]; //graphVertex(possibleposition[23]);
+                adjacentPositions[2]=positionArray[31]; //graphVertex(possibleposition[31]);
+                          }
+            else if(findpos(actuelposition,possibleposition[23])){
+                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
+                adjacentPositions[1]=positionArray[30]; //graphVertex(possibleposition[30]);
+                       }
+            else if(findpos(actuelposition,possibleposition[24])){
+                adjacentPositions[0]=positionArray[18]; //graphVertex(possibleposition[18]);
+                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
+                       }
+            else if(findpos(actuelposition,possibleposition[25])){
+                adjacentPositions[0]=positionArray[17]; //graphVertex(possibleposition[17]);
+                adjacentPositions[1]=positionArray[26]; //graphVertex(possibleposition[26]);
+                       }
+            else if(findpos(actuelposition,possibleposition[26])){
+                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
+                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
+                adjacentPositions[2]=positionArray[27]; //graphVertex(possibleposition[27]);
+                         }
+            else if(findpos(actuelposition,possibleposition[27])){
+                adjacentPositions[0]=positionArray[26]; //graphVertex(possibleposition[26]);
+                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
+                adjacentPositions[2]=positionArray[37]; //graphVertex(possibleposition[37]);
+                          }
+            else if(findpos(actuelposition,possibleposition[28])){
+                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
+                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
+                adjacentPositions[2]=positionArray[36]; //graphVertex(possibleposition[36]);
+                          }
+            else if(findpos(actuelposition,possibleposition[29])){
+                adjacentPositions[0]=positionArray[24]; //graphVertex(possibleposition[24]);
+                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
+                adjacentPositions[2]=positionArray[30]; //graphVertex(possibleposition[30]);
+                          }
+            else if(findpos(actuelposition,possibleposition[30])){
+                adjacentPositions[0]=positionArray[23]; //graphVertex(possibleposition[23]);
+                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
+                adjacentPositions[2]=positionArray[34]; //graphVertex(possibleposition[34]);
+                          }
+            else if(findpos(actuelposition,possibleposition[31])){
+                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
+                adjacentPositions[1]=positionArray[32]; //graphVertex(possibleposition[32]);
+                       }
+            else if(findpos(actuelposition,possibleposition[32])){
+                adjacentPositions[0]=positionArray[31]; //graphVertex(possibleposition[31]);
+                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
+                       }
+            else if(findpos(actuelposition,possibleposition[33])){
+                adjacentPositions[0]=positionArray[32]; //graphVertex(possibleposition[32]);
+                adjacentPositions[1]=positionArray[34]; //graphVertex(possibleposition[34]);
+                       }
+            else if(findpos(actuelposition,possibleposition[34])){
+                adjacentPositions[0]=positionArray[30]; //graphVertex(possibleposition[30]);
+                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
+                adjacentPositions[2]=positionArray[35]; //graphVertex(possibleposition[35]);
+                adjacentPositions[3]=positionArray[42]; //graphVertex(possibleposition[42]);
+                
+            }
+            else if(findpos(actuelposition,possibleposition[35])){
+                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
+                adjacentPositions[1]=positionArray[36]; //graphVertex(possibleposition[36]);
+                adjacentPositions[2]=positionArray[41]; //graphVertex(possibleposition[41]);
+                          }
+            else if(findpos(actuelposition,possibleposition[36])){
+                adjacentPositions[0]=positionArray[28]; //graphVertex(possibleposition[28]);
+                adjacentPositions[1]=positionArray[35]; //graphVertex(possibleposition[35]);
+                       }
+            else if(findpos(actuelposition,possibleposition[37])){
+                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
+                adjacentPositions[1]=positionArray[38]; //graphVertex(possibleposition[38]);
+                       }
+            else if(findpos(actuelposition,possibleposition[38])){
+                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
+                adjacentPositions[1]=positionArray[37]; //graphVertex(possibleposition[37]);
+                adjacentPositions[2]=positionArray[39]; //graphVertex(possibleposition[39]);
+                         }
+            else if(findpos(actuelposition,possibleposition[39])){
+                adjacentPositions[0]=positionArray[38]; //graphVertex(possibleposition[38]);
+                adjacentPositions[1]=positionArray[40]; //graphVertex(possibleposition[40]);
+                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
+                          }
+            else if(findpos(actuelposition,possibleposition[40])){
+                adjacentPositions[0]=positionArray[39]; //graphVertex(possibleposition[39]);
+                adjacentPositions[1]=positionArray[41]; //graphVertex(possibleposition[41]);
+            }
+            else if(findpos(actuelposition,possibleposition[41])){
+                adjacentPositions[0]=positionArray[35]; //graphVertex(possibleposition[35]);
+                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
+                       }
+            else if(findpos(actuelposition,possibleposition[42])){
+                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
+                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
+                adjacentPositions[2]=positionArray[54]; //graphVertex(possibleposition[54]);
+                          }
+            else if(findpos(actuelposition,possibleposition[43])){
+                adjacentPositions[0]=positionArray[41]; //graphVertex(possibleposition[41]);
+                adjacentPositions[1]=positionArray[46]; //graphVertex(possibleposition[46]);
+                       }
+            else if(findpos(actuelposition,possibleposition[44])){
+                adjacentPositions[0]=positionArray[40]; //graphVertex(possibleposition[40]);
+                adjacentPositions[1]=positionArray[66]; //graphVertex(possibleposition[66]);
+                       }
+            else if(findpos(actuelposition,possibleposition[45])){
+                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
+                adjacentPositions[1]=positionArray[39]; //graphVertex(possibleposition[39]);
+                adjacentPositions[2]=positionArray[49]; //graphVertex(possibleposition[49]);
+                          }
+            else if(findpos(actuelposition,possibleposition[46])){
+                adjacentPositions[0]=positionArray[43]; //graphVertex(possibleposition[43]);
+                adjacentPositions[1]=positionArray[47]; //graphVertex(possibleposition[47]);
+                       }
+            else if(findpos(actuelposition,possibleposition[47])){
+                adjacentPositions[0]=positionArray[46]; //graphVertex(possibleposition[46]);
+                adjacentPositions[1]=positionArray[52]; //graphVertex(possibleposition[52]);
+                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
+                          }
+            else if(findpos(actuelposition,possibleposition[48])){
+                adjacentPositions[0]=positionArray[49]; //graphVertex(possibleposition[49]);
+                adjacentPositions[1]=positionArray[51]; //graphVertex(possibleposition[51]);
+                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
+                          }
+            else if(findpos(actuelposition,possibleposition[49])){
+                adjacentPositions[0]=positionArray[45]; //graphVertex(possibleposition[45]);
+                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
+                       }
+            else if(findpos(actuelposition,possibleposition[50])){
+                adjacentPositions[0]=positionArray[51]; //graphVertex(possibleposition[51]);
+                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
+                       }
+            else if(findpos(actuelposition,possibleposition[51])){
+                adjacentPositions[0]=positionArray[48]; //graphVertex(possibleposition[48]);
+                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
+                       }
+            else if(findpos(actuelposition,possibleposition[52])){
+                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
+                adjacentPositions[1]=positionArray[53]; //graphVertex(possibleposition[53]);
+                       }
+            else if(findpos(actuelposition,possibleposition[53])){
+                adjacentPositions[0]=positionArray[52]; //graphVertex(possibleposition[52]);
+                adjacentPositions[1]=positionArray[58]; //graphVertex(possibleposition[58]);
+                       }
+            else if(findpos(actuelposition,possibleposition[54])){
+                adjacentPositions[0]=positionArray[42]; //graphVertex(possibleposition[42]);
+                adjacentPositions[1]=positionArray[55]; //graphVertex(possibleposition[55]);
+                adjacentPositions[2]=positionArray[57]; //graphVertex(possibleposition[57]);
+                          }
+            else if(findpos(actuelposition,possibleposition[55])){
+                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
+                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
+                       }
+            else if(findpos(actuelposition,possibleposition[56])){
+                adjacentPositions[0]=positionArray[55]; //graphVertex(possibleposition[55]);
+                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
+                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
+                          }
+            else if(findpos(actuelposition,possibleposition[57])){
+                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
+                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
+                adjacentPositions[2]=positionArray[58]; //graphVertex(possibleposition[58]);
+                adjacentPositions[3]=positionArray[64]; //graphVertex(possibleposition[64]);
+                
+            }
+            else if(findpos(actuelposition,possibleposition[58])){
+                adjacentPositions[0]=positionArray[53]; //graphVertex(possibleposition[53]);
+                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
+                adjacentPositions[2]=positionArray[59]; //graphVertex(possibleposition[59]);
+                          }
+            else if(findpos(actuelposition,possibleposition[59])){
+                adjacentPositions[0]=positionArray[58]; //graphVertex(possibleposition[58]);
+                adjacentPositions[1]=positionArray[59]; //graphVertex(possibleposition[59]);
+                adjacentPositions[2]=positionArray[63]; //graphVertex(possibleposition[63]);
+                          }
+            else if(findpos(actuelposition,possibleposition[60])){
+                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
+                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
+                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
+                          }
+            else if(findpos(actuelposition,possibleposition[61])){
+                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
+                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
+                adjacentPositions[2]=positionArray[60]; //graphVertex(possibleposition[60]);
+                          }
+            else if(findpos(actuelposition,possibleposition[62])){
+                adjacentPositions[0]=positionArray[16]; //graphVertex(possibleposition[16]);
+                adjacentPositions[1]=positionArray[60]; //graphVertex(possibleposition[60]);
+                       }
+            else if(findpos(actuelposition,possibleposition[63])){
+                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
+                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
+                       }
+            else if(findpos(actuelposition,possibleposition[64])){
+                adjacentPositions[0]=positionArray[57]; //graphVertex(possibleposition[57]);
+                adjacentPositions[1]=positionArray[63]; //graphVertex(possibleposition[63]);
+                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
+                          }
+            else if(findpos(actuelposition,possibleposition[65])){
+                adjacentPositions[0]=positionArray[56]; //graphVertex(possibleposition[56]);
+                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
+                       }
+            else if(findpos(actuelposition,possibleposition[66])){
+                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
+                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
+                       }
+    }
 
 
Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h	(revision 12325)
@@ -135,4 +135,11 @@
 
 
+
+
+
+    void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
+
+    Vector3 frontPosition();
+
     };
 
Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc	(revision 12325)
@@ -45,7 +45,7 @@
 
         int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
-        this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
-        /*std::cout<<this->pointInFrontOfPlayer<<endl;
-        std::cout<<this->lastPlayerPassedPoint<<endl;*/
+        this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
+        std::cout<<this->pointInFrontOfPlayer<<endl;
+        std::cout<<this->lastPlayerPassedPoint<<endl;
         
         //Stop, if target arrived
@@ -92,7 +92,7 @@
             //this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
             
-            std::cout<<this->lastPlayerPassedPoint<<endl;
+            //std::cout<<this->lastPlayerPassedPoint<<endl;
 
-            std::cout<<this->pointInFrontOfPlayer<<endl;
+            //std::cout<<this->pointInFrontOfPlayer<<endl;
             nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint);
 
@@ -114,5 +114,5 @@
         Vector3 nextTarget;
 
-        if(playerPos==pointToAvoidP11){
+        if(playerPos==pointToAvoidP11){ //SIGSEV if playerPos==pointToAvoidP11 otherwise
             nextTarget = getShortestPath(pinkPosP, playerPos);
         }
Index: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc	(revision 12324)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc	(revision 12325)
@@ -64,4 +64,6 @@
         }*/
 
+            std::cout<<this->lastPlayerPassedPoint<<endl;
+            std::cout<<this->pointInFrontOfPlayer<<endl;
 
 
@@ -109,5 +111,5 @@
 
             int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
-            this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
+            this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
 
 
@@ -146,21 +148,9 @@
         Vector3 nextTarget;
 
+        if(redPosP!=playerPos){
 	   nextTarget = getShortestPath(redPosP, playerPos);
-	
-	   setNewTargetGhost(nextTarget);
+       setNewTargetGhost(nextTarget);
+        }
 	}
 
-
-
-    //save last checkpoint crossed by player 
-    /* 
-        void PacmanGelb::tick(float dt){ //last passed point of player
-            for(int u=0; u < 67; u++){
-            if(findpos(this->getPosition(), possibleposition[u])){
-            this->lastPassedPoint=possibleposition[u];
-                    }
-                }
-        }
-    */
-
 }
