Index: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	(revision 11900)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	(revision 11903)
@@ -118,4 +118,129 @@
          else{
             if(findpos(actuelposition,possibleposition[0])){
+            	setnewTarget(1);
+            }
+            else if(findpos(actuelposition,possibleposition[1])){
+            	setnewTarget(0,2);
+            }
+            else if(findpos(actuelposition,possibleposition[2])){
+        		setnewTarget(1,3);
+            }
+            else if(findpos(actuelposition,possibleposition[3])){
+			    setnewTarget(2,4,5);
+            }
+            else if(findpos(actuelposition,possibleposition[4])){
+				setnewTarget(3,6);
+            }
+            else if(findpos(actuelposition,possibleposition[5])){
+            	setnewTarget(3,7);
+            }
+            else if(findpos(actuelposition,possibleposition[6])){
+                setnewTarget(4);
+            }
+            else if(findpos(actuelposition,possibleposition[7])){
+                setnewTarget(5);
+            }
+
+
+            else{
+            } //End of Position table
+            }
+
+    }
+
+    void PacmanGhost::setnewTarget(int firstdec){
+    	  decision = rand()%1;
+            switch(decision){
+                case 0:
+                    this->target_x = possibleposition[firstdec].x;
+                    this->target_z = possibleposition[firstdec].z; 
+                    this->ismoving = true;
+                    break;
+    		}
+    }
+
+    void PacmanGhost::setnewTarget(int firstdec, int seconddec){
+    	   decision = rand()%2;
+            switch(decision){
+                case 0:
+                    this->target_x = possibleposition[firstdec].x;
+                    this->target_z = possibleposition[firstdec].z; 
+                    this->ismoving = true;
+                    break;
+                case 1:
+                    this->target_x = possibleposition[seconddec].x;
+                    this->target_z = possibleposition[seconddec].z; 
+                    this->ismoving = true;
+                    break;  
+            }
+    }
+
+    void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){
+    	   decision = rand()%3;
+            switch(decision){
+                case 0:
+                    this->target_x = possibleposition[firstdec].x;
+                    this->target_z = possibleposition[firstdec].z; 
+                    this->ismoving = true;
+                    break;
+                case 1:
+                    this->target_x = possibleposition[seconddec].x;
+                    this->target_z = possibleposition[seconddec].z; 
+                    this->ismoving = true;
+                    break;
+                case 2:
+                    this->target_x = possibleposition[thirddec].x;
+                    this->target_z = possibleposition[thirddec].z; 
+                    this->ismoving = true;
+                    break;    
+    		}
+	}
+
+    void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){
+    	   decision = rand()%4;
+            switch(decision){
+                case 0:
+                    this->target_x = possibleposition[firstdec].x;
+                    this->target_z = possibleposition[firstdec].z; 
+                    this->ismoving = true;
+                    break;
+                case 1:
+                    this->target_x = possibleposition[seconddec].x;
+                    this->target_z = possibleposition[seconddec].z; 
+                    this->ismoving = true;
+                    break;
+                case 2:
+                    this->target_x = possibleposition[thirddec].x;
+                    this->target_z = possibleposition[thirddec].z; 
+                    this->ismoving = true;
+                    break;
+                case 3:
+                	this->target_x = possibleposition[fourthdec].x;
+                    this->target_z = possibleposition[fourthdec].z; 
+                    this->ismoving = true;
+                    break;    
+    		}
+	}
+
+
+
+    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
+        this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
+    }
+
+    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
+        if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
+        return false;
+    }
+
+    void PacmanGhost::resetGhost(){
+        this->setPosition(resetposition);
+    }
+}
+
+/*
+//Check on which position ghost has arrived and set new target
+         else{
+            if(findpos(actuelposition,possibleposition[0])){
                 decision = rand()%1;
             switch(decision){
@@ -239,20 +364,2 @@
             else{
             } //End of Position table
-            }
-
-    }
-
-
-    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
-        this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
-    }
-
-    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
-        if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
-        return false;
-    }
-
-    void PacmanGhost::resetGhost(){
-        this->setPosition(resetposition);
-    }
-}
Index: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	(revision 11900)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	(revision 11903)
@@ -51,4 +51,10 @@
             void resetGhost();
 
+            void setnewTarget(int firstdec);
+            void setnewTarget(int firstdec, int seconddec);
+            void setnewTarget(int firstdec, int seconddec, int thirddec);
+            void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec);
+
+
             bool findpos(Vector3 one, Vector3 other);
 
