[Orxonox-commit 7816] r12408 - in code/branches/Presentation_FS19: . data/levels src/modules/pacman

wiesep at orxonox.net wiesep at orxonox.net
Wed May 22 13:58:40 CEST 2019


Author: wiesep
Date: 2019-05-22 13:58:40 +0200 (Wed, 22 May 2019)
New Revision: 12408

Added:
   code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.cpp
   code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.h
Modified:
   code/branches/Presentation_FS19/
   code/branches/Presentation_FS19/data/levels/3DPacman.oxw
   code/branches/Presentation_FS19/src/modules/pacman/CMakeLists.txt
   code/branches/Presentation_FS19/src/modules/pacman/Pacman.cc
   code/branches/Presentation_FS19/src/modules/pacman/Pacman.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.cc
   code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.h
   code/branches/Presentation_FS19/src/modules/pacman/PacmanPointSphere.cc
Log:
Merged 3DPacman_FS19

Index: code/branches/Presentation_FS19
===================================================================
--- code/branches/Presentation_FS19	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19	2019-05-22 11:58:40 UTC (rev 12408)

Property changes on: code/branches/Presentation_FS19
___________________________________________________________________
Modified: svn:mergeinfo
## -1,4 +1,5 ##
 /code/branches/3DPacman_FS18:11819-12041
+/code/branches/3DPacman_FS19:12206-12407
 /code/branches/AI_HS15:10640-10832
 /code/branches/Alejandro_FS17:11369-11447
 /code/branches/AsteroidMining_HS17:11461-11729
Modified: code/branches/Presentation_FS19/data/levels/3DPacman.oxw
===================================================================
--- code/branches/Presentation_FS19/data/levels/3DPacman.oxw	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/data/levels/3DPacman.oxw	2019-05-22 11:58:40 UTC (rev 12408)
@@ -34,29 +34,29 @@
     <SpawnPoint team=0 position="0,10,150" lookat="0,0,0" spawnclass=PacmanGelb pawndesign=PacmanGelb />
 
 <!-- GHOSTS -->
-<PacmanGhost position="0,10,15" >
+<PacmanRed position="0,10,15" colour='1'>
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostRed.mesh" scale="5" />
     </attached>
-</PacmanGhost>
+</PacmanRed>
 
-<PacmanGhost position="0,10,15" >
+<PacmanCyan position="0,10,15" colour='2'>
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostBlue.mesh" scale="5" />
     </attached>
-</PacmanGhost>
+</PacmanCyan>
 
-<PacmanGhost position="0,10,15" >
+<PacmanBrown position="0,10,15" colour='3'>
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostOrange.mesh" scale="5" />
     </attached>
-</PacmanGhost>
+</PacmanBrown>
 
-<PacmanGhost position="0,10,15" >
+<PacmanPink position="0,10,15" colour='4'>
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostPink.mesh" scale="5" />
     </attached>
-</PacmanGhost>
+</PacmanPink>
 
 
 <PacmanGhost position="0,-20,0" >
@@ -86,6 +86,13 @@
 
 
 <!-- POINTS first Line -->
+
+<PacmanLaser position="20,-20000,150">
+    <attached>
+        <Model position="0, 0, 0" yaw="90" pitch="-90" roll="0" scale3D="5, 5, 50" mesh="LaserBeam2.mesh" />
+    </attached>
+</PacmanLaser>
+
 <PacmanPointSphere position="-215,10,245">
     <attached>
         <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />

Modified: code/branches/Presentation_FS19/src/modules/pacman/CMakeLists.txt
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/CMakeLists.txt	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/CMakeLists.txt	2019-05-22 11:58:40 UTC (rev 12408)
@@ -5,6 +5,12 @@
   PacmanPointSphere.cc
   PacmanPointAfraid.cc
   PacmanHUDinfo.cc
+  PacmanRandom.cc
+  PacmanRed.cc
+  PacmanPink.cc
+  PacmanBrown.cc
+  PacmanCyan.cc
+  PacmanLaser.cpp
 )
 
 ORXONOX_ADD_LIBRARY(pacman

Modified: code/branches/Presentation_FS19/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/Pacman.cc	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/Pacman.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -38,6 +38,8 @@
 {
     RegisterClass(Pacman);
 
+    int PACMAN_INTERNAL_PACMAN_POSITION;
+
     Pacman::Pacman(Context* context) : Deathmatch(context)
     {
         RegisterObject(Pacman);
@@ -45,6 +47,7 @@
         lives = 3;
         point = 0;
         level = 1;
+        laser = 5; //after that number of eaten pointSpheres, the laser appears
 
     }
 
@@ -55,6 +58,12 @@
         	nextsphere->resetPacmanPointSphere();
         }
 
+        
+        PacmanLaser* pos = *(ObjectList<PacmanLaser>().begin());
+        pos->resetPacmanLaser();
+
+
+
         for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){
             next->resetPacmanPointAfraid();
         }
@@ -72,28 +81,50 @@
     }
 
 
