Index: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	(revision 11904)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	(revision 11915)
@@ -50,5 +50,5 @@
         this->setCollisionType(CollisionType::Dynamic);
 
-        this->resetposition = Vector3(0,20,245); //Set Default start position
+        this->resetposition = this->getPosition(); //Set Default start position
         
         this->actuelposition = this->getPosition();
@@ -81,6 +81,12 @@
 
     
-    Vector3 possibleposition[] = {Vector3(175,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195),
-        Vector3(185,10,150),Vector3(135,10,145),Vector3(215,10,150)};
+    Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4
+        Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9
+        Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14
+        Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19
+        Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24
+        Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29
+        Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105) //30-34
+    };
 
     /**
@@ -99,5 +105,5 @@
         
         //Stop, if target arrived
-        if((abs(this->actuelposition.x - this->target_x)<0.1) && (abs(this->actuelposition.z - this->target_z)<0.1)){
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
                  this->ismoving = false;
         }
@@ -105,10 +111,10 @@
         //Move, if ghost hasn't arrived yet
         if(this->ismoving){
-            if(!(abs(this->actuelposition.z-target_z)<0.1)) {
-                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)*2);
                 move(dt, actuelposition, velocity);
             }    
-            if(!(abs(this->actuelposition.x-target_x)<0.1)){
-                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x)*2,0,0);
                 move(dt, actuelposition, velocity);
             }
@@ -118,5 +124,5 @@
          else{
             if(findpos(actuelposition,possibleposition[0])){
-            	setnewTarget(1);
+            	setnewTarget(1,17,19);
             }
             else if(findpos(actuelposition,possibleposition[1])){
@@ -136,8 +142,89 @@
             }
             else if(findpos(actuelposition,possibleposition[6])){
-                setnewTarget(4);
+                setnewTarget(4,9,26);
             }
             else if(findpos(actuelposition,possibleposition[7])){
-                setnewTarget(5);
+                setnewTarget(5,8);
+            }
+            else if(findpos(actuelposition,possibleposition[8])){
+                setnewTarget(7,9);
+            }
+            else if(findpos(actuelposition,possibleposition[9])){
+                setnewTarget(6,8,10); //38
+            }
+            else if(findpos(actuelposition,possibleposition[10])){
+                setnewTarget(9,11); //45,9
+            }
+            else if(findpos(actuelposition,possibleposition[11])){
+                setnewTarget(10,12,13);
+            }
+            else if(findpos(actuelposition,possibleposition[12])){
+                setnewTarget(11,14);
+            }
+            else if(findpos(actuelposition,possibleposition[13])){
+                setnewTarget(11,14,16); //61
+            }
+            else if(findpos(actuelposition,possibleposition[14])){
+                setnewTarget(12,13,15);
+            }
+            else if(findpos(actuelposition,possibleposition[15])){
+                setnewTarget(14,16);
+            }
+            else if(findpos(actuelposition,possibleposition[16])){
+                setnewTarget(13,15); //62
+            }
+            else if(findpos(actuelposition,possibleposition[17])){
+                setnewTarget(0,25);
+            }
+            else if(findpos(actuelposition,possibleposition[18])){
+                setnewTarget(19,24);
+            }
+            else if(findpos(actuelposition,possibleposition[19])){
+                setnewTarget(0,18,20);
+            }
+            else if(findpos(actuelposition,possibleposition[20])){
+                setnewTarget(19,21);
+            }
+            else if(findpos(actuelposition,possibleposition[21])){
+                setnewTarget(20,22);
+            }
+            else if(findpos(actuelposition,possibleposition[22])){
+                setnewTarget(21,23,31);
+            }
+            else if(findpos(actuelposition,possibleposition[23])){
+                setnewTarget(22,30);
+            }
+            else if(findpos(actuelposition,possibleposition[24])){
+                setnewTarget(18,29);
+            }
+            else if(findpos(actuelposition,possibleposition[25])){
+                setnewTarget(17,26);
+            }
+            else if(findpos(actuelposition,possibleposition[26])){
+                setnewTarget(6,25,27);
+            }
+            else if(findpos(actuelposition,possibleposition[27])){
+                setnewTarget(26,28);//37
+            }
+            else if(findpos(actuelposition,possibleposition[28])){
+                setnewTarget(27,29); //36
+            }
+            else if(findpos(actuelposition,possibleposition[29])){
+                setnewTarget(24,28,30);
+            }
+            else if(findpos(actuelposition,possibleposition[30])){
+                setnewTarget(23,29,34);
+            }
+            else if(findpos(actuelposition,possibleposition[31])){
+                setnewTarget(22,32);
+            }
+            else if(findpos(actuelposition,possibleposition[32])){
+                setnewTarget(31,33);
+            }
+            else if(findpos(actuelposition,possibleposition[33])){
+                setnewTarget(32,34);
+            }
+            else if(findpos(actuelposition,possibleposition[34])){
+                setnewTarget(30,33);//35,42
             }
 
@@ -230,137 +317,15 @@
 
     bool PacmanGhost::findpos(Vector3 one, Vector3 other){
-        if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
+        if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
         return false;
     }
 
     void PacmanGhost::resetGhost(){
-        this->setPosition(resetposition);
+        this->setPosition(this->resetposition);
+        this->ismoving = false;
+        this->actuelposition = this->getPosition();
+        
+        this->target_x = actuelposition.x;
+        this->target_z = actuelposition.z;
     }
 }
-
-/*
-//Check on which position ghost has arrived and set new target
-         else{
-            if(findpos(actuelposition,possibleposition[0])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[1].x;
-                    this->target_z = possibleposition[1].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            
-            }
-            else if(findpos(actuelposition,possibleposition[1])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[0].x;
-                    this->target_z = possibleposition[0].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[2].x;
-                    this->target_z = possibleposition[2].z; 
-                    this->ismoving = true;
-                    break;    
-            }
-
-            }
-            else if(findpos(actuelposition,possibleposition[2])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[1].x;
-                    this->target_z = possibleposition[1].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            
-            }
-
-            else if(findpos(actuelposition,possibleposition[3])){
-                decision = rand()%3;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[2].x;
-                    this->target_z = possibleposition[2].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[4].x;
-                    this->target_z = possibleposition[4].z; 
-                    this->ismoving = true;
-                    break;
-                case 2:
-                    this->target_x = possibleposition[5].x;
-                    this->target_z = possibleposition[5].z; 
-                    this->ismoving = true;
-                    break;        
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[4])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[6].x;
-                    this->target_z = possibleposition[6].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[5])){
-                decision = rand()%2;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[3].x;
-                    this->target_z = possibleposition[3].z; 
-                    this->ismoving = true;
-                    break;
-                case 1:
-                    this->target_x = possibleposition[7].x;
-                    this->target_z = possibleposition[7].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[6])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[4].x;
-                    this->target_z = possibleposition[4].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-            else if(findpos(actuelposition,possibleposition[7])){
-                decision = rand()%1;
-            switch(decision){
-                case 0:
-                    this->target_x = possibleposition[5].x;
-                    this->target_z = possibleposition[5].z; 
-                    this->ismoving = true;
-                    break;
-            }
-            }
-
-
-            else{
-            } //End of Position table
-            */