-    PacmanGhost* ghosts[4];
+    PacmanGhost* ghosts[8];
 
 
     void Pacman::tick(float dt)
     {
+
         SUPER(Pacman, tick, dt);
 
+
         //Needed for gameover
         if(deathtime != 0){
             dead(dt);
+
+
+         
         }
 
         //ingame loop
         else{
 
+            //support by laser
+            if(point > laser + 240*(level-1)){
+              
+                for(PacmanPointSphere* pointer : ObjectList<PacmanPointSphere>()){
+                    Vector3 pointSpherePosition = pointer->getPosition();
+
+                     if(pointSpherePosition.y > 0){// pointSphere above surface =not eaten yet
+
+                        PacmanLaser* pos = *(ObjectList<PacmanLaser>().begin());
+                        pos->setPosition(pointSpherePosition);
+                        break;
+                    }
+
+
+                }
+
+            }
+
             //Register ghosts
             int i = 0;
-            for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
+            for(PacmanGhost* nextghost: ObjectList<PacmanGhost>()){
                 ghosts[i] = nextghost;
                 i++;
             }
-
             //Switch ghost to not-catchable, if timer is zero
             if(afraid){
                 timer = timer - dt;
@@ -136,7 +167,7 @@
 
     //Check for collisions between to objects (compare float numbers)
     bool Pacman::collis(Vector3 one, Vector3 other){
-        if((abs(one.x-other.x)<10) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<10))
+        if((abs(one.x-other.x)<19) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<19))
             return true;
         return false;
     }
@@ -202,6 +233,7 @@
     //Collision with PointSphere
     void Pacman::takePoint(PacmanPointSphere* taken){
         ++point;
+        
         if(point == totallevelpoint){ 
             this->levelUp();
             return;
@@ -280,4 +312,4 @@
     {
         GSLevel::startMainMenu();
     }
-}
+}
\ No newline at end of file

Modified: code/branches/Presentation_FS19/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/Pacman.h	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/Pacman.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -39,8 +39,8 @@
 #include "PacmanGhost.h"
 #include "PacmanPointSphere.h"
 #include "PacmanPointAfraid.h"
+#include "PacmanLaser.h"
 
-
 #include "core/EventIncludes.h"
 #include "core/command/Executor.h"
 #include "core/config/ConfigValueIncludes.h"
@@ -59,7 +59,15 @@
 
 namespace orxonox
 {
+    /*
+deklaration ohne Speicher zu reservieren. definition in Pacman.cc
+wird benoetigt um auf die Position global zuzugreifen
 
+analog pacman_next
+
+    */
+    extern int PACMAN_INTERNAL_PACMAN_POSITION;
+
     class _PacmanExport Pacman : public Deathmatch
     {
        public:
@@ -105,6 +113,7 @@
             int level;
             int point;
             int lives;
+            int laser;
         
     };
 }

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.cc (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.cc	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,148 @@
+	
+#include "PacmanBrown.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+	
+	namespace orxonox{
+
+		RegisterClass(PacmanBrown);
+
+		PacmanBrown::PacmanBrown(Context* context) : PacmanGhost(context){
+
+        RegisterObject(PacmanBrown);
+
+        this->target_x=0;
+        this->target_z=15;
+        this->lastPlayerPassedPoint=Vector3(0,0,0); 
+          
+    }
+
+    /**
+    @brief
+        Method for creating a ghost through XML.
+    */
+    void PacmanBrown::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanBrown, XMLPort, xmlelement, mode);
+    }
+
+
+int PacmanBrown::absoluteDistance(Vector3 pos1, Vector3 pos2){
+
+
+        Vector3 diffVector;
+        diffVector.x=pos2.x-pos1.x;
+        diffVector.y=pos2.y-pos1.y; //should always be 0
+        diffVector.z=pos2.z-pos1.z;
+        int result = sqrt((diffVector.x)*(diffVector.x)+(diffVector.z)*(diffVector.z));
+        return result;
+    }
+
+
+	void PacmanBrown::tick(float dt)
+    {
+        SUPER(PacmanGhost, tick, dt);
+
+        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
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
+                 this->ismoving = false;
+        }
+
+        //Move, if ghost hasn't arrived yet
+        if(this->ismoving){
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+                move(dt, actuelposition, velocity);
+            }    
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+                move(dt, actuelposition, velocity);
+            }
+        }
+        else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){
+            //as long as the player has not started the game,
+            //i.e. lastPlayerPastPoint is (0,0,0), brown pacman
+            //cannot possibly move, because it needs the position
+            //of the player to move accordingly
+
+            this->ismoving=false;
+        }
+        
+        //Check on which position the ghost has arrived and set new target
+        else{
+        	while(lockmove){};
+            lockmove = true;
+
+        	//do brown behavior
+        	//put everything needed here
+
+            Vector3 brownPos=Vector3(this->target_x, 10, this->target_z);
+
+            
+            if(this->isFleeing==true){
+                if(findpos(brownPos, Vector3(-215,10,-195))){
+                    this->isFleeing=false;
+                }
+                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);
+                    }
+                }
+
+            }
+            else {
+                    Vector3 arrayPlaNeig[4];
+
+                    findNeighboorPositions(this->lastPlayerPassedPoint, arrayPlaNeig, possibleposition);
+                    if(isAdjacentToPlayerLastPastPoint(brownPos, arrayPlaNeig)){
+                        this->isFleeing=true;
+                    }
+                    else{
+                        Vector3 nextMove = getShortestPath(brownPos, this->lastPlayerPassedPoint);        
+                        setNewTargetGhost(nextMove);
+                    }
+                    
+            }
+
+
+            lockmove=false; //NEVER FORGET THIS ONE !!!
+   
+        }
+}
+
+
+    bool PacmanBrown::isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]){
+            //return true if brownPacman is on an adjacent position to the last
+            //point visited by the player. return false otherwise.
+
+            for(int i =0; i < 4; i++){
+                if(arrayForNeighborPositions[i]!=Vector3(0,0,0)){
+                    if(findpos(pacmanBrownPos, arrayForNeighborPositions[i])){
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+
+
+}
+

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanBrown.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,40 @@
+#ifndef _PacmanBrown_H__
+#define _PacmanBrown_H__
+
+#include "PacmanGhost.h"
+
+namespace orxonox {
+
+	class _OrxonoxExport PacmanBrown : public PacmanGhost{
+
+		public :
+			PacmanBrown(Context* context);
+
+			  virtual void tick(float dt) override; //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+  			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+  			void setNewTargetBrown(Vector3 goalToGo);
+
+  			void nextMove(Vector3 playerPos, Vector3 redPos);
+
+  			int graphDistance(Vector3 start, Vector3 goal);
+
+  			int absoluteDistance(Vector3 pos1, Vector3 pos2);
+
+  			void fleeMode();
+
+
+  			Vector3 goAdjacentOfPlayer(Vector3 neighboorsOfPlayer[]);
+  			//they both do the same -_-
+  			Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray);
+
+        bool isFleeing;
+
+        bool isAdjacentToPlayerLastPastPoint(Vector3 pacmanBrownPos, Vector3 arrayForNeighborPositions[]);
+
+	};
+
+}
+
+#endif 
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.cc (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.cc	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,158 @@
+#include "PacmanCyan.h"
+//#include "Pacman.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+	namespace orxonox{
+
+		RegisterClass(PacmanCyan);
+
+		PacmanCyan::PacmanCyan(Context* context) : PacmanGhost(context){
+
+        RegisterObject(PacmanCyan);
+        this->target_x=0;
+        this->target_z=15;
+        this->setPosition(Vector3(0,10,15));
+        this->lastPlayerPassedPoint=Vector3(70,10,-135);
+
+        this->isPatrolling = false;
+          
+    }
+
+
+    /**
+    @brief
+        Method for creating a ghost through XML.
+    */
+    void PacmanCyan::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanCyan, XMLPort, xmlelement, mode);
+    }
+
+
+
+    void PacmanCyan::tick(float dt)
+    {
+        
+        SUPER(PacmanGhost, tick, dt);
+        this->actuelposition = this->getPosition();
+
+        //Stop, if target arrived
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
+            
+                 this->ismoving = false;
+        }
+
+        //Move, if ghost hasn't arrived yet
+        if(this->ismoving){     
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+                move(dt, actuelposition, velocity);
+            }    
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+                move(dt, actuelposition, velocity);
+            }    
+        }
+
+        //Check on which position the ghost has arrived and set new target
+        else{
+            while(lockmove){};
+            lockmove = true;
+
+            Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
+        	
+            if(this->isPatrolling==false){
+                //we are not patrolling anymore, choose new patrol
+
+
+                this->nextPatrol();
+
+            }
+            else if(this->passedByStart==false){
+                //we have not even reached our startPatrol point
+
+                if(findpos(cyanPos, startPatrol)){
+                    this->passedByStart=true;
+                }
+                else{
+                nextMove(cyanPos, startPatrol);
+                }
+            }
+            else if(this->passedByGoal==false){
+                //we have reached our startPatrol point, now we go to goalPoint
+
+                if(findpos(cyanPos, goalPatrol)){
+                    this->passedByGoal=true;
+                }
+                else{
+                nextMove(cyanPos, goalPatrol);
+                }
+
+            }
+            else if(!findpos(cyanPos, this->startPatrol)){
+                //we reached our goal, now we return to start
+
+                nextMove(cyanPos, startPatrol);
+
+            }
+            else {
+                //we reached startPoint again. Either we change patrol
+                //or redo same patrol
+
+                int redoORNot = rand()%2;
+
+                if(redoORNot==1){
+
+                this->isPatrolling=false;
+                //we will change patrol region
+                    }
+                else {
+                this->passedByGoal=false;
+                //repeat patrol region
+                    }
+            }
+
+            lockmove=false; //NEVER FORGET THIS ONE !!!!!!!
+        }
+        
+    }
+
+    void PacmanCyan::nextPatrol(){
+
+                int indexRand1=rand()%67;
+                while(indexRand1==44){
+                    //new try if index is that of the position in the middle
+                    indexRand1=rand()%67;
+                }
+
+                int indexRand2=rand()%67;
+                while((indexRand2==44)||(indexRand2==indexRand1)){
+                    //new try if 2nd index is same as first one or is index
+                    // of position in the middle
+
+                    indexRand2=rand()%67;
+                }
+
+              this->startPatrol =  possibleposition[indexRand1];
+              this->goalPatrol = possibleposition[indexRand2];
+
+              this->passedByStart=false;
+              this->passedByGoal=false;
+              this->isPatrolling=true;
+
+    }
+
+
+
+
+	void PacmanCyan::nextMove( Vector3 cyanPosP, Vector3 playerPos){
+
+	   Vector3 nextTarget = getShortestPath(cyanPosP, playerPos);
+	
+	   setNewTargetGhost(nextTarget);
+	}
+
+
+}
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanCyan.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,35 @@
+#ifndef _PacmanCyan_H__
+#define _PacmanCyan_H__
+
+#include "PacmanGhost.h"
+
+namespace orxonox {
+
+	class _OrxonoxExport PacmanCyan : public PacmanGhost{
+
+		public :
+			PacmanCyan(Context* context);
+
+			  virtual void tick(float dt) override; //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+  			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+  			void nextMove( Vector3 cyanPosP, Vector3 playerPos);
+
+  			bool isPatrolling;
+
+  			void nextPatrol();
+
+  			Vector3 startPatrol;
+  			Vector3 goalPatrol;
+
+  			struct PatrolPosition;
+
+  			bool passedByStart;
+  			bool passedByGoal;
+
+	};
+
+}
+
+#endif 
\ No newline at end of file

Modified: code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.cc	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -31,467 +31,1057 @@
 #include "core/CoreIncludes.h"
 #include "BulletDynamics/Dynamics/btRigidBody.h"
 
+#include <vector>
+
 namespace orxonox
 {
-    RegisterClass(PacmanGhost);
 
-    /**
-    @brief
-        Constructor. Registers the object and initializes some default values.
-    @param creator
-        The creator of this object.
-    */
-    PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context)
-    {
-        RegisterObject(PacmanGhost);
 
-        this->velocity = Vector3(0, 0, 0);
+	struct PacmanGhost::graphVertex {
 
-        this->setCollisionType(CollisionType::Dynamic);
-        
-        this->actuelposition = this->getPosition();
+		public:
 
-        if(findpos(actuelposition, Vector3(0,-20,0)))
-            dontmove = true;
-        
-        this->target_x = actuelposition.x;
-        this->target_z = actuelposition.z; 
+			Vector3 position;
+			graphVertex *adjacentVertices[4]; //neighbooring vertices
 
-    }
+			int shortestDistanceToStart; //actual shortest distance to start point
+			graphVertex* actuelPredecessor; //the predecessor giving the for now shortest 
+			//path to start
+			graphVertex* currentNearestNonVisitedNeighboor; 
+			bool alreadyVisited;
+			graphVertex(){ //default constructor
+				position=0;
+				shortestDistanceToStart= std::numeric_limits<int>::max();
+				actuelPredecessor=nullptr;
+				alreadyVisited=false;
+				for(int kl =0; kl <4;kl++){
+					adjacentVertices[kl]=nullptr;  //first put all position in array listing neighboors to 0
+				}
+			}
+			graphVertex(Vector3 wantedPosition){  //normal constructor
+				position=wantedPosition;
+				shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity
+				actuelPredecessor=nullptr;
+				alreadyVisited=false;
+				for(int kl =0; kl <4;kl++){
+					adjacentVertices[kl]=nullptr;  //first put all position in array listing neighboors to 0
+				}
+			}
+			graphVertex& operator = (const graphVertex &rightSide){
+				this->position=rightSide.position;
+				this->shortestDistanceToStart=rightSide.shortestDistanceToStart;
+				this->actuelPredecessor=rightSide.actuelPredecessor;
+				this->currentNearestNonVisitedNeighboor=rightSide.currentNearestNonVisitedNeighboor;
+				this->alreadyVisited=rightSide.alreadyVisited;
 
-    /**
-    @brief
-        Destructor. Destroys ghost, if present.
-    */
-    PacmanGhost::~PacmanGhost()
-    {
-        // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
-    }
+				return *this;
+			}
 
-    /**
-    @brief
-        Method for creating a ghost through XML.
-    */
-    void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(PacmanGhost, XMLPort, xmlelement, mode);
-    }
+	};
 
 
-    //All positions in the map, see documentation
-    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
-        Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39
-        Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44
-        Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49
-        Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54
-        Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59
-        Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64
-        Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66
+	static PacmanGhost::graphVertex listOfVertices[67];
 
-    /**
-    @brief
-        Defines which actions the ghost has to take in each tick.
-    @param dt
-        The length of the tick.
-    */
-    void PacmanGhost::tick(float dt)
-    {
-        SUPER(PacmanGhost, tick, dt);
+	//Check if there is a collision
+	bool findpos(Vector3 one, Vector3 other){
+		if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
+		return false;
+	}
 
-        this->actuelposition = this->getPosition();
-        
-        //Stop, if target arrived
-        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
-                 this->ismoving = false;
-        }
+	//All positions in the map, see documentation
+	Vector3 possibleposition[67] = {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
+		Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39
+		Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44
+		Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49
+		Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54
+		Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59
+		Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64
+		Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66
 
-        //Move, if ghost hasn't arrived yet
-        if(this->ismoving){
-            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
-                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
-                move(dt, actuelposition, velocity);
-            }    
-            if(!(abs(this->actuelposition.x-target_x)<0.5)){
-                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
-                move(dt, actuelposition, velocity);
-            }
-        }
-        //Check on which position the ghost has arrived and set new target
-         else{
-            while(lockmove){};
-            lockmove = true;
+	RegisterClass(PacmanGhost);
 
-            if(findpos(actuelposition,possibleposition[0])){
-            	setnewTarget(1,17,19);
-            }
-            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,9,26);
-            }
-            else if(findpos(actuelposition,possibleposition[7])){
-                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);
-            }
-            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);
-            }
-            else if(findpos(actuelposition,possibleposition[35])){
-                setnewTarget(34,36,41);
-            }
-            else if(findpos(actuelposition,possibleposition[36])){
-                setnewTarget(28,35);
-            }
-            else if(findpos(actuelposition,possibleposition[37])){
-                setnewTarget(27,38);
-            }
-            else if(findpos(actuelposition,possibleposition[38])){
-                setnewTarget(9,37,39);
-            }
-            else if(findpos(actuelposition,possibleposition[39])){
-                setnewTarget(38,40,45);
-            }
-            else if(findpos(actuelposition,possibleposition[40])){
-                setnewTarget(39,41); //Shouldn't be able to return in center
-            }
-            else if(findpos(actuelposition,possibleposition[41])){
-                setnewTarget(35,43);
-            }
-            else if(findpos(actuelposition,possibleposition[42])){
-                setnewTarget(34,43,54);
-            }
-            else if(findpos(actuelposition,possibleposition[43])){
-                setnewTarget(41,46);
-            }
-            else if(findpos(actuelposition,possibleposition[44])){
-                setnewTarget(40,66);
-            }
-            else if(findpos(actuelposition,possibleposition[45])){
-                setnewTarget(10,39,49);
-            }
-            else if(findpos(actuelposition,possibleposition[46])){
-                setnewTarget(43,47);
-            }
-            else if(findpos(actuelposition,possibleposition[47])){
-                setnewTarget(46,52,66);
-            }
-            else if(findpos(actuelposition,possibleposition[48])){
-                setnewTarget(49,51,66);
-            }
-            else if(findpos(actuelposition,possibleposition[49])){
-                setnewTarget(45,48);
-            }
-            else if(findpos(actuelposition,possibleposition[50])){
-                setnewTarget(51,61);
-            }
-            else if(findpos(actuelposition,possibleposition[51])){
-                setnewTarget(48,50);
-            }
-            else if(findpos(actuelposition,possibleposition[52])){
-                setnewTarget(47,53);
-            }
-            else if(findpos(actuelposition,possibleposition[53])){
-                setnewTarget(52,58);
-            }
-            else if(findpos(actuelposition,possibleposition[54])){
-                setnewTarget(42,55,57);
-            }
-            else if(findpos(actuelposition,possibleposition[55])){
-                setnewTarget(54,56);
-            }
-            else if(findpos(actuelposition,possibleposition[56])){
-                setnewTarget(55,57,65);
-            }
-            else if(findpos(actuelposition,possibleposition[57])){
-                setnewTarget(54,56,58,64);
-            }
-            else if(findpos(actuelposition,possibleposition[58])){
-                setnewTarget(53,57,59);
-            }
-            else if(findpos(actuelposition,possibleposition[59])){
-                setnewTarget(58,59,63);
-            }
-            else if(findpos(actuelposition,possibleposition[60])){
-                setnewTarget(59,61,62);
-            }
-            else if(findpos(actuelposition,possibleposition[61])){
-                setnewTarget(13,50,60);
-            }
-            else if(findpos(actuelposition,possibleposition[62])){
-                setnewTarget(16,60);
-            }
-            else if(findpos(actuelposition,possibleposition[63])){
-                setnewTarget(59,64);
-            }
-            else if(findpos(actuelposition,possibleposition[64])){
-                setnewTarget(57,63,65);
-            }
-            else if(findpos(actuelposition,possibleposition[65])){
-                setnewTarget(56,64);
-            }
-            else if(findpos(actuelposition,possibleposition[66])){
-                setnewTarget(47,48);
-            }
+	/**
+	  @brief
+	  Constructor. Registers the object and initializes some default values.
+	  @param creator
+	  The creator of this object.
+	  */
+	PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context)
+	{
+		RegisterObject(PacmanGhost);
 
-            else{
-                this->resetGhost(); //Shouldn't happen...
-            } //End of Position table
-                lockmove = false;
-            }
-        
-    }
+		this->velocity = Vector3(0, 0, 0);
 
-    //Random choice of new target (not used in game, but useful)
-    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;
-    		}
-    }
+		this->setCollisionType(CollisionType::Dynamic);
 
-    //Random choice of new target
-    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;  
-            }
-            
-    }
+		this->actuelposition = this->getPosition();
 
-    //Random choice of new target
-    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;    
-    		}
-            
+		if(findpos(actuelposition, Vector3(0,-20,0)))
+			dontmove = true;
+
+		this->target_x = actuelposition.x;
+		this->target_z = actuelposition.z; 
+
 	}
 
-    //Random choice of new target
-    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;    
-    		}
+	/**
+	  @brief
+	  Destructor. Destroys ghost, if present.
+	  */
+	PacmanGhost::~PacmanGhost()
+	{
+		// Deletes the controller if the object was initialized and the pointer to the controller is not nullptr.
+	}
+
+	/**
+	  @brief
+	  Method for creating a ghost through XML.
+	  */
+	void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+	{
+		SUPER(PacmanGhost, XMLPort, xmlelement, mode);
+	}
+
+	//Change this with other ghost
+	void PacmanGhost::changewith(PacmanGhost* otherghost){
+
+		while(lockmove){};
+		lockmove = true;    //Prevent change of target while ghost is changed
+
+		otherghost->setPosition(this->getPosition());
+		this->setPosition(0,-20,0);
+		otherghost->target_x = this->target_x;   
+		otherghost->target_z = this->target_z;
+		otherghost->ismoving = this->ismoving;
+
+		this->dontmove = true;
+		otherghost->dontmove = false;
+
+		lockmove = false;
+	}
+
+	//Move ghost with rotation
+	void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
+		if(!dontmove){
+			this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt));
+
+			//Rotate ghost in the direction of movement 
+			if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)){
+				if(velocity.x<0){
+					this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0)));  
+				}
+				else{
+					this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0)));  
+				}
+			}
+			if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)){
+				if(velocity.z<0){
+					this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0)));  
+				}
+				else{
+					this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));  
+				}
+			}
+
+		}
+	}
+
+	//Change ability to move
+	void PacmanGhost::changemovability(){
+		if(dontmove){
+			dontmove = false;}
+		else{
+			dontmove = true;   
+		}
+	}
+
+	//ResetGhost
+	void PacmanGhost::resetGhost(){
+
+		this->setPosition(this->resetposition);
+		this->ismoving = false;
+		this->actuelposition = this->getPosition();
+
+		this->target_x = actuelposition.x;
+		this->target_z = actuelposition.z;
+
+	}
+
+	//Increase speed of ghosts
+	void PacmanGhost::levelupvelo(){
+		speed ++;
+	}
+
+	Vector3 PacmanGhost::getPlayerPos()
+	{
+		for (PacmanGelb* player : ObjectList<PacmanGelb>())
+		{
+			return player->getWorldPosition();
+		}
+		
+		return Vector3(0,0,0); //default, should not be used
+
+	}
+
+
+	bool PacmanGhost::jeanfindpos(Vector3 one, Vector3 other){
+		//This function is used to detect the last Vector3 position that the player crossed.
+
+		if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true;
+		return false;
+	}
+
+	void PacmanGhost::setNewTargetGhost(Vector3 goalToGo){
+		//Ghosts will go to goalToGo
+
+		this->target_x = goalToGo.x;
+		this->target_z = goalToGo.z; 
+		this->ismoving = true;
+	}
+
+
+	///
+	//// getShortestPath   /////////
+	///
+
+
+
+	Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1){
+		//this function should then somehow produce the algorithm and call all other functions
+		//and finally return the best neighboor of the actual position of the pacman
+
+		//(optional parameter) pointToAvoidP1 is a point that cannot be considered
+
+
+		graphVertex listOfVerticesM[67]; //our list of all possible graphs
+		graphVertex* actualVertex; //we will walk through the array with a pointer
+
+
+		if(start==goal){ // basic case
+			return start; 
+		}
+
+		for(int an=0; an < 67; an++){
+			listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file
             
+
+			if(start==possibleposition[an]){
+				actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array
+				
+			}
+		}
+
+		actualVertex->alreadyVisited=true; //our start point is now visited
+		actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0
+		findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
+		// second parameter is an array ! //third is our global array
+
+		while(actualVertex->position!=goal){
+			for(int h=0;h < 4; h++){
+				if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex
+
+					
+					updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]);
+				} //we "update" the neighboors of our new visited vertex
+
+			}
+
+			actualVertex=findNextVertexToConsider(listOfVerticesM, pointToAvoidP1);
+			actualVertex->alreadyVisited=true;
+			
+			if(actualVertex->position!=goal){
+				findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
+				//we find the neighboors of our new visited vertex
+			}
+		}
+
+		//we should have reached our goal at this point
+
+		while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor
+			actualVertex=actualVertex->actuelPredecessor;
+		}
+		// the predecessor is our starting point, in other words we are now on an
+		//adjacent vertex of the start
+
+		return actualVertex->position; //we return the position of this - adjacent to start - vertex
 	}
 
-    //Change this with other ghost
-    void PacmanGhost::changewith(PacmanGhost* otherghost){
+	//end of getShortestPath
 
-        while(lockmove){};
-        lockmove = true;    //Prevent change of target while ghost is changed
 
-        otherghost->setPosition(this->getPosition());
-        this->setPosition(0,-20,0);
-        otherghost->target_x = this->target_x;   
-        otherghost->target_z = this->target_z;
-        otherghost->ismoving = this->ismoving;
+	int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){
+		
+		Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
 
-        this->dontmove = true;
-        otherghost->dontmove = false;
+		return differenceVector.x+differenceVector.z;
+	}
 
-        lockmove = false;
-    }
+	void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){
+		//apply this method to all non visited neighboors of a vertex.
+		// This method should always be run on a vertex after we marked it as visited.
+		if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors.
+			if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&&
+					(neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + 
+					 graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case !
 
-    //Move ghost with rotation
-    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
-        if(!dontmove){
-            this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt));
-        
-        //Rotate ghost in the direction of movement 
-        if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1))
-            if(velocity.x<0){
-                 this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0)));  
-            }
-            else{
-                 this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0)));  
-            }
-        if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1))
-            if(velocity.z<0){
-                 this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0)));  
-            }
-            else{
-                 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));  
-            }
-                     
-     }
-    }
+				neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + 
+					graphDistance(vertex.position, neighboor.position);
+				neighboor.actuelPredecessor = &vertex;
+			}
+		}
+	}
 
-    //Check if there is a collision
-    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
-       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
-        return false;
-    }
+	void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3){ 
+		//find nearest non visited neighboor of a given already visited vertex
+		//(optional parameter) pointToAvoidP3 is a point that cannot be considered
+		int shortestDistance = -1;
+		graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any.
+		//Also, if all neighboors are already visited, we return NULL, i.e. there is no
+		//nearest non visited neighboor.
+		for(int i=0; i < 4; i++){
+			if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)&&(vertex.adjacentVertices[i]->position!=pointToAvoidP3)){
+				if(shortestDistance==-1){   //(concerns line above) we want a non visited neighboor //(optional) if the position of the neighboor is the one we want
+					//to avoid, then we ignore it
 
-    //Change ability to move
-    void PacmanGhost::changemovability(){
-        if(dontmove){
-         dontmove = false;}
-        else{
-         dontmove = true;   
-        }
-    }
+					shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
+					nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
+					
+				}
+				else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){
+					shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
+					nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
+					
+				}
+			}
+		}
+		vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses !
+		
+	}
 
-    //ResetGhost
-    void PacmanGhost::resetGhost(){
-    
-        this->setPosition(this->resetposition);
-        this->ismoving = false;
-        this->actuelposition = this->getPosition();
-        
-        this->target_x = actuelposition.x;
-        this->target_z = actuelposition.z;
-    
-    }
 
-    //Increase speed of ghosts
-    void PacmanGhost::levelupvelo(){
-        speed ++;
-    }
-}
\ No newline at end of file
+	PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2){ //find next, nearest from start, non visited vertex in our listOfVertices array
+		//(optional parameter) pointToAvoidP2 is a point that cannot be considered
+
+		int shortestDistance = -1;
+		graphVertex* nextVertexToConsider;
+
+		for(int i=0; i < 67; i++){ //we loop over all possible positions 
+
+			if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited 
+
+				findNearestNonVisitedNeighboor(listOfVerticesP[i], pointToAvoidP2); //we update nearest neighboor
+				//of all visited vertices given that one of the nearest neighboor of a visited
+				// vertex is now also visited because it was chosen as next optimal vertex
+
+				if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate!
+					if(shortestDistance==-1){ //our first possible candidate
+
+						shortestDistance=graphDistance(listOfVerticesP[i].position, 
+								listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
+							listOfVerticesP[i].shortestDistanceToStart;
+
+						nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
+						//adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor
+
+					}
+					else if(shortestDistance > graphDistance(listOfVerticesP[i].position, 
+								listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
+							listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available
+
+						shortestDistance=graphDistance(listOfVerticesP[i].position, 
+								listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
+							listOfVerticesP[i].shortestDistanceToStart;
+
+						nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
+						//we dont need the & because we are not giving the adress of the array element 
+						//listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor
+					}
+				}
+			}
+			//we want after all to return the nearest non visited neighboor
+		}
+
+		return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array
+	}
+
+	//////////////////////////////////////////////////////////////////////////////////////////////
+
+	void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){      
+		//Should put in adjacentVertices the neighboor points of actuelposition. listOfVertices is the
+		//array containing all possible positions in the map.
+
+		if(findpos(actuelposition,possibleposition[0])){
+			
+			adjacentVertices[0]=&listOfVerticesP2[1]; 
+			adjacentVertices[1]=&listOfVerticesP2[17]; 
+			adjacentVertices[2]=&listOfVerticesP2[19]; 
+		}
+		else if(findpos(actuelposition,possibleposition[1])){
+			adjacentVertices[0]=&listOfVerticesP2[0]; 
+			adjacentVertices[1]=&listOfVerticesP2[2]; 
+		}
+		else if(findpos(actuelposition,possibleposition[2])){
+			adjacentVertices[0]=&listOfVerticesP2[1]; 
+			adjacentVertices[1]=&listOfVerticesP2[3]; 
+		}
+		else if(findpos(actuelposition,possibleposition[3])){
+			adjacentVertices[0]=&listOfVerticesP2[2]; 
+			adjacentVertices[1]=&listOfVerticesP2[4]; 
+			adjacentVertices[2]=&listOfVerticesP2[5]; 
+		}
+		else if(findpos(actuelposition,possibleposition[4])){
+			adjacentVertices[0]=&listOfVerticesP2[3]; 
+			adjacentVertices[1]=&listOfVerticesP2[6]; 
+		}
+		else if(findpos(actuelposition,possibleposition[5])){
+			adjacentVertices[0]=&listOfVerticesP2[3]; 
+			adjacentVertices[1]=&listOfVerticesP2[7]; 
+		}
+		else if(findpos(actuelposition,possibleposition[6])){
+			adjacentVertices[0]=&listOfVerticesP2[4]; 
+			adjacentVertices[1]=&listOfVerticesP2[9]; 
+			adjacentVertices[2]=&listOfVerticesP2[26]; 
+		}
+		else if(findpos(actuelposition,possibleposition[7])){
+			adjacentVertices[0]=&listOfVerticesP2[5]; 
+			adjacentVertices[1]=&listOfVerticesP2[8]; 
+		}
+		else if(findpos(actuelposition,possibleposition[8])){
+			adjacentVertices[0]=&listOfVerticesP2[7]; 
+			adjacentVertices[1]=&listOfVerticesP2[9]; 
+		}
+		else if(findpos(actuelposition,possibleposition[9])){
+			adjacentVertices[0]=&listOfVerticesP2[6]; 
+			adjacentVertices[1]=&listOfVerticesP2[8]; 
+			adjacentVertices[2]=&listOfVerticesP2[10]; 
+			adjacentVertices[3]=&listOfVerticesP2[38]; 
+		}
+		else if(findpos(actuelposition,possibleposition[10])){
+			adjacentVertices[0]=&listOfVerticesP2[9]; 
+			adjacentVertices[1]=&listOfVerticesP2[11]; 
+			adjacentVertices[2]=&listOfVerticesP2[45]; 
+		}
+		else if(findpos(actuelposition,possibleposition[11])){
+			adjacentVertices[0]=&listOfVerticesP2[10]; 
+			adjacentVertices[1]=&listOfVerticesP2[12]; 
+			adjacentVertices[2]=&listOfVerticesP2[13]; 
+		}
+		else if(findpos(actuelposition,possibleposition[12])){
+			adjacentVertices[0]=&listOfVerticesP2[11]; 
+			adjacentVertices[1]=&listOfVerticesP2[14]; 
+		}
+		else if(findpos(actuelposition,possibleposition[13])){
+			adjacentVertices[0]=&listOfVerticesP2[11]; 
+			adjacentVertices[1]=&listOfVerticesP2[14]; 
+			adjacentVertices[2]=&listOfVerticesP2[16]; 
+			adjacentVertices[3]=&listOfVerticesP2[61]; 
+		}
+		else if(findpos(actuelposition,possibleposition[14])){
+			adjacentVertices[0]=&listOfVerticesP2[12]; 
+			adjacentVertices[1]=&listOfVerticesP2[13]; 
+			adjacentVertices[2]=&listOfVerticesP2[15]; 
+		}
+		else if(findpos(actuelposition,possibleposition[15])){
+			adjacentVertices[0]=&listOfVerticesP2[14]; 
+			adjacentVertices[1]=&listOfVerticesP2[16]; 
+		}
+		else if(findpos(actuelposition,possibleposition[16])){
+			adjacentVertices[0]=&listOfVerticesP2[13]; 
+			adjacentVertices[1]=&listOfVerticesP2[15]; 
+			adjacentVertices[2]=&listOfVerticesP2[62]; 
+		}
+		else if(findpos(actuelposition,possibleposition[17])){
+			adjacentVertices[0]=&listOfVerticesP2[0]; 
+			adjacentVertices[1]=&listOfVerticesP2[25]; 
+		}
+		else if(findpos(actuelposition,possibleposition[18])){
+			adjacentVertices[0]=&listOfVerticesP2[19]; 
+			adjacentVertices[1]=&listOfVerticesP2[24];                
+		}
+		else if(findpos(actuelposition,possibleposition[19])){
+			adjacentVertices[0]=&listOfVerticesP2[0]; 
+			adjacentVertices[1]=&listOfVerticesP2[18]; 
+			adjacentVertices[2]=&listOfVerticesP2[20]; 
+		}
+		else if(findpos(actuelposition,possibleposition[20])){
+			adjacentVertices[0]=&listOfVerticesP2[19]; 
+			adjacentVertices[1]=&listOfVerticesP2[21]; 
+		}
+		else if(findpos(actuelposition,possibleposition[21])){
+			adjacentVertices[0]=&listOfVerticesP2[20]; 
+			adjacentVertices[1]=&listOfVerticesP2[22]; 
+		}
+		else if(findpos(actuelposition,possibleposition[22])){
+			adjacentVertices[0]=&listOfVerticesP2[21]; 
+			adjacentVertices[1]=&listOfVerticesP2[23]; 
+			adjacentVertices[2]=&listOfVerticesP2[31]; 
+		}
+		else if(findpos(actuelposition,possibleposition[23])){
+			adjacentVertices[0]=&listOfVerticesP2[22]; 
+			adjacentVertices[1]=&listOfVerticesP2[30]; 
+		}
+		else if(findpos(actuelposition,possibleposition[24])){
+			adjacentVertices[0]=&listOfVerticesP2[18]; 
+			adjacentVertices[1]=&listOfVerticesP2[29]; 
+		}
+		else if(findpos(actuelposition,possibleposition[25])){
+			adjacentVertices[0]=&listOfVerticesP2[17]; 
+			adjacentVertices[1]=&listOfVerticesP2[26]; 
+		}
+		else if(findpos(actuelposition,possibleposition[26])){
+			adjacentVertices[0]=&listOfVerticesP2[6]; 
+			adjacentVertices[1]=&listOfVerticesP2[25]; 
+			adjacentVertices[2]=&listOfVerticesP2[27]; 
+		}
+		else if(findpos(actuelposition,possibleposition[27])){
+			adjacentVertices[0]=&listOfVerticesP2[26]; 
+			adjacentVertices[1]=&listOfVerticesP2[28]; 
+			adjacentVertices[2]=&listOfVerticesP2[37]; 
+		}
+		else if(findpos(actuelposition,possibleposition[28])){
+			adjacentVertices[0]=&listOfVerticesP2[27]; 
+			adjacentVertices[1]=&listOfVerticesP2[29]; 
+			adjacentVertices[2]=&listOfVerticesP2[36];
+		}
+		else if(findpos(actuelposition,possibleposition[29])){
+			adjacentVertices[0]=&listOfVerticesP2[24]; 
+			adjacentVertices[1]=&listOfVerticesP2[28]; 
+			adjacentVertices[2]=&listOfVerticesP2[30]; 
+		}
+		else if(findpos(actuelposition,possibleposition[30])){
+			adjacentVertices[0]=&listOfVerticesP2[23]; 
+			adjacentVertices[1]=&listOfVerticesP2[29]; 
+			adjacentVertices[2]=&listOfVerticesP2[34]; 
+		}
+		else if(findpos(actuelposition,possibleposition[31])){
+			adjacentVertices[0]=&listOfVerticesP2[22]; 
+			adjacentVertices[1]=&listOfVerticesP2[32]; 
+		}
+		else if(findpos(actuelposition,possibleposition[32])){
+			adjacentVertices[0]=&listOfVerticesP2[31]; 
+			adjacentVertices[1]=&listOfVerticesP2[33];
+		}
+		else if(findpos(actuelposition,possibleposition[33])){
+			adjacentVertices[0]=&listOfVerticesP2[32]; 
+			adjacentVertices[1]=&listOfVerticesP2[34];
+		}
+		else if(findpos(actuelposition,possibleposition[34])){
+			adjacentVertices[0]=&listOfVerticesP2[30]; 
+			adjacentVertices[1]=&listOfVerticesP2[33]; 
+			adjacentVertices[2]=&listOfVerticesP2[35]; 
+			adjacentVertices[3]=&listOfVerticesP2[42]; 
+
+		}
+		else if(findpos(actuelposition,possibleposition[35])){
+			adjacentVertices[0]=&listOfVerticesP2[34]; 
+			adjacentVertices[1]=&listOfVerticesP2[36]; 
+			adjacentVertices[2]=&listOfVerticesP2[41]; 
+		}
+		else if(findpos(actuelposition,possibleposition[36])){
+			adjacentVertices[0]=&listOfVerticesP2[28]; 
+			adjacentVertices[1]=&listOfVerticesP2[35]; 
+		}
+		else if(findpos(actuelposition,possibleposition[37])){
+			adjacentVertices[0]=&listOfVerticesP2[27]; 
+			adjacentVertices[1]=&listOfVerticesP2[38]; 
+		}
+		else if(findpos(actuelposition,possibleposition[38])){
+			adjacentVertices[0]=&listOfVerticesP2[9]; 
+			adjacentVertices[1]=&listOfVerticesP2[37]; 
+			adjacentVertices[2]=&listOfVerticesP2[39]; 
+		}
+		else if(findpos(actuelposition,possibleposition[39])){
+			adjacentVertices[0]=&listOfVerticesP2[38]; 
+			adjacentVertices[1]=&listOfVerticesP2[40]; 
+			adjacentVertices[2]=&listOfVerticesP2[45]; 
+		}
+		else if(findpos(actuelposition,possibleposition[40])){
+			adjacentVertices[0]=&listOfVerticesP2[39]; 
+			adjacentVertices[1]=&listOfVerticesP2[41]; 
+		}
+		else if(findpos(actuelposition,possibleposition[41])){
+			adjacentVertices[0]=&listOfVerticesP2[35]; 
+			adjacentVertices[1]=&listOfVerticesP2[43]; 
+			adjacentVertices[2]=&listOfVerticesP2[40]; 
+		}
+		else if(findpos(actuelposition,possibleposition[42])){
+			adjacentVertices[0]=&listOfVerticesP2[34]; 
+			adjacentVertices[1]=&listOfVerticesP2[43]; 
+			adjacentVertices[2]=&listOfVerticesP2[54]; 
+		}
+		else if(findpos(actuelposition,possibleposition[43])){
+			adjacentVertices[0]=&listOfVerticesP2[41]; 
+			adjacentVertices[1]=&listOfVerticesP2[46]; 
+			adjacentVertices[2]=&listOfVerticesP2[42]; 
+		}
+		else if(findpos(actuelposition,possibleposition[44])){
+			adjacentVertices[0]=&listOfVerticesP2[40]; 
+			adjacentVertices[1]=&listOfVerticesP2[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[45])){
+			adjacentVertices[0]=&listOfVerticesP2[10]; 
+			adjacentVertices[1]=&listOfVerticesP2[39];
+			adjacentVertices[2]=&listOfVerticesP2[49]; 
+		}
+		else if(findpos(actuelposition,possibleposition[46])){
+			adjacentVertices[0]=&listOfVerticesP2[43]; 
+			adjacentVertices[1]=&listOfVerticesP2[47]; 
+		}
+		else if(findpos(actuelposition,possibleposition[47])){
+			adjacentVertices[0]=&listOfVerticesP2[46]; 
+			adjacentVertices[1]=&listOfVerticesP2[52]; 
+			adjacentVertices[2]=&listOfVerticesP2[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[48])){
+			adjacentVertices[0]=&listOfVerticesP2[49]; 
+			adjacentVertices[1]=&listOfVerticesP2[51]; 
+			adjacentVertices[2]=&listOfVerticesP2[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[49])){
+			adjacentVertices[0]=&listOfVerticesP2[45]; 
+			adjacentVertices[1]=&listOfVerticesP2[48]; 
+		}
+		else if(findpos(actuelposition,possibleposition[50])){
+			adjacentVertices[0]=&listOfVerticesP2[51]; 
+			adjacentVertices[1]=&listOfVerticesP2[61]; 
+		}
+		else if(findpos(actuelposition,possibleposition[51])){
+			adjacentVertices[0]=&listOfVerticesP2[48]; 
+			adjacentVertices[1]=&listOfVerticesP2[50]; 
+		}
+		else if(findpos(actuelposition,possibleposition[52])){
+			adjacentVertices[0]=&listOfVerticesP2[47]; 
+			adjacentVertices[1]=&listOfVerticesP2[53]; 
+		}
+		else if(findpos(actuelposition,possibleposition[53])){
+			adjacentVertices[0]=&listOfVerticesP2[52]; 
+			adjacentVertices[1]=&listOfVerticesP2[58];
+		}
+		else if(findpos(actuelposition,possibleposition[54])){
+			adjacentVertices[0]=&listOfVerticesP2[42]; 
+			adjacentVertices[1]=&listOfVerticesP2[55]; 
+			adjacentVertices[2]=&listOfVerticesP2[57]; 
+		}
+		else if(findpos(actuelposition,possibleposition[55])){
+			adjacentVertices[0]=&listOfVerticesP2[54]; 
+			adjacentVertices[1]=&listOfVerticesP2[56]; 
+		}
+		else if(findpos(actuelposition,possibleposition[56])){
+			adjacentVertices[0]=&listOfVerticesP2[55]; 
+			adjacentVertices[1]=&listOfVerticesP2[57]; 
+			adjacentVertices[2]=&listOfVerticesP2[65]; 
+		}
+		else if(findpos(actuelposition,possibleposition[57])){
+			adjacentVertices[0]=&listOfVerticesP2[54]; 
+			adjacentVertices[1]=&listOfVerticesP2[56]; 
+			adjacentVertices[2]=&listOfVerticesP2[58]; 
+			adjacentVertices[3]=&listOfVerticesP2[64]; 
+
+		}
+		else if(findpos(actuelposition,possibleposition[58])){
+			adjacentVertices[0]=&listOfVerticesP2[53]; 
+			adjacentVertices[1]=&listOfVerticesP2[57]; 
+			adjacentVertices[2]=&listOfVerticesP2[59];
+		}
+		else if(findpos(actuelposition,possibleposition[59])){
+			adjacentVertices[0]=&listOfVerticesP2[58]; 
+			adjacentVertices[1]=&listOfVerticesP2[60]; 
+			adjacentVertices[2]=&listOfVerticesP2[63]; 
+		}
+		else if(findpos(actuelposition,possibleposition[60])){
+			adjacentVertices[0]=&listOfVerticesP2[59]; 
+			adjacentVertices[1]=&listOfVerticesP2[61]; 
+			adjacentVertices[2]=&listOfVerticesP2[62]; 
+		}
+		else if(findpos(actuelposition,possibleposition[61])){
+			adjacentVertices[0]=&listOfVerticesP2[13]; 
+			adjacentVertices[1]=&listOfVerticesP2[50]; 
+			adjacentVertices[2]=&listOfVerticesP2[60]; 
+		}
+		else if(findpos(actuelposition,possibleposition[62])){
+			adjacentVertices[0]=&listOfVerticesP2[16]; 
+			adjacentVertices[1]=&listOfVerticesP2[60]; 
+		}
+		else if(findpos(actuelposition,possibleposition[63])){
+			adjacentVertices[0]=&listOfVerticesP2[59]; 
+			adjacentVertices[1]=&listOfVerticesP2[64]; 
+		}
+		else if(findpos(actuelposition,possibleposition[64])){
+			adjacentVertices[0]=&listOfVerticesP2[57]; 
+			adjacentVertices[1]=&listOfVerticesP2[63]; 
+			adjacentVertices[2]=&listOfVerticesP2[65]; 
+		}
+		else if(findpos(actuelposition,possibleposition[65])){
+			adjacentVertices[0]=&listOfVerticesP2[56];
+			adjacentVertices[1]=&listOfVerticesP2[64];
+		}
+		else if(findpos(actuelposition,possibleposition[66])){
+			adjacentVertices[0]=&listOfVerticesP2[47];
+			adjacentVertices[1]=&listOfVerticesP2[48]; 
+		}
+	}
+
+
+	Vector3 PacmanGhost::frontPosition(){
+		//Should return the Vector3 point in front of the player. 
+
+		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];
+				}
+
+			}
+		}
+
+		if(frontPoint==Vector3(0,-1,0)){
+			//default
+			return this->lastPlayerPassedPoint;
+		}
+		else{
+			return frontPoint;
+		}
+	}
+
+
+
+
+
+
+	void PacmanGhost::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){      
+		//this function should put in adjacentPositions[] the neighboors of actuelposition.
+		// positionArray[] contains all possible positions of the map.
+
+		if(findpos(actuelposition,possibleposition[0])){
+
+
+			adjacentPositions[0]=positionArray[1];  
+			adjacentPositions[1]=positionArray[17]; 
+			adjacentPositions[2]=positionArray[19]; 
+		}
+		else if(findpos(actuelposition,possibleposition[1])){
+			adjacentPositions[0]=positionArray[0]; 
+			adjacentPositions[1]=positionArray[2]; 
+		}
+		else if(findpos(actuelposition,possibleposition[2])){
+			adjacentPositions[0]=positionArray[1]; 
+			adjacentPositions[1]=positionArray[3]; 
+		}
+		else if(findpos(actuelposition,possibleposition[3])){
+			adjacentPositions[0]=positionArray[2]; 
+			adjacentPositions[1]=positionArray[4]; 
+			adjacentPositions[2]=positionArray[5]; 
+		}
+		else if(findpos(actuelposition,possibleposition[4])){
+			adjacentPositions[0]=positionArray[3]; 
+			adjacentPositions[1]=positionArray[6]; 
+		}
+		else if(findpos(actuelposition,possibleposition[5])){
+			adjacentPositions[0]=positionArray[3]; 
+			adjacentPositions[1]=positionArray[7]; 
+		}
+		else if(findpos(actuelposition,possibleposition[6])){
+			adjacentPositions[0]=positionArray[4]; ;
+			adjacentPositions[1]=positionArray[9]; 
+			adjacentPositions[2]=positionArray[26]; 
+		}
+		else if(findpos(actuelposition,possibleposition[7])){
+			adjacentPositions[0]=positionArray[5]; 
+			adjacentPositions[1]=positionArray[8]; 
+		}
+		else if(findpos(actuelposition,possibleposition[8])){
+			adjacentPositions[0]=positionArray[7]; 
+			adjacentPositions[1]=positionArray[9]; 
+		}
+		else if(findpos(actuelposition,possibleposition[9])){
+			adjacentPositions[0]=positionArray[6]; 
+			adjacentPositions[1]=positionArray[8]; 
+			adjacentPositions[2]=positionArray[10]; 
+			adjacentPositions[3]=positionArray[38]; 
+		}
+		else if(findpos(actuelposition,possibleposition[10])){
+			adjacentPositions[0]=positionArray[9]; 
+			adjacentPositions[1]=positionArray[11]; 
+			adjacentPositions[2]=positionArray[45]; 
+		}
+		else if(findpos(actuelposition,possibleposition[11])){
+			adjacentPositions[0]=positionArray[10]; 
+			adjacentPositions[1]=positionArray[12]; 
+			adjacentPositions[2]=positionArray[13]; 
+		}
+		else if(findpos(actuelposition,possibleposition[12])){
+			adjacentPositions[0]=positionArray[11]; 
+			adjacentPositions[1]=positionArray[14]; 
+		}
+		else if(findpos(actuelposition,possibleposition[13])){
+			adjacentPositions[0]=positionArray[11]; 
+			adjacentPositions[1]=positionArray[14]; 
+			adjacentPositions[2]=positionArray[16]; 
+			adjacentPositions[3]=positionArray[61]; 
+		}
+		else if(findpos(actuelposition,possibleposition[14])){
+			adjacentPositions[0]=positionArray[12]; 
+			adjacentPositions[1]=positionArray[13]; 
+			adjacentPositions[2]=positionArray[15]; 
+		}
+		else if(findpos(actuelposition,possibleposition[15])){
+			adjacentPositions[0]=positionArray[14]; 
+			adjacentPositions[1]=positionArray[16]; 
+		}
+		else if(findpos(actuelposition,possibleposition[16])){
+			adjacentPositions[0]=positionArray[13]; 
+			adjacentPositions[1]=positionArray[15]; 
+			adjacentPositions[2]=positionArray[62]; 
+		}
+		else if(findpos(actuelposition,possibleposition[17])){
+			adjacentPositions[0]=positionArray[0]; 
+			adjacentPositions[1]=positionArray[25]; 
+		}
+		else if(findpos(actuelposition,possibleposition[18])){
+			adjacentPositions[0]=positionArray[19]; 
+			adjacentPositions[1]=positionArray[24];                 
+		}
+		else if(findpos(actuelposition,possibleposition[19])){
+			adjacentPositions[0]=positionArray[0]; 
+			adjacentPositions[1]=positionArray[18]; 
+			adjacentPositions[2]=positionArray[20]; 
+		}
+		else if(findpos(actuelposition,possibleposition[20])){
+			adjacentPositions[0]=positionArray[19]; 
+			adjacentPositions[1]=positionArray[21]; 
+		}
+		else if(findpos(actuelposition,possibleposition[21])){
+			adjacentPositions[0]=positionArray[20]; 
+			adjacentPositions[1]=positionArray[22]; 
+		}
+		else if(findpos(actuelposition,possibleposition[22])){
+			adjacentPositions[0]=positionArray[21]; 
+			adjacentPositions[1]=positionArray[23]; 
+			adjacentPositions[2]=positionArray[31]; 
+		}
+		else if(findpos(actuelposition,possibleposition[23])){
+			adjacentPositions[0]=positionArray[22];
+			adjacentPositions[1]=positionArray[30]; 
+		}
+		else if(findpos(actuelposition,possibleposition[24])){
+			adjacentPositions[0]=positionArray[18]; 
+			adjacentPositions[1]=positionArray[29]; 
+		}
+		else if(findpos(actuelposition,possibleposition[25])){
+			adjacentPositions[0]=positionArray[17]; 
+			adjacentPositions[1]=positionArray[26]; 
+		}
+		else if(findpos(actuelposition,possibleposition[26])){
+			adjacentPositions[0]=positionArray[6]; 
+			adjacentPositions[1]=positionArray[25]; 
+			adjacentPositions[2]=positionArray[27]; 
+		}
+		else if(findpos(actuelposition,possibleposition[27])){
+			adjacentPositions[0]=positionArray[26]; 
+			adjacentPositions[1]=positionArray[28]; 
+			adjacentPositions[2]=positionArray[37]; 
+		}
+		else if(findpos(actuelposition,possibleposition[28])){
+			adjacentPositions[0]=positionArray[27]; 
+			adjacentPositions[1]=positionArray[29]; 
+			adjacentPositions[2]=positionArray[36]; 
+		}
+		else if(findpos(actuelposition,possibleposition[29])){
+			adjacentPositions[0]=positionArray[24]; 
+			adjacentPositions[1]=positionArray[28]; 
+			adjacentPositions[2]=positionArray[30]; 
+		}
+		else if(findpos(actuelposition,possibleposition[30])){
+			adjacentPositions[0]=positionArray[23]; 
+			adjacentPositions[1]=positionArray[29]; 
+			adjacentPositions[2]=positionArray[34]; 
+		}
+		else if(findpos(actuelposition,possibleposition[31])){
+			adjacentPositions[0]=positionArray[22]; 
+			adjacentPositions[1]=positionArray[32]; 
+		}
+		else if(findpos(actuelposition,possibleposition[32])){
+			adjacentPositions[0]=positionArray[31]; 
+			adjacentPositions[1]=positionArray[33]; 
+		}
+		else if(findpos(actuelposition,possibleposition[33])){
+			adjacentPositions[0]=positionArray[32]; 
+			adjacentPositions[1]=positionArray[34]; 
+		}
+		else if(findpos(actuelposition,possibleposition[34])){
+			adjacentPositions[0]=positionArray[30]; 
+			adjacentPositions[1]=positionArray[33]; 
+			adjacentPositions[2]=positionArray[35]; 
+			adjacentPositions[3]=positionArray[42]; 
+
+		}
+		else if(findpos(actuelposition,possibleposition[35])){
+			adjacentPositions[0]=positionArray[34]; 
+			adjacentPositions[1]=positionArray[36]; 
+			adjacentPositions[2]=positionArray[41]; 
+		}
+		else if(findpos(actuelposition,possibleposition[36])){
+			adjacentPositions[0]=positionArray[28]; 
+			adjacentPositions[1]=positionArray[35]; 
+		}
+		else if(findpos(actuelposition,possibleposition[37])){
+			adjacentPositions[0]=positionArray[27]; 
+			adjacentPositions[1]=positionArray[38]; 
+		}
+		else if(findpos(actuelposition,possibleposition[38])){
+			adjacentPositions[0]=positionArray[9]; 
+			adjacentPositions[1]=positionArray[37]; 
+			adjacentPositions[2]=positionArray[39]; 
+		}
+		else if(findpos(actuelposition,possibleposition[39])){
+			adjacentPositions[0]=positionArray[38]; 
+			adjacentPositions[1]=positionArray[40]; 
+			adjacentPositions[2]=positionArray[45]; 
+		}
+		else if(findpos(actuelposition,possibleposition[40])){
+			adjacentPositions[0]=positionArray[39]; 
+			adjacentPositions[1]=positionArray[41]; 
+		}
+		else if(findpos(actuelposition,possibleposition[41])){
+			adjacentPositions[0]=positionArray[35]; 
+			adjacentPositions[1]=positionArray[43]; 
+			adjacentPositions[2]=positionArray[40];  
+		}
+		else if(findpos(actuelposition,possibleposition[42])){
+			adjacentPositions[0]=positionArray[34]; 
+			adjacentPositions[1]=positionArray[43]; 
+			adjacentPositions[2]=positionArray[54]; 
+		}
+		else if(findpos(actuelposition,possibleposition[43])){
+			adjacentPositions[0]=positionArray[41]; 
+			adjacentPositions[1]=positionArray[46]; 
+			adjacentPositions[2]=positionArray[42]; 
+		}
+		else if(findpos(actuelposition,possibleposition[44])){
+			adjacentPositions[0]=positionArray[40]; 
+			adjacentPositions[1]=positionArray[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[45])){
+			adjacentPositions[0]=positionArray[10]; 
+			adjacentPositions[1]=positionArray[39]; 
+			adjacentPositions[2]=positionArray[49]; 
+		}
+		else if(findpos(actuelposition,possibleposition[46])){
+			adjacentPositions[0]=positionArray[43]; 
+			adjacentPositions[1]=positionArray[47]; 
+		}
+		else if(findpos(actuelposition,possibleposition[47])){
+			adjacentPositions[0]=positionArray[46]; 
+			adjacentPositions[1]=positionArray[52]; 
+			adjacentPositions[2]=positionArray[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[48])){
+			adjacentPositions[0]=positionArray[49]; 
+			adjacentPositions[1]=positionArray[51]; 
+			adjacentPositions[2]=positionArray[66]; 
+		}
+		else if(findpos(actuelposition,possibleposition[49])){
+			adjacentPositions[0]=positionArray[45]; 
+			adjacentPositions[1]=positionArray[48]; 
+		}
+		else if(findpos(actuelposition,possibleposition[50])){
+			adjacentPositions[0]=positionArray[51]; 
+			adjacentPositions[1]=positionArray[61]; 
+		}
+		else if(findpos(actuelposition,possibleposition[51])){
+			adjacentPositions[0]=positionArray[48]; 
+			adjacentPositions[1]=positionArray[50]; 
+		}
+		else if(findpos(actuelposition,possibleposition[52])){
+			adjacentPositions[0]=positionArray[47]; 
+			adjacentPositions[1]=positionArray[53]; 
+		}
+		else if(findpos(actuelposition,possibleposition[53])){
+			adjacentPositions[0]=positionArray[52]; 
+			adjacentPositions[1]=positionArray[58]; 
+		}
+		else if(findpos(actuelposition,possibleposition[54])){
+			adjacentPositions[0]=positionArray[42]; 
+			adjacentPositions[1]=positionArray[55]; 
+			adjacentPositions[2]=positionArray[57]; 
+		}
+		else if(findpos(actuelposition,possibleposition[55])){
+			adjacentPositions[0]=positionArray[54]; 
+			adjacentPositions[1]=positionArray[56]; 
+		}
+		else if(findpos(actuelposition,possibleposition[56])){
+			adjacentPositions[0]=positionArray[55]; 
+			adjacentPositions[1]=positionArray[57]; 
+			adjacentPositions[2]=positionArray[65]; 
+		}
+		else if(findpos(actuelposition,possibleposition[57])){
+			adjacentPositions[0]=positionArray[54]; 
+			adjacentPositions[1]=positionArray[56]; 
+			adjacentPositions[2]=positionArray[58]; 
+			adjacentPositions[3]=positionArray[64]; 
+
+		}
+		else if(findpos(actuelposition,possibleposition[58])){
+			adjacentPositions[0]=positionArray[53]; 
+			adjacentPositions[1]=positionArray[57]; 
+			adjacentPositions[2]=positionArray[59]; 
+		}
+		else if(findpos(actuelposition,possibleposition[59])){
+			adjacentPositions[0]=positionArray[58]; 
+			adjacentPositions[1]=positionArray[60]; 
+			adjacentPositions[2]=positionArray[63]; 
+		}
+		else if(findpos(actuelposition,possibleposition[60])){
+			adjacentPositions[0]=positionArray[59]; 
+			adjacentPositions[1]=positionArray[61]; 
+			adjacentPositions[2]=positionArray[62]; 
+		}
+		else if(findpos(actuelposition,possibleposition[61])){
+			adjacentPositions[0]=positionArray[13]; 
+			adjacentPositions[1]=positionArray[50]; 
+			adjacentPositions[2]=positionArray[60]; 
+		}
+		else if(findpos(actuelposition,possibleposition[62])){
+			adjacentPositions[0]=positionArray[16]; 
+			adjacentPositions[1]=positionArray[60]; 
+		}
+		else if(findpos(actuelposition,possibleposition[63])){
+			adjacentPositions[0]=positionArray[59]; 
+			adjacentPositions[1]=positionArray[64]; 
+		}
+		else if(findpos(actuelposition,possibleposition[64])){
+			adjacentPositions[0]=positionArray[57]; 
+			adjacentPositions[1]=positionArray[63]; 
+			adjacentPositions[2]=positionArray[65]; 
+		}
+		else if(findpos(actuelposition,possibleposition[65])){
+			adjacentPositions[0]=positionArray[56]; 
+			adjacentPositions[1]=positionArray[64]; 
+		}
+		else if(findpos(actuelposition,possibleposition[66])){
+			adjacentPositions[0]=positionArray[47]; 
+			adjacentPositions[1]=positionArray[48]; 
+		}
+	}
+
+
+}

Modified: code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.h	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanGhost.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -35,8 +35,18 @@
 
 #include "worldentities/ControllableEntity.h"
 
+#include "Pacman.h"
+
 namespace orxonox {
 
+    extern Vector3 possibleposition[67];
+
+    extern bool findpos(Vector3 one, Vector3 other);
+
+
+
+
+
     class _OrxonoxExport PacmanGhost : public ControllableEntity
     {
         public:
@@ -43,21 +53,20 @@
             PacmanGhost(Context* context);
             virtual ~PacmanGhost();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an AutonomousDrone through XML.
-            virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating an AutonomousDrone through XML.
+            //virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
 
-            void move(float dt, Vector3 actuelposition, Vector3 velocity);
+            virtual void move(float dt, Vector3 actuelposition, Vector3 velocity);
             
-            void resetGhost();
+            virtual void resetGhost();
 
-            void changewith(PacmanGhost* otherghost);
-            void levelupvelo();
-
-            bool findpos(Vector3 one, Vector3 other);      
-            void changemovability();
+            virtual void changewith(PacmanGhost* otherghost);
+            virtual void levelupvelo();
+      
+            virtual void changemovability();
             bool dontmove = false;
 
-        private:
+       
             int decision = 0; 
             Vector3 resetposition = Vector3(0,10,15);
             Vector3 velocity;
@@ -69,12 +78,51 @@
             int target_z = 0;
             bool lockmove = false;
 
-            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);
+
+        Vector3 getPlayerPos();
+
+        Vector3 playerPos;
+
+        Vector3 lastPlayerPassedPoint;
+
+        Vector3 pointInFrontOfPlayer;
+        
+        /*
+    public: //HACK
+    */
+
+
+    struct graphVertex;
+    void findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]);
+    void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor);
+    void findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3=Vector3(0,0,0));
+    int graphDistance(Vector3 start, Vector3 goal);
+
+    graphVertex* findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2=Vector3(0,0,0));
+    Vector3 getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1=Vector3(0,0,0));
+
+
+
+    Vector3 getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE);
+    int findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos);
+    Vector3 diffVector (Vector3 start, Vector3 goal);
+
+    bool playerFindPos(Vector3 one, Vector3 other);
+
+    bool jeanfindpos(Vector3 one, Vector3 other);
+
+    void setNewTargetGhost(Vector3 goalToGo);
+
+
+
+
+
+    void findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]);
+
+    Vector3 frontPosition();
+
     };
 
 }
 
-#endif
+#endif
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.cpp (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanLaser.cpp)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.cpp	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.cpp	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,51 @@
+#include "PacmanLaser.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+    RegisterClass(PacmanLaser);
+
+    /**
+    @brief
+        Constructor. Registers the object and initializes some default values.
+    @param creator
+        The creator of this object.
+    */
+    PacmanLaser::PacmanLaser(Context* context) : ControllableEntity(context)
+    {
+        RegisterObject(PacmanLaser);
+        this->setCollisionType(CollisionType::None);
+    }
+
+    /**
+    @brief
+        Destructor. Destroys controller, if present.
+    */
+    PacmanLaser::~PacmanLaser()
+    {
+        // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
+    }
+
+    /**
+    @brief
+        Method for creating a AutonomousDrone through XML.
+    */
+    void PacmanLaser::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanLaser, XMLPort, xmlelement, mode);
+    }
+
+
+    void PacmanLaser::tick(float dt)
+    {
+        SUPER(PacmanLaser, tick, dt);
+    }
+
+    void PacmanLaser::resetPacmanLaser(){
+    	resetposition = this->getPosition();
+        resetposition.y = -20000;
+        this->setPosition(resetposition);
+    }
+}
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanLaser.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanLaser.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,31 @@
+#ifndef _PacmanLaser_H__
+#define _PacmanLaser_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/XMLPort.h"
+
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox {
+
+    class _OrxonoxExport PacmanLaser : public ControllableEntity
+    {
+        public:
+            PacmanLaser(Context* context);
+            virtual ~PacmanLaser();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an AutonomousDrone through XML.
+            virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
+            void resetPacmanLaser();
+            
+
+        private:
+            
+            Vector3 resetposition;
+    
+    };
+
+}
+
+#endif

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.cc (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.cc	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,112 @@
+	
+#include "PacmanPink.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+	
+namespace orxonox{
+
+	RegisterClass(PacmanPink);
+
+		PacmanPink::PacmanPink(Context* context) : PacmanGhost(context){
+
+        RegisterObject(PacmanPink);
+
+        this->target_x=0;
+        this->target_z=15;
+        this->lastPlayerPassedPoint=Vector3(0,0,0); 
+        this->pointInFrontOfPlayer=Vector3(0,0,0);
+          
+    }
+
+    /**
+    @brief
+        Method for creating a ghost through XML.
+    */
+    void PacmanPink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanPink, XMLPort, xmlelement, mode);
+    }
+
+
+    void PacmanPink::tick(float dt)
+    {
+        SUPER(PacmanGhost, tick, dt);
+        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];        
+                }
+            }
+
+        this->pointInFrontOfPlayer=frontPosition(); 
+        Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
+        
+        //Stop, if target arrived
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
+                 this->ismoving = false;
+        }
+
+        //Move, if ghost hasn't arrived yet
+        if(this->ismoving){
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+                move(dt, actuelposition, velocity);
+            }    
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+                move(dt, actuelposition, velocity);
+            }
+        }
+        else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){
+            //as long as the player has not started the game,
+            //i.e. lastPlayerPastPoint is (0,0,0), pink pacman
+            //cannot possibly move, because it needs the position
+            //of the player to move accordingly
+
+            this->ismoving=false;
+        }
+        else if(this->pointInFrontOfPlayer==Vector3(0,0,0)){
+
+            Vector3 pinkPos=Vector3(this->target_x, 10, this->target_z);
+            setNewTargetGhost(getShortestPath(pinkPos, this->lastPlayerPassedPoint));
+
+        }
+        //Check on which position the ghost has arrived and set new target
+         else{
+            while(lockmove){};
+            lockmove = true;
+            nextMove(pinkPos, pointInFrontOfPlayer, lastPlayerPassedPoint);
+            lockmove=false;
+        }
+	}
+
+
+
+    void PacmanPink::nextMove( Vector3 pinkPosP, Vector3 playerPos, Vector3 pointToAvoidP11){
+    
+        Vector3 nextTarget;
+
+        if(playerPos==pointToAvoidP11){ //SIGSEV if playerPos==pointToAvoidP11 otherwise
+            nextTarget = getShortestPath(pinkPosP, playerPos);
+        }
+        else if(playerPos==Vector3(-70,10,-35)){
+            
+        nextTarget=getShortestPath(pinkPosP, Vector3(-70,10,-35));
+        
+        }
+        else{   
+        
+        nextTarget = getShortestPath(pinkPosP, playerPos, pointToAvoidP11);
+        }
+        
+       setNewTargetGhost(nextTarget);
+    }
+
+}
+
+	
+
+	

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanPink.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,27 @@
+#ifndef _PacmanPink_H__
+#define _PacmanPink_H__
+
+
+#include "PacmanGhost.h"
+
+
+namespace orxonox {
+
+	class _OrxonoxExport PacmanPink : public PacmanGhost{
+
+		public :
+			PacmanPink(Context* context);
+
+			virtual void tick(float dt) override; //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+  			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+        Vector3 pinkPos;
+
+        void nextMove(Vector3 pinkPosP, Vector3 playerPos, Vector3 pointToAvoidP11=Vector3(0,0,0));
+
+	};
+
+}
+
+#endif 
\ No newline at end of file

Modified: code/branches/Presentation_FS19/src/modules/pacman/PacmanPointSphere.cc
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanPointSphere.cc	2019-05-22 11:49:19 UTC (rev 12407)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanPointSphere.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -81,7 +81,6 @@
       } 
       return false;
     }
-
     //Reset position
     void PacmanPointSphere::resetPacmanPointSphere(){
         resetposition = this->getPosition();

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.cc (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.cc)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.cc	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,353 @@
+#include "PacmanRandom.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+
+
+
+namespace orxonox {
+
+
+    RegisterClass(PacmanRandom);
+
+
+
+    PacmanRandom::PacmanRandom(Context* context) : PacmanGhost(context){
+
+        RegisterObject(PacmanRandom);
+        
+        
+    }
+
+        /**
+    @brief
+        Method for creating a ghost through XML.
+    */
+    void PacmanRandom::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanRandom, XMLPort, xmlelement, mode);
+    }
+
+    void PacmanRandom::tick(float dt)
+    {
+        SUPER(PacmanGhost, tick, dt);
+
+        this->actuelposition = this->getPosition();
+        
+        //Stop, if target arrived
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
+                 this->ismoving = false;
+        }
+
+        //Move, if ghost hasn't arrived yet
+        if(this->ismoving){
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+                move(dt, actuelposition, velocity);
+            }    
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+                move(dt, actuelposition, velocity);
+            }
+        }
+        //Check on which position the ghost has arrived and set new target
+         else{
+            while(lockmove){};
+            lockmove = true;
+
+            if(findpos(actuelposition,possibleposition[0])){
+                setnewTarget(1,17,19);
+            }
+            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,9,26);
+            }
+            else if(findpos(actuelposition,possibleposition[7])){
+                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);
+            }
+            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);
+            }
+            else if(findpos(actuelposition,possibleposition[35])){
+                setnewTarget(34,36,41);
+            }
+            else if(findpos(actuelposition,possibleposition[36])){
+                setnewTarget(28,35);
+            }
+            else if(findpos(actuelposition,possibleposition[37])){
+                setnewTarget(27,38);
+            }
+            else if(findpos(actuelposition,possibleposition[38])){
+                setnewTarget(9,37,39);
+            }
+            else if(findpos(actuelposition,possibleposition[39])){
+                setnewTarget(38,40,45);
+            }
+            else if(findpos(actuelposition,possibleposition[40])){
+                setnewTarget(39,41); //Shouldn't be able to return in center
+            }
+            else if(findpos(actuelposition,possibleposition[41])){
+                setnewTarget(35,43);
+            }
+            else if(findpos(actuelposition,possibleposition[42])){
+                setnewTarget(34,43,54);
+            }
+            else if(findpos(actuelposition,possibleposition[43])){
+                setnewTarget(41,46);
+            }
+            else if(findpos(actuelposition,possibleposition[44])){
+                setnewTarget(40,66);
+            }
+            else if(findpos(actuelposition,possibleposition[45])){
+                setnewTarget(10,39,49);
+            }
+            else if(findpos(actuelposition,possibleposition[46])){
+                setnewTarget(43,47);
+            }
+            else if(findpos(actuelposition,possibleposition[47])){
+                setnewTarget(46,52,66);
+            }
+            else if(findpos(actuelposition,possibleposition[48])){
+                setnewTarget(49,51,66);
+            }
+            else if(findpos(actuelposition,possibleposition[49])){
+                setnewTarget(45,48);
+            }
+            else if(findpos(actuelposition,possibleposition[50])){
+                setnewTarget(51,61);
+            }
+            else if(findpos(actuelposition,possibleposition[51])){
+                setnewTarget(48,50);
+            }
+            else if(findpos(actuelposition,possibleposition[52])){
+                setnewTarget(47,53);
+            }
+            else if(findpos(actuelposition,possibleposition[53])){
+                setnewTarget(52,58);
+            }
+            else if(findpos(actuelposition,possibleposition[54])){
+                setnewTarget(42,55,57);
+            }
+            else if(findpos(actuelposition,possibleposition[55])){
+                setnewTarget(54,56);
+            }
+            else if(findpos(actuelposition,possibleposition[56])){
+                setnewTarget(55,57,65);
+            }
+            else if(findpos(actuelposition,possibleposition[57])){
+                setnewTarget(54,56,58,64);
+            }
+            else if(findpos(actuelposition,possibleposition[58])){
+                setnewTarget(53,57,59);
+            }
+            else if(findpos(actuelposition,possibleposition[59])){
+                setnewTarget(58,59,63);
+            }
+            else if(findpos(actuelposition,possibleposition[60])){
+                setnewTarget(59,61,62);
+            }
+            else if(findpos(actuelposition,possibleposition[61])){
+                setnewTarget(13,50,60);
+            }
+            else if(findpos(actuelposition,possibleposition[62])){
+                setnewTarget(16,60);
+            }
+            else if(findpos(actuelposition,possibleposition[63])){
+                setnewTarget(59,64);
+            }
+            else if(findpos(actuelposition,possibleposition[64])){
+                setnewTarget(57,63,65);
+            }
+            else if(findpos(actuelposition,possibleposition[65])){
+                setnewTarget(56,64);
+            }
+            else if(findpos(actuelposition,possibleposition[66])){
+                setnewTarget(47,48);
+            }
+
+            else{
+                this->resetGhost(); //Shouldn't happen...
+            } //End of Position table
+                lockmove = false;  //never forget this one !!!!
+            }
+        
+    }
+
+    void PacmanRandom::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;
+            }
+    }
+
+    //Random choice of new target
+    void PacmanRandom::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;  
+            }
+            
+    }
+
+    //Random choice of new target
+    void PacmanRandom::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;    
+            }
+            
+    }
+
+    //Random choice of new target
+    void PacmanRandom::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;    
+            }
+            
+    }
+
+
+}
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanRandom.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,28 @@
+#ifndef _PacmanRandom_H__
+#define _PacmanRandom_H__
+
+#include "PacmanGhost.h"
+
+namespace orxonox {
+
+  class _OrxonoxExport PacmanRandom : public PacmanGhost{
+    //This class is not used anymore in the game, given that all 4 Ghosts now have
+    //their own behavior. But it could maybe still be useful.
+
+  		public:
+  			PacmanRandom(Context* context);
+
+  			virtual void tick(float dt) override; //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+  			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+  			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);
+  };
+
+
+}
+
+
+#endif 
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.cc (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.cc	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.cc	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,111 @@
+#include "PacmanRed.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+
+
+	namespace orxonox{
+
+		RegisterClass(PacmanRed);
+
+		PacmanRed::PacmanRed(Context* context) : PacmanGhost(context){
+
+        RegisterObject(PacmanRed);
+        this->target_x=0;
+        this->target_z=15;
+        this->lastPlayerPassedPoint=Vector3(0,0,0); 
+        this->isNearPlayer=false;
+          
+    }
+
+
+    /**
+    @brief
+        Method for creating a ghost through XML.
+    */
+    void PacmanRed::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanRed, XMLPort, xmlelement, mode);
+    }
+
+    void PacmanRed::tick(float dt)
+    {
+        SUPER(PacmanGhost, tick, dt);
+
+        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
+        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
+            
+                 this->ismoving = false;
+        }
+
+        //Move, if ghost hasn't arrived yet
+        if(this->ismoving){
+            
+            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
+                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
+                move(dt, actuelposition, velocity);
+            }    
+            if(!(abs(this->actuelposition.x-target_x)<0.5)){
+                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
+                move(dt, actuelposition, velocity);
+            }
+        
+        }
+        else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){
+            //as long as the player has not started the game,
+            //i.e. lastPlayerPastPoint is (0,0,0), red pacman
+            //cannot possibly move, because it needs the position
+            //of the player to move accordingly
+
+            this->ismoving=false;
+        }
+
+        //Check on which position the ghost has arrived and set new target
+        else{
+
+            while(lockmove){};
+            lockmove = true;
+
+        	//do red behavior
+            //Use target_x and target_z for position of red pacman
+
+            Vector3 redPos=Vector3(this->target_x, 10, this->target_z);
+            this->pointInFrontOfPlayer=frontPosition(); 
+
+            if(!findpos(this->actuelposition, lastPlayerPassedPoint)){
+                
+            nextMove(redPos, lastPlayerPassedPoint);
+            }
+            else if(findpos(this->actuelposition, lastPlayerPassedPoint)){// red pacman is at lastPlayerPassedPoint
+
+            nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer); 
+            }
+
+            lockmove=false; //NEVER FORGET THIS ONE !!!!!!!
+        }
+        
+    }
+
+
+	void PacmanRed::nextMove( Vector3 redPosP, Vector3 playerPos){
+	
+        Vector3 nextTarget;
+
+        if(redPosP!=playerPos){
+	   nextTarget = getShortestPath(redPosP, playerPos);
+       setNewTargetGhost(nextTarget);
+        }
+	}
+
+}
\ No newline at end of file

Copied: code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.h (from rev 12407, code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h)
===================================================================
--- code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.h	                        (rev 0)
+++ code/branches/Presentation_FS19/src/modules/pacman/PacmanRed.h	2019-05-22 11:58:40 UTC (rev 12408)
@@ -0,0 +1,31 @@
+#ifndef _PacmanRed_H__
+#define _PacmanRed_H__
+
+
+#include "PacmanGhost.h"
+
+
+namespace orxonox {
+
+	class _OrxonoxExport PacmanRed : public PacmanGhost{
+
+		public :
+			PacmanRed(Context* context);
+
+			virtual void tick(float dt) override; //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+  			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+  			void nextMove(Vector3 playerPos, Vector3 redPos);
+
+  			void mainBehaviourRed();
+
+  			bool isNearPlayer;
+
+
+
+	};
+
+}
+
+#endif 
\ No newline at end of file



More information about the Orxonox-commit mailing list