[Orxonox-commit 7711] r12304 - code/branches/3DPacman_FS19/src/modules/pacman
peterf at orxonox.net
peterf at orxonox.net
Thu Apr 18 13:26:11 CEST 2019
Author: peterf
Date: 2019-04-18 13:26:10 +0200 (Thu, 18 Apr 2019)
New Revision: 12304
Added:
code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h
code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.h
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.h
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h
Removed:
code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.h
Modified:
code/branches/3DPacman_FS19/src/modules/pacman/CMakeLists.txt
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.cc
code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.cc
Log:
added several pacmans
Modified: code/branches/3DPacman_FS19/src/modules/pacman/CMakeLists.txt
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/CMakeLists.txt 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/CMakeLists.txt 2019-04-18 11:26:10 UTC (rev 12304)
@@ -5,8 +5,9 @@
PacmanPointSphere.cc
PacmanPointAfraid.cc
PacmanHUDinfo.cc
+ PacmanRandom.cc
+ PacmanRed.cc
getShortestPath.cc
- PacmanRandom.cc
)
ORXONOX_ADD_LIBRARY(pacman
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,211 @@
+
+#include "PacmanBrown.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+
+ namespace orxonox{
+
+ RegisterClass(PacmanBrown);
+
+ PacmanBrown::PacmanBrown(Context* context) : PacmanGhost(context){
+
+ RegisterObject(PacmanBrown);
+
+ }
+
+ /**
+ @brief
+ Method for creating a ghost through XML.
+ */
+ void PacmanBrown::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PacmanBrown, XMLPort, xmlelement, mode);
+ }
+
+
+
+ void PacmanBrown::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;
+
+ //do brown behavior
+ //put everything needed here
+
+ if((this->fleeing==true)&&(this->actuelposition!=(-215,10,-195))){
+ //if fleeing, then go to corner map if not already there
+ fleeMode();
+ }
+ else{ // else go next to pacman
+
+ if(absoluteDistance(this->pos, player.pos)<10){//no idea if 10 ok
+ //if near player, flee away
+ fleemode();
+ }
+ else{ //go to neighboor of player nearest to brown pacman
+
+ //first find nearest neighboor point of player to brown pacman
+ //we can maybe call getShortestPath recursively to do so
+
+player.pos.nearestneighboor=findPlayerNeighboorNearestToPacman(player.neighboors);
+//btw the array player.neighboor can be defined with a big list as we
+//already did several times for similar things
+
+ Vector3 nextMove = getShortestPath(this->actuelposition, player.pos.nearestneighboor);
+ setNewTargetBrown(nextMove);
+ }
+
+ }
+
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+
+ int graphDistance(Vector3 start, Vector3 goal){
+
+ Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
+
+ return differenceVector.x+differenceVector.z;
+ }
+
+ void setNewTargetBrown(Vector3 goalToGo){
+
+ this->target_x = goalToGo.x;
+ this->target_z = goalToGo.z;
+ this->ismoving = true;
+ }
+
+
+
+ int absoluteDistance(Vector3 pos1, Vector3 pos2){
+
+
+ Vector3 diffVector;
+ diffVector.x=pos2-pos1;
+ diffVector.y=pos2-pos1; //should always be 0
+ diffVector.z=pos2-pos1;
+ int result = sqrt(diffVector.x²+diffVector.z²);
+ return result;
+ }
+
+
+ void fleeMode(){ //flees to corner of the map
+
+ Vector3 cornerPos = Vector3(-215,10,-195); //let's take this. We can still change
+ Vector3 nextMove = getShortestPath(this->actuelposition, cornerPos);
+ setNewTargetBrown(nextMove);
+
+ /*//while(this->actuelposition!=cornerPos){
+
+ continue moving and each time find next point to go until
+ we reach the corner
+ }*/
+ }
+
+
+ Vector3 goAdjacentOfPlayer(Vector neighboorsOfPlayer[]){
+ //find ,nearest to brown, player neighboor
+
+ int besTotDist=-1;
+ Vector3 curPos=this->pos;
+ Vector3 predPos;
+ Vector3 chosenNeighbor;
+
+ for(int i=0; i < 4; i++){
+ int totDist=0;
+
+ if(neighboorsOfPlayer[i]!=0){
+ while(curPos!=neighboorsOfPlayer[i]){
+
+ predPos=curPos;
+ curPos = getShortestPath(curPos, neighboorsOfPlayer[i]);
+ totDist+=graphDistance(curPos,predPos);
+
+ }
+ }
+
+ if(besTotDist==-1){
+ besTotDist=totDist;
+ chosenNeighbor=neighboorsOfPlayer[i];
+ }
+ else if(besTotDist>totDist){
+ besTotDist=totDist;
+ chosenNeighbor=neighboorsOfPlayer[i];
+ }
+ }
+ return chosenNeighbor;
+
+ }
+
+
+ Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray[]){
+ //uh, i think it does the same think as the function above
+
+ Vector3 nextMove;
+ int distCost=-1;
+ for(int i=0; i < 4; i++){
+ int totDist=0;
+ Vector3 newCandidate=this->actuelposition;
+ Vector3 predPos;
+
+ if(neighboorArray[i]!=NULL){
+ while(nextMove!=neighboorArray[i]){
+ predPos=newCandidate;
+ newCandidate=getShortestPath(newCandidate, neighboorArray[i]);
+ totDist+=graphDistance(predPos, newCandidate);
+ }
+
+ if(distCost==-1){
+ distCost=totDist;
+ nextMove=gneighboorArray[i];
+ }
+ else if(totDist<distCost){
+ distCost=totDist;
+ nextMove=neighboorArray[i];
+ }
+ }
+ }
+ return nextMove;
+
+ }
+
+}
+
+
+
+
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanBrown.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,40 @@
+#ifndef _PacmanBrown_H__
+#define _PacmanBrown_H__
+
+
+#include "PacmanGhost.h"
+//#include "getShortestPath.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(Vector neighboorsOfPlayer[]);
+ //they both do the same -_-
+ Vector3 findPlayerNeighboorNearestToPacman(Vector3 neighboorArray);
+
+
+ };
+
+}
+
+#endif
\ No newline at end of file
Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -33,6 +33,29 @@
namespace orxonox
{
+
+ //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;
+ }
+
+ //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
+
RegisterClass(PacmanGhost);
/**
@@ -46,6 +69,7 @@
RegisterObject(PacmanGhost);
this->velocity = Vector3(0, 0, 0);
+
this->setCollisionType(CollisionType::Dynamic);
this->actuelposition = this->getPosition();
@@ -71,74 +95,11 @@
@brief
Method for creating a ghost through XML.
*/
- void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ 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*/
-
- /**
- @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);
-
- 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);
- }
- }
-
- }
-
-
- //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;
- }
- }
-
//Change this with other ghost
void PacmanGhost::changewith(PacmanGhost* otherghost){
@@ -163,7 +124,7 @@
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((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)));
}
@@ -170,7 +131,8 @@
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((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)));
}
@@ -177,16 +139,11 @@
else{
this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));
}
+ }
}
}
- //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;
- }
-
//Change ability to move
void PacmanGhost::changemovability(){
if(dontmove){
@@ -212,4 +169,17 @@
void PacmanGhost::levelupvelo(){
speed ++;
}
+
+ Vector3 PacmanGhost::setPureArrayPos(Vector3 &posToSet){
+ //given that the position of a pacman is generally not "neat",
+ //we need to set it to the nearest point on the map
+ // if the pacman is not moving anymore, i.e. has reached a point
+ int i=0;
+ while(!(findpos(possibleposition[i], posToSet))){
+ i++;
+ }
+ return possibleposition[i];
+ }
+
+
}
\ No newline at end of file
Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -37,6 +37,19 @@
namespace orxonox {
+ extern Vector3 possibleposition[67];
+
+ extern bool findpos(Vector3 one, Vector3 other);
+
+
+ struct graphVertex;
+ void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]);
+ void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor);
+ graphVertex findNextVertexToConsider(graphVertex[]);
+
+ extern graphVertex listOfVertices[];
+
+
class _OrxonoxExport PacmanGhost : public ControllableEntity
{
public:
@@ -43,21 +56,21 @@
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();
+ virtual void changewith(PacmanGhost* otherghost);
+ virtual void levelupvelo();
- bool findpos(Vector3 one, Vector3 other);
- void changemovability();
+ //bool findpos(Vector3 one, Vector3 other);
+ virtual void changemovability();
bool dontmove = false;
-
+
int decision = 0;
Vector3 resetposition = Vector3(0,10,15);
Vector3 velocity;
@@ -69,27 +82,11 @@
int target_z = 0;
bool lockmove = 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
+ Vector3 getShortestPath(Vector3 start, Vector3 goal);
- private:
- 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 setPureArrayPos(Vector3 &posToSet);
+
+ private:
};
}
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,555 @@
+
+#include "PacmanPink.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+
+namespace orxonox{
+
+ RegisterClass(PacmanPink);
+
+ PacmanPink::PacmanPink(Context* context) : PacmanGhost(context){
+
+ RegisterObject(PacmanPink);
+
+ }
+
+ /**
+ @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();
+
+ //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(player.getPos(), player.lastPassedPoint)){
+ // if player is on a point, for simplicity go to it
+ Vector3 nextMove = getShortestPath(this->actuelposition, player.lastPassedPoint);
+ setNewTargetPink(nextMove);
+ }
+
+ else{ //if player is not on a point either go to next neighboor, or if no
+ //neighboor in player direction available, go to last point passed by player.
+
+ int dir=findPlayerTravDir(player.lastPassedPoint, player.getPos());
+ //not in other sense!
+
+ Vector3[] neighboors;
+ findNeighboor(player.lastPassedPoint, neighboors);
+ //we need to create function that finds neighboors of player last point
+ //We can use and even should use the part of the tick random function
+ // that determines the neighboors. But array neighboor should be in form
+ // south-west-north-east respectively to array index.
+
+ for(int s=0; s < 4; s++){
+ //find next neighboor between player and player.lastPassedPoint
+ if((neighboors[s]!=NULL)&&(s==dir)){
+ if(dir==0){
+ Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
+ setNewTargetPink(nextMove);
+ }
+ else if(dir==1){
+ Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
+ setNewTargetPink(nextMove);
+ }
+ else if(dir==2){
+ Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
+ setNewTargetPink(nextMove);
+ }
+ else{//last is default
+ Vector3 nextMove=getShortestPath(this->actuelposition, neighboors[s]);
+ setNewTargetPink(nextMove);
+ }
+ }
+ else{//if no further point after last player point possible
+ //then simply go to this last point.
+ Vector3 nextMove=getShortestPath(this->actuelposition, player.lastPassedPoint);
+ setNewTargetPink(nextMove);
+ }
+
+ }
+
+ }
+
+ }
+
+
+
+
+ Vector3 diffVector (Vector3 start, Vector3 goal){
+
+ Vector3 result;
+ result.x=goal.x-start.x;
+ result.z=goal.z-start.z;
+ return result;
+ }
+
+ int findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){
+ //return 0 for south, 1 for west, 2 for north, 3 for east
+
+ Vector3 difference = diffVector(playerPosBefore, playerPos);
+
+
+ if((difference.z < 0)&&(difference.z>difference.x)){ //move south
+
+ return 0;
+ }
+ else if((difference.x < 0)&&(difference.x > difference.z )){//move west
+
+ return 1;
+ }
+
+ else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north
+
+ return 2;
+ }
+
+ else if((difference.x>0)&&(difference.x>difference.z)){ //move east
+ return 3;
+
+ }
+
+ else { //default move west
+
+ return 1;
+ }
+
+
+ Vector3 getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){
+ //return the Vector3 point that Pinky should target to
+ //be in front of pacman
+
+ Vector3 listOfNeighboors[4];
+ //first element is south, 2nd west, 3d north, 4th east
+
+ /*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*/
+
+
+
+
+ if(findpos(pacLasVisPos,possibleposition[0])){
+ //no south neighbor
+ listOfNeighboors[1]=possibleposition[19]; // west neighbor
+ listOfNeighboors[2]=possibleposition[17]; //north
+ listOfNeighboors[3]=possibleposition[1]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[1])){
+ listOfNeighboors[1]=possibleposition[0]; // west neighbor
+ listOfNeighboors[2]=possibleposition[2]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[2])){
+ listOfNeighboors[0]=possibleposition[1]; //south
+ listOfNeighboors[1]=possibleposition[3]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[3])){
+ listOfNeighboors[1]=possibleposition[4]; //west
+ listOfNeighboors[2]=possibleposition[5]; //north
+ listOfNeighboors[3]=possibleposition[2]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[4])){
+ listOfNeighboors[2]=possibleposition[6]; //north
+ listOfNeighboors[3]=possibleposition[3]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[5])){
+ listOfNeighboors[0]=possibleposition[3]; //south
+ listOfNeighboors[3]=possibleposition[7]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[6])){
+ listOfNeighboors[0]=possibleposition[4]; //south
+ listOfNeighboors[1]=possibleposition[26]; //west
+ listOfNeighboors[2]=possibleposition[9]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[7])){
+ listOfNeighboors[1]=possibleposition[5]; //west
+ listOfNeighboors[2]=possibleposition[8]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[8])){
+ listOfNeighboors[0]=possibleposition[7]; //south
+ listOfNeighboors[1]=possibleposition[9]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[9])){
+ listOfNeighboors[0]=possibleposition[6]; //south
+ listOfNeighboors[1]=possibleposition[38]; //west
+ listOfNeighboors[2]=possibleposition[10]; //north
+ listOfNeighboors[3]=possibleposition[8]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[10])){
+ listOfNeighboors[0]=possibleposition[9]; //south
+ listOfNeighboors[1]=possibleposition[45]; //west
+ listOfNeighboors[2]=possibleposition[11]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[11])){
+ listOfNeighboors[0]=possibleposition[10]; //south
+ listOfNeighboors[2]=possibleposition[13]; //north
+ listOfNeighboors[3]=possibleposition[12]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[12])){
+ listOfNeighboors[1]=possibleposition[11]; //west
+ listOfNeighboors[2]=possibleposition[14]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[13])){
+ listOfNeighboors[0]=possibleposition[11]; //south
+ listOfNeighboors[1]=possibleposition[61]; //west
+ listOfNeighboors[2]=possibleposition[16]; //north
+ listOfNeighboors[3]=possibleposition[14]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[14])){
+ listOfNeighboors[0]=possibleposition[12]; //south
+ listOfNeighboors[1]=possibleposition[13]; //west
+ listOfNeighboors[2]=possibleposition[15]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[15])){
+ listOfNeighboors[0]=possibleposition[14]; //south
+ listOfNeighboors[1]=possibleposition[16]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[16])){
+ listOfNeighboors[0]=possibleposition[13]; //south
+ listOfNeighboors[1]=possibleposition[62]; //west
+ listOfNeighboors[2]=possibleposition[15]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[17])){
+ listOfNeighboors[0]=possibleposition[0]; //south
+ listOfNeighboors[3]=possibleposition[25]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[18])){
+ listOfNeighboors[0]=possibleposition[19]; //south
+ listOfNeighboors[1]=possibleposition[24]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[19])){
+ listOfNeighboors[1]=possibleposition[20]; //west
+ listOfNeighboors[2]=possibleposition[18]; //north
+ listOfNeighboors[3]=possibleposition[0]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[20])){
+ listOfNeighboors[2]=possibleposition[21]; //north
+ listOfNeighboors[3]=possibleposition[19]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[21])){
+ listOfNeighboors[0]=possibleposition[20]; //south
+ listOfNeighboors[3]=possibleposition[22]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[22])){
+ listOfNeighboors[1]=possibleposition[21]; //west
+ listOfNeighboors[2]=possibleposition[31]; //north
+ listOfNeighboors[3]=possibleposition[23]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[23])){
+ listOfNeighboors[1]=possibleposition[22]; //west
+ listOfNeighboors[2]=possibleposition[30]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[24])){
+ listOfNeighboors[2]=possibleposition[29]; //north
+ listOfNeighboors[3]=possibleposition[18]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[25])){
+ listOfNeighboors[1]=possibleposition[17]; //west
+ listOfNeighboors[2]=possibleposition[26]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[26])){
+ listOfNeighboors[0]=possibleposition[25]; //south
+ listOfNeighboors[1]=possibleposition[27]; //west
+ listOfNeighboors[3]=possibleposition[6]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[27])){
+ listOfNeighboors[1]=possibleposition[28]; //west
+ listOfNeighboors[2]=possibleposition[37]; //north
+ listOfNeighboors[3]=possibleposition[26]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[28])){
+ listOfNeighboors[1]=possibleposition[29]; //west
+ listOfNeighboors[2]=possibleposition[36]; //north
+ listOfNeighboors[3]=possibleposition[27]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[29])){
+ listOfNeighboors[0]=possibleposition[24]; //south
+ listOfNeighboors[1]=possibleposition[30]; //west
+ listOfNeighboors[3]=possibleposition[28]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[30])){
+ listOfNeighboors[0]=possibleposition[23]; //south
+ listOfNeighboors[2]=possibleposition[34]; //north
+ listOfNeighboors[3]=possibleposition[29]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[31])){
+ listOfNeighboors[0]=possibleposition[22]; //south
+ listOfNeighboors[1]=possibleposition[32]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[32])){
+ listOfNeighboors[2]=possibleposition[33]; //north
+ listOfNeighboors[3]=possibleposition[31]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[33])){
+ listOfNeighboors[0]=possibleposition[32]; //south
+ listOfNeighboors[3]=possibleposition[34]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[34])){
+ listOfNeighboors[0]=possibleposition[30]; //south
+ listOfNeighboors[1]=possibleposition[33]; //west
+ listOfNeighboors[2]=possibleposition[92]; //north
+ listOfNeighboors[3]=possibleposition[35]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[35])){
+ listOfNeighboors[1]=possibleposition[34]; //west
+ listOfNeighboors[2]=possibleposition[91]; //north
+ listOfNeighboors[3]=possibleposition[36]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[36])){
+ listOfNeighboors[0]=possibleposition[28]; //south
+ listOfNeighboors[1]=possibleposition[35]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[37])){
+ listOfNeighboors[0]=possibleposition[27]; //south
+ listOfNeighboors[3]=possibleposition[38]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[38])){
+ listOfNeighboors[1]=possibleposition[37]; //west
+ listOfNeighboors[2]=possibleposition[39]; //north
+ listOfNeighboors[3]=possibleposition[9]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[39])){
+ listOfNeighboors[0]=possibleposition[38]; //south
+ listOfNeighboors[1]=possibleposition[40]; //west
+ listOfNeighboors[2]=possibleposition[45]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[40])){
+ listOfNeighboors[1]=possibleposition[41]; //west
+ //Not return in center
+ listOfNeighboors[3]=possibleposition[39]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[41])){
+ listOfNeighboors[0]=possibleposition[35]; //south
+ listOfNeighboors[2]=possibleposition[43]; //north
+ listOfNeighboors[3]=possibleposition[40]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[42])){
+ listOfNeighboors[0]=possibleposition[39]; //south
+ listOfNeighboors[2]=possibleposition[59]; //north
+ listOfNeighboors[3]=possibleposition[43]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[43])){
+ listOfNeighboors[0]=possibleposition[41]; //south
+ listOfNeighboors[1]=possibleposition[42]; //west
+ listOfNeighboors[2]=possibleposition[46]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[44])){
+ listOfNeighboors[0]=possibleposition[40]; //south
+ listOfNeighboors[2]=possibleposition[66]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[45])){
+ listOfNeighboors[0]=possibleposition[39]; //south
+ listOfNeighboors[2]=possibleposition[49]; //north
+ listOfNeighboors[3]=possibleposition[10]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[46])){
+ listOfNeighboors[0]=possibleposition[43]; //south
+ listOfNeighboors[3]=possibleposition[47]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[47])){
+ listOfNeighboors[1]=possibleposition[46]; //west
+ listOfNeighboors[2]=possibleposition[52]; //north
+ listOfNeighboors[3]=possibleposition[66]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[48])){
+ listOfNeighboors[1]=possibleposition[66]; //west
+ listOfNeighboors[2]=possibleposition[51]; //north
+ listOfNeighboors[3]=possibleposition[49]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[49])){
+ listOfNeighboors[0]=possibleposition[45]; //south
+ listOfNeighboors[1]=possibleposition[48]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[50])){
+ listOfNeighboors[1]=possibleposition[51]; //west
+ listOfNeighboors[2]=possibleposition[61]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[51])){
+ listOfNeighboors[0]=possibleposition[48]; //south
+ listOfNeighboors[3]=possibleposition[50]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[52])){
+ listOfNeighboors[0]=possibleposition[47]; //south
+ listOfNeighboors[1]=possibleposition[53]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[53])){
+ listOfNeighboors[2]=possibleposition[58]; //north
+ listOfNeighboors[3]=possibleposition[52]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[54])){
+ listOfNeighboors[0]=possibleposition[42]; //south
+ listOfNeighboors[1]=possibleposition[55]; //west
+ listOfNeighboors[2]=possibleposition[57]; //north
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[55])){
+ listOfNeighboors[2]=possibleposition[56]; //north
+ listOfNeighboors[3]=possibleposition[54]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[56])){
+ listOfNeighboors[0]=possibleposition[55]; //south
+ listOfNeighboors[2]=possibleposition[65]; //north
+ listOfNeighboors[3]=possibleposition[57]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[57])){
+ listOfNeighboors[0]=possibleposition[54]; //south
+ listOfNeighboors[1]=possibleposition[56]; //west
+ listOfNeighboors[2]=possibleposition[64]; //north
+ listOfNeighboors[3]=possibleposition[58]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[58])){
+ listOfNeighboors[0]=possibleposition[53]; //south
+ listOfNeighboors[1]=possibleposition[57]; //west
+ listOfNeighboors[3]=possibleposition[59]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[59])){
+ listOfNeighboors[1]=possibleposition[58]; //west
+ listOfNeighboors[2]=possibleposition[63]; //north
+ listOfNeighboors[3]=possibleposition[60]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[60])){
+ listOfNeighboors[1]=possibleposition[59]; //west
+ listOfNeighboors[2]=possibleposition[62]; //north
+ listOfNeighboors[3]=possibleposition[61]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[61])){
+ listOfNeighboors[0]=possibleposition[50]; //south
+ listOfNeighboors[1]=possibleposition[60]; //west
+ listOfNeighboors[3]=possibleposition[13]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[62])){
+ listOfNeighboors[0]=possibleposition[60]; //south
+ listOfNeighboors[3]=possibleposition[16]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[63])){
+ listOfNeighboors[0]=possibleposition[59]; //south
+ listOfNeighboors[1]=possibleposition[64]; //west
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[64])){
+ listOfNeighboors[0]=possibleposition[57]; //south
+ listOfNeighboors[1]=possibleposition[65]; //west
+ listOfNeighboors[3]=possibleposition[63]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[65])){
+ listOfNeighboors[0]=possibleposition[56]; //south
+ listOfNeighboors[3]=possibleposition[64]; //east
+ return listOfNeighboors[s];
+ }
+ else if(findpos(pacLasVisPos,possibleposition[66])){
+ //Not back in center
+ listOfNeighboors[1]=possibleposition[47]; //west
+ listOfNeighboors[3]=possibleposition[48]; //east
+ return listOfNeighboors[s];
+ }
+
+
+ }
+
+
+
+
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.h (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanPink.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,34 @@
+#ifndef _PacmanPink_H__
+#define _PacmanPink_H__
+
+
+#include "PacmanGhost.h"
+//#include "getShortestPath.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;
+
+ void setNewTargetPink(Vector3 goalToGo);
+
+ void nextMove(Vector3 playerPos, Vector3 redPos);
+
+ int findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos);
+
+ Vector3 getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE);
+
+ Vector3 diffVector (Vector3 start, Vector3 goal);
+
+ };
+
+}
+
+#endif
\ No newline at end of file
Modified: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.cc 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -1,132 +1,78 @@
+#include "PacmanRandom.h"
- #include "PacmanGhost.h"
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
- namespace orxonox{
- class PacmanRandom : public PacmanGhost {
- public:
- /* int decision=0;
- int target_x = 0;
- int target_z = 0;
- bool ismoving = false;
- bool lockmove = false;*/
+namespace orxonox {
- //Random choice of new target (not used in game, but useful)
- void setnewTarget(int firstdec){
- //setNewTarget in PacmanGhost seems to be private so we need it here too
-
- decision = rand()%1;
- switch(decision){
- case 0:
- this->target_x = possibleposition[firstdec].x;
- this->target_z = possibleposition[firstdec].z;
- this->ismoving = true;
- break;
- }
- }
+ RegisterClass(PacmanRandom);
- //Random choice of new target
- void 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 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;
- }
-
- }
+ PacmanRandom::PacmanRandom(Context* context) : PacmanGhost(context){
- //Random choice of new target
- void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){
+ RegisterObject(PacmanRandom);
- decision = rand()%4;
- switch(decision){
- case 0:
- this->target_x = possibleposition[firstdec].x;
- this->target_z = possibleposition[firstdec].z;
- this->ismoving = true;
- break;
- case 1:
- this->target_x = possibleposition[seconddec].x;
- this->target_z = possibleposition[seconddec].z;
- this->ismoving = true;
- break;
- case 2:
- this->target_x = possibleposition[thirddec].x;
- this->target_z = possibleposition[thirddec].z;
- this->ismoving = true;
- break;
- case 3:
- this->target_x = possibleposition[fourthdec].x;
- this->target_z = possibleposition[fourthdec].z;
- this->ismoving = true;
- break;
- }
-
- }
+
+ }
- void tick(float dt){
+ /**
+ @brief
+ Method for creating a ghost through XML.
+ */
+ void PacmanRandom::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PacmanRandom, XMLPort, xmlelement, mode);
+ }
- PacmanGhost::tick(dt);
+ 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;
+ }
- if(!(this->ismoving)){
-
+ //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);
+ setnewTarget(1,17,19);
}
else if(findpos(actuelposition,possibleposition[1])){
- setnewTarget(0,2);
+ setnewTarget(0,2);
}
else if(findpos(actuelposition,possibleposition[2])){
- setnewTarget(1,3);
+ setnewTarget(1,3);
}
else if(findpos(actuelposition,possibleposition[3])){
- setnewTarget(2,4,5);
+ setnewTarget(2,4,5);
}
else if(findpos(actuelposition,possibleposition[4])){
- setnewTarget(3,6);
+ setnewTarget(3,6);
}
else if(findpos(actuelposition,possibleposition[5])){
- setnewTarget(3,7);
+ setnewTarget(3,7);
}
else if(findpos(actuelposition,possibleposition[6])){
setnewTarget(4,9,26);
@@ -316,20 +262,92 @@
this->resetGhost(); //Shouldn't happen...
} //End of Position table
lockmove = false;
- }
+ }
+
+ }
- //end of function
+ 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;
+ }
+
+ }
- private:
+ //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;
+ }
+
+ }
-
- //end of class
- };
-
-
- //namespae orxonox
- }
+}
\ No newline at end of file
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.h (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRandom.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,26 @@
+#ifndef _PacmanRandom_H__
+#define _PacmanRandom_H__
+
+#include "PacmanGhost.h"
+
+namespace orxonox {
+
+ class _OrxonoxExport PacmanRandom : public PacmanGhost{
+
+ 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
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,101 @@
+#include "PacmanRed.h"
+//#include "Pacman.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+ namespace orxonox{
+
+ RegisterClass(PacmanRed);
+
+ PacmanRed::PacmanRed(Context* context) : PacmanGhost(context){
+
+ RegisterObject(PacmanRed);
+
+ }
+
+
+ /**
+ @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();
+
+ //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;
+
+ //do red behavior
+
+ Vector3 purePos = setPureArrayPos(this->actuelposition);
+ //find nearest position on the map to red pos if pacman does not move,
+ //i.e. reached a point on the map
+ //Why not simply use target_x and target_z ??????
+
+ nextMove(purePos, player.actuelposition);
+ //how do we access the PLAYER variable ??????
+
+ //also, player.lastPassedPoint is maybe better
+ }
+
+ }
+
+
+ void PacmanRed::setNewTargetRed(Vector3 goalToGo){
+
+ this->target_x = goalToGo.x;
+ this->target_z = goalToGo.z;
+ this->ismoving = true;
+ }
+
+
+ void PacmanRed::nextMove(Vector3 playerPos, Vector3 redPos){
+ Vector3 nextTarget;
+
+ nextTarget = getShortestPath(playerPos, redPos);
+
+ setNewTargetRed(nextTarget);
+ }
+
+
+
+ //save last checkpoint crossed by player
+ /*
+ void PacmanGelb::tick(float dt){ //last passed point of player
+ for(int u=0; u < 67; u++){
+ if(findpos(this->getPosition(), possibleposition[u])){
+ this->lastPassedPoint=possibleposition[u];
+ }
+ }
+ }
+ */
+
+}
\ No newline at end of file
Added: code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h (rev 0)
+++ code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -0,0 +1,32 @@
+#ifndef _PacmanRed_H__
+#define _PacmanRed_H__
+
+
+#include "PacmanGhost.h"
+//#include "getShortestPath.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 setNewTargetRed(Vector3 goalToGo);
+
+ void nextMove(Vector3 playerPos, Vector3 redPos);
+
+ void mainBehaviourRed();
+
+
+
+ };
+
+}
+
+#endif
\ No newline at end of file
Modified: code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.cc
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.cc 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.cc 2019-04-18 11:26:10 UTC (rev 12304)
@@ -1,6 +1,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
- #include "getShortestPath.h"
+ //#include "getShortestPath.h"
+ #include "PacmanGhost.h"
#include "worldentities/ControllableEntity.h"
@@ -8,16 +9,6 @@
namespace orxonox{
- //Check if there is a collision
- bool jeanfindpos(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;
- }
-
- struct graphVertex;
- void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]);
- void updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor);
- graphVertex findNextVertexToConsider(graphVertex[]);
struct graphVertex {
Vector3 position;
@@ -56,6 +47,7 @@
};
+ graphVertex listOfVertices[67];
Vector3 getShortestPath(Vector3 start, Vector3 goal){
//this function should then somehow produce the algorithm and call all other functions
@@ -65,24 +57,6 @@
if(start==goal){ // basic case
return start;
}
-
- //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
-
- graphVertex listOfVertices[67]= { graphVertex()}; //list of all vertices in the map. // We need graphVertex()
for(int an=0; an < 67; an++){
@@ -89,7 +63,7 @@
listOfVertices[an]= graphVertex(possibleposition[an]); //same position order as in other file
}
- graphVertex actualVertex;
+ graphVertex actualVertex= graphVertex(start);
actualVertex.alreadyVisited=true;
actualVertex.shortestDistanceToStart=0;
@@ -167,7 +141,7 @@
}
- graphVertex findNextVertexToConsider(graphVertex listOfVertices[]){ //find next, nearest from start, non visited vertex
+ graphVertex findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex
int shortestDistance = -1;
graphVertex nextVertexToConsider;
@@ -174,31 +148,31 @@
for(int i=0; i < 67; i++){ //we loop over all possible positions
- if(listOfVertices[i].alreadyVisited==true){ //vertex should already be visited
+ if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited
- findNearestNonVisitedNeighboor(listOfVertices[i]); //we update nearest neighboor
+ findNearestNonVisitedNeighboor(listOfVerticesP[i]); //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(listOfVertices[i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate!
+ if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=NULL){ //we want a candidate!
if(shortestDistance==-1){ //our first possible candidate
- shortestDistance=graphDistance(listOfVertices[i].position,
- listOfVertices[i].currentNearestNonVisitedNeighboor->position) +
- listOfVertices[i].shortestDistanceToStart;
+ shortestDistance=graphDistance(listOfVerticesP[i].position,
+ listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) +
+ listOfVerticesP[i].shortestDistanceToStart;
- nextVertexToConsider=listOfVertices[i].currentNearestNonVisitedNeighboor;
+ nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
}
- else if(shortestDistance > graphDistance(listOfVertices[i].position,
- listOfVertices[i].currentNearestNonVisitedNeighboor->position) +
- listOfVertices[i].shortestDistanceToStart){
+ else if(shortestDistance > graphDistance(listOfVerticesP[i].position,
+ listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) +
+ listOfVerticesP[i].shortestDistanceToStart){
- shortestDistance=graphDistance(listOfVertices[i].position,
- listOfVertices[i].currentNearestNonVisitedNeighboor->position) +
- listOfVertices[i].shortestDistanceToStart;
+ shortestDistance=graphDistance(listOfVerticesP[i].position,
+ listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) +
+ listOfVerticesP[i].shortestDistanceToStart;
- nextVertexToConsider=listOfVertices[i].currentNearestNonVisitedNeighboor;
+ nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
}
}
}
@@ -217,335 +191,318 @@
//-195 -135 -85 -35 15 60 105 150 195 245
- void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]){
+ void findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[]){
- //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
-
-
-
- if(jeanfindpos(actuelposition,possibleposition[0])){
+ if(findpos(actuelposition,possibleposition[0])){
// we should use listOfVertices[i] instead of possibleposition[i] I think
// so that all neighboors are "the same"
- adjacentVertices[0]=graphVertex(possibleposition[1]); //need to do it everywhere !!!
- adjacentVertices[1]=graphVertex(possibleposition[17]);
- adjacentVertices[2]=possibleposition[19]; //maybe a vector would be more suitable ?
+ adjacentVertices[0]=&listOfVertices[1]; //graphVertex(possibleposition[1]); //need to do it everywhere !!!
+ adjacentVertices[1]=&listOfVertices[17]; //graphVertex(possibleposition[17]);
+ adjacentVertices[2]=&listOfVertices[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
}
- else if(jeanfindpos(actuelposition,possibleposition[1])){
- adjacentVertices[0]=possibleposition[0];
- adjacentVertices[1]=possibleposition[2];
+ else if(findpos(actuelposition,possibleposition[1])){
+ adjacentVertices[0]=&listOfVertices[0]; //graphVertex(possibleposition[0]);
+ adjacentVertices[1]=&listOfVertices[2]; //graphVertex(possibleposition[2]);
}
- else if(jeanfindpos(actuelposition,possibleposition[2])){
- adjacentVertices[0]=possibleposition[1];
- adjacentVertices[1]=possibleposition[3];
+ else if(findpos(actuelposition,possibleposition[2])){
+ adjacentVertices[0]=&listOfVertices[1]; //graphVertex(possibleposition[1]);
+ adjacentVertices[1]=&listOfVertices[3]; //graphVertex(possibleposition[3]);
}
- else if(jeanfindpos(actuelposition,possibleposition[3])){
- adjacentVertices[0]=possibleposition[2];
- adjacentVertices[1]=possibleposition[4];
- adjacentVertices[2]=possibleposition[5];
+ else if(findpos(actuelposition,possibleposition[3])){
+ adjacentVertices[0]=&listOfVertices[2]; //graphVertex(possibleposition[2]);
+ adjacentVertices[1]=&listOfVertices[4]; //graphVertex(possibleposition[4]);
+ adjacentVertices[2]=&listOfVertices[5]; //graphVertex(possibleposition[5]);
}
- else if(jeanfindpos(actuelposition,possibleposition[4])){
- adjacentVertices[0]=possibleposition[3];
- adjacentVertices[1]=possibleposition[6];
+ else if(findpos(actuelposition,possibleposition[4])){
+ adjacentVertices[0]=&listOfVertices[3]; //graphVertex(possibleposition[3]);
+ adjacentVertices[1]=&listOfVertices[6]; //graphVertex(possibleposition[6]);
}
- else if(jeanfindpos(actuelposition,possibleposition[5])){
- adjacentVertices[0]=possibleposition[3];
- adjacentVertices[1]=possibleposition[7];
+ else if(findpos(actuelposition,possibleposition[5])){
+ adjacentVertices[0]=&listOfVertices[3]; //graphVertex(possibleposition[3]);
+ adjacentVertices[1]=&listOfVertices[7]; //graphVertex(possibleposition[7]);
}
- else if(jeanfindpos(actuelposition,possibleposition[6])){
- adjacentVertices[0]=possibleposition[4];
- adjacentVertices[1]=possibleposition[9];
- adjacentVertices[2]=possibleposition[26];
+ else if(findpos(actuelposition,possibleposition[6])){
+ adjacentVertices[0]=&listOfVertices[4]; //graphVertex(possibleposition[4]);
+ adjacentVertices[1]=&listOfVertices[9]; //graphVertex(possibleposition[9]);
+ adjacentVertices[2]=&listOfVertices[26]; //graphVertex(possibleposition[26]);
}
- else if(jeanfindpos(actuelposition,possibleposition[7])){
- adjacentVertices[0]=possibleposition[5];
- adjacentVertices[1]=possibleposition[8];
+ else if(findpos(actuelposition,possibleposition[7])){
+ adjacentVertices[0]=&listOfVertices[5]; //graphVertex(possibleposition[5]);
+ adjacentVertices[1]=&listOfVertices[8]; //graphVertex(possibleposition[8]);
}
- else if(jeanfindpos(actuelposition,possibleposition[8])){
- adjacentVertices[0]=possibleposition[7];
- adjacentVertices[1]=possibleposition[9];
+ else if(findpos(actuelposition,possibleposition[8])){
+ adjacentVertices[0]=&listOfVertices[7]; //graphVertex(possibleposition[7]);
+ adjacentVertices[1]=&listOfVertices[9]; //graphVertex(possibleposition[9]);
}
- else if(jeanfindpos(actuelposition,possibleposition[9])){
- adjacentVertices[0]=possibleposition[6];
- adjacentVertices[1]=possibleposition[8];
- adjacentVertices[2]=possibleposition[10];
- adjacentVertices[3]=possibleposition[38];
+ else if(findpos(actuelposition,possibleposition[9])){
+ adjacentVertices[0]=&listOfVertices[6]; //graphVertex(possibleposition[6]);
+ adjacentVertices[1]=&listOfVertices[8]; //graphVertex(possibleposition[8]);
+ adjacentVertices[2]=&listOfVertices[10]; //graphVertex(possibleposition[10]);
+ adjacentVertices[3]=&listOfVertices[38]; //graphVertex(possibleposition[38]);
}
- else if(jeanfindpos(actuelposition,possibleposition[10])){
- adjacentVertices[0]=possibleposition[9];
- adjacentVertices[1]=possibleposition[11];
- adjacentVertices[2]=possibleposition[45];
+ else if(findpos(actuelposition,possibleposition[10])){
+ adjacentVertices[0]=&listOfVertices[9]; //graphVertex(possibleposition[9]);
+ adjacentVertices[1]=&listOfVertices[11]; //graphVertex(possibleposition[11]);
+ adjacentVertices[2]=&listOfVertices[45]; //graphVertex(possibleposition[45]);
}
- else if(jeanfindpos(actuelposition,possibleposition[11])){
- adjacentVertices[0]=possibleposition[10];
- adjacentVertices[1]=possibleposition[12];
- adjacentVertices[2]=possibleposition[13];
+ else if(findpos(actuelposition,possibleposition[11])){
+ adjacentVertices[0]=&listOfVertices[10]; //graphVertex(possibleposition[10]);
+ adjacentVertices[1]=&listOfVertices[12]; //graphVertex(possibleposition[12]);
+ adjacentVertices[2]=&listOfVertices[13]; //graphVertex(possibleposition[13]);
}
- else if(jeanfindpos(actuelposition,possibleposition[12])){
- adjacentVertices[0]=possibleposition[11];
- adjacentVertices[1]=possibleposition[14];
+ else if(findpos(actuelposition,possibleposition[12])){
+ adjacentVertices[0]=&listOfVertices[11]; //graphVertex(possibleposition[11]);
+ adjacentVertices[1]=&listOfVertices[14]; //graphVertex(possibleposition[14]);
}
- else if(jeanfindpos(actuelposition,possibleposition[13])){
- adjacentVertices[0]=possibleposition[11];
- adjacentVertices[1]=possibleposition[14];
- adjacentVertices[2]=possibleposition[16];
- adjacentVertices[3]=possibleposition[61];
+ else if(findpos(actuelposition,possibleposition[13])){
+ adjacentVertices[0]=&listOfVertices[11]; //graphVertex(possibleposition[11]);
+ adjacentVertices[1]=&listOfVertices[14]; //graphVertex(possibleposition[14]);
+ adjacentVertices[2]=&listOfVertices[16]; //graphVertex(possibleposition[16]);
+ adjacentVertices[3]=&listOfVertices[61]; //graphVertex(possibleposition[61]);
}
- else if(jeanfindpos(actuelposition,possibleposition[14])){
- adjacentVertices[0]=possibleposition[12];
- adjacentVertices[1]=possibleposition[13];
- adjacentVertices[2]=possibleposition[15];
+ else if(findpos(actuelposition,possibleposition[14])){
+ adjacentVertices[0]=&listOfVertices[12]; //graphVertex(possibleposition[12]);
+ adjacentVertices[1]=&listOfVertices[13]; //graphVertex(possibleposition[13]);
+ adjacentVertices[2]=&listOfVertices[15]; //graphVertex(possibleposition[15]);
}
- else if(jeanfindpos(actuelposition,possibleposition[15])){
- adjacentVertices[0]=possibleposition[14];
- adjacentVertices[1]=possibleposition[16];
+ else if(findpos(actuelposition,possibleposition[15])){
+ adjacentVertices[0]=&listOfVertices[14]; //graphVertex(possibleposition[14]);
+ adjacentVertices[1]=&listOfVertices[16]; //graphVertex(possibleposition[16]);
}
- else if(jeanfindpos(actuelposition,possibleposition[16])){
- adjacentVertices[0]=possibleposition[13];
- adjacentVertices[1]=possibleposition[15];
- adjacentVertices[2]=possibleposition[62];
+ else if(findpos(actuelposition,possibleposition[16])){
+ adjacentVertices[0]=&listOfVertices[13]; //graphVertex(possibleposition[13]);
+ adjacentVertices[1]=&listOfVertices[15]; //graphVertex(possibleposition[15]);
+ adjacentVertices[2]=&listOfVertices[62]; //graphVertex(possibleposition[62]);
}
- else if(jeanfindpos(actuelposition,possibleposition[17])){
- adjacentVertices[0]=possibleposition[0];
- adjacentVertices[1]=possibleposition[25];
+ else if(findpos(actuelposition,possibleposition[17])){
+ adjacentVertices[0]=&listOfVertices[0]; //graphVertex(possibleposition[0]);
+ adjacentVertices[1]=&listOfVertices[25]; //graphVertex(possibleposition[25]);
}
- else if(jeanfindpos(actuelposition,possibleposition[18])){
- adjacentVertices[0]=possibleposition[19];
- adjacentVertices[1]=possibleposition[24];
+ else if(findpos(actuelposition,possibleposition[18])){
+ adjacentVertices[0]=&listOfVertices[19]; //graphVertex(possibleposition[19]);
+ adjacentVertices[1]=&listOfVertices[24]; //graphVertex(possibleposition[24]);
}
- else if(jeanfindpos(actuelposition,possibleposition[19])){
- adjacentVertices[0]=possibleposition[0];
- adjacentVertices[1]=possibleposition[18];
- adjacentVertices[2]=possibleposition[20];
+ else if(findpos(actuelposition,possibleposition[19])){
+ adjacentVertices[0]=&listOfVertices[0]; //graphVertex(possibleposition[0]);
+ adjacentVertices[1]=&listOfVertices[18]; //graphVertex(possibleposition[18]);
+ adjacentVertices[2]=&listOfVertices[20]; //graphVertex(possibleposition[20]);
}
- else if(jeanfindpos(actuelposition,possibleposition[20])){
- adjacentVertices[0]=possibleposition[19];
- adjacentVertices[1]=possibleposition[21];
+ else if(findpos(actuelposition,possibleposition[20])){
+ adjacentVertices[0]=&listOfVertices[19]; //graphVertex(possibleposition[19]);
+ adjacentVertices[1]=&listOfVertices[21]; //graphVertex(possibleposition[21]);
}
- else if(jeanfindpos(actuelposition,possibleposition[21])){
- adjacentVertices[0]=possibleposition[20];
- adjacentVertices[1]=possibleposition[22];
+ else if(findpos(actuelposition,possibleposition[21])){
+ adjacentVertices[0]=&listOfVertices[20]; //graphVertex(possibleposition[20]);
+ adjacentVertices[1]=&listOfVertices[22]; //graphVertex(possibleposition[22]);
}
- else if(jeanfindpos(actuelposition,possibleposition[22])){
- adjacentVertices[0]=possibleposition[21];
- adjacentVertices[1]=possibleposition[23];
- adjacentVertices[2]=possibleposition[31];
+ else if(findpos(actuelposition,possibleposition[22])){
+ adjacentVertices[0]=&listOfVertices[21]; //graphVertex(possibleposition[21]);
+ adjacentVertices[1]=&listOfVertices[23]; //graphVertex(possibleposition[23]);
+ adjacentVertices[2]=&listOfVertices[31]; //graphVertex(possibleposition[31]);
}
- else if(jeanfindpos(actuelposition,possibleposition[23])){
- adjacentVertices[0]=possibleposition[22];
- adjacentVertices[1]=possibleposition[30];
+ else if(findpos(actuelposition,possibleposition[23])){
+ adjacentVertices[0]=&listOfVertices[22]; //graphVertex(possibleposition[22]);
+ adjacentVertices[1]=&listOfVertices[30]; //graphVertex(possibleposition[30]);
}
- else if(jeanfindpos(actuelposition,possibleposition[24])){
- adjacentVertices[0]=possibleposition[18];
- adjacentVertices[1]=possibleposition[29];
+ else if(findpos(actuelposition,possibleposition[24])){
+ adjacentVertices[0]=&listOfVertices[18]; //graphVertex(possibleposition[18]);
+ adjacentVertices[1]=&listOfVertices[29]; //graphVertex(possibleposition[29]);
}
- else if(jeanfindpos(actuelposition,possibleposition[25])){
- adjacentVertices[0]=possibleposition[17];
- adjacentVertices[1]=possibleposition[26];
+ else if(findpos(actuelposition,possibleposition[25])){
+ adjacentVertices[0]=&listOfVertices[17]; //graphVertex(possibleposition[17]);
+ adjacentVertices[1]=&listOfVertices[26]; //graphVertex(possibleposition[26]);
}
- else if(jeanfindpos(actuelposition,possibleposition[26])){
- adjacentVertices[0]=possibleposition[6];
- adjacentVertices[1]=possibleposition[25];
- adjacentVertices[2]=possibleposition[27];
+ else if(findpos(actuelposition,possibleposition[26])){
+ adjacentVertices[0]=&listOfVertices[6]; //graphVertex(possibleposition[6]);
+ adjacentVertices[1]=&listOfVertices[25]; //graphVertex(possibleposition[25]);
+ adjacentVertices[2]=&listOfVertices[27]; //graphVertex(possibleposition[27]);
}
- else if(jeanfindpos(actuelposition,possibleposition[27])){
- adjacentVertices[0]=possibleposition[26];
- adjacentVertices[1]=possibleposition[28];
- adjacentVertices[2]=possibleposition[37];
+ else if(findpos(actuelposition,possibleposition[27])){
+ adjacentVertices[0]=&listOfVertices[26]; //graphVertex(possibleposition[26]);
+ adjacentVertices[1]=&listOfVertices[28]; //graphVertex(possibleposition[28]);
+ adjacentVertices[2]=&listOfVertices[37]; //graphVertex(possibleposition[37]);
}
- else if(jeanfindpos(actuelposition,possibleposition[28])){
- adjacentVertices[0]=possibleposition[27];
- adjacentVertices[1]=possibleposition[29];
- adjacentVertices[2]=possibleposition[36];
+ else if(findpos(actuelposition,possibleposition[28])){
+ adjacentVertices[0]=&listOfVertices[27]; //graphVertex(possibleposition[27]);
+ adjacentVertices[1]=&listOfVertices[29]; //graphVertex(possibleposition[29]);
+ adjacentVertices[2]=&listOfVertices[36]; //graphVertex(possibleposition[36]);
}
- else if(jeanfindpos(actuelposition,possibleposition[29])){
- adjacentVertices[0]=possibleposition[24];
- adjacentVertices[1]=possibleposition[28];
- adjacentVertices[2]=possibleposition[30];
+ else if(findpos(actuelposition,possibleposition[29])){
+ adjacentVertices[0]=&listOfVertices[24]; //graphVertex(possibleposition[24]);
+ adjacentVertices[1]=&listOfVertices[28]; //graphVertex(possibleposition[28]);
+ adjacentVertices[2]=&listOfVertices[30]; //graphVertex(possibleposition[30]);
}
- else if(jeanfindpos(actuelposition,possibleposition[30])){
- adjacentVertices[0]=possibleposition[23];
- adjacentVertices[1]=possibleposition[29];
- adjacentVertices[2]=possibleposition[34];
+ else if(findpos(actuelposition,possibleposition[30])){
+ adjacentVertices[0]=&listOfVertices[23]; //graphVertex(possibleposition[23]);
+ adjacentVertices[1]=&listOfVertices[29]; //graphVertex(possibleposition[29]);
+ adjacentVertices[2]=&listOfVertices[34]; //graphVertex(possibleposition[34]);
}
- else if(jeanfindpos(actuelposition,possibleposition[31])){
- adjacentVertices[0]=possibleposition[22];
- adjacentVertices[1]=possibleposition[32];
+ else if(findpos(actuelposition,possibleposition[31])){
+ adjacentVertices[0]=&listOfVertices[22]; //graphVertex(possibleposition[22]);
+ adjacentVertices[1]=&listOfVertices[32]; //graphVertex(possibleposition[32]);
}
- else if(jeanfindpos(actuelposition,possibleposition[32])){
- adjacentVertices[0]=possibleposition[31];
- adjacentVertices[1]=possibleposition[33];
+ else if(findpos(actuelposition,possibleposition[32])){
+ adjacentVertices[0]=&listOfVertices[31]; //graphVertex(possibleposition[31]);
+ adjacentVertices[1]=&listOfVertices[33]; //graphVertex(possibleposition[33]);
}
- else if(jeanfindpos(actuelposition,possibleposition[33])){
- adjacentVertices[0]=possibleposition[32];
- adjacentVertices[1]=possibleposition[34];
+ else if(findpos(actuelposition,possibleposition[33])){
+ adjacentVertices[0]=&listOfVertices[32]; //graphVertex(possibleposition[32]);
+ adjacentVertices[1]=&listOfVertices[34]; //graphVertex(possibleposition[34]);
}
- else if(jeanfindpos(actuelposition,possibleposition[34])){
- adjacentVertices[0]=possibleposition[30];
- adjacentVertices[1]=possibleposition[33];
- adjacentVertices[2]=possibleposition[35];
- adjacentVertices[3]=possibleposition[42];
+ else if(findpos(actuelposition,possibleposition[34])){
+ adjacentVertices[0]=&listOfVertices[30]; //graphVertex(possibleposition[30]);
+ adjacentVertices[1]=&listOfVertices[33]; //graphVertex(possibleposition[33]);
+ adjacentVertices[2]=&listOfVertices[35]; //graphVertex(possibleposition[35]);
+ adjacentVertices[3]=&listOfVertices[42]; //graphVertex(possibleposition[42]);
}
- else if(jeanfindpos(actuelposition,possibleposition[35])){
- adjacentVertices[0]=possibleposition[34];
- adjacentVertices[1]=possibleposition[36];
- adjacentVertices[2]=possibleposition[41];
+ else if(findpos(actuelposition,possibleposition[35])){
+ adjacentVertices[0]=&listOfVertices[34]; //graphVertex(possibleposition[34]);
+ adjacentVertices[1]=&listOfVertices[36]; //graphVertex(possibleposition[36]);
+ adjacentVertices[2]=&listOfVertices[41]; //graphVertex(possibleposition[41]);
}
- else if(jeanfindpos(actuelposition,possibleposition[36])){
- adjacentVertices[0]=possibleposition[28];
- adjacentVertices[1]=possibleposition[35];
+ else if(findpos(actuelposition,possibleposition[36])){
+ adjacentVertices[0]=&listOfVertices[28]; //graphVertex(possibleposition[28]);
+ adjacentVertices[1]=&listOfVertices[35]; //graphVertex(possibleposition[35]);
}
- else if(jeanfindpos(actuelposition,possibleposition[37])){
- adjacentVertices[0]=possibleposition[27];
- adjacentVertices[1]=possibleposition[38];
+ else if(findpos(actuelposition,possibleposition[37])){
+ adjacentVertices[0]=&listOfVertices[27]; //graphVertex(possibleposition[27]);
+ adjacentVertices[1]=&listOfVertices[38]; //graphVertex(possibleposition[38]);
}
- else if(jeanfindpos(actuelposition,possibleposition[38])){
- adjacentVertices[0]=possibleposition[9];
- adjacentVertices[1]=possibleposition[37];
- adjacentVertices[2]=possibleposition[39];
+ else if(findpos(actuelposition,possibleposition[38])){
+ adjacentVertices[0]=&listOfVertices[9]; //graphVertex(possibleposition[9]);
+ adjacentVertices[1]=&listOfVertices[37]; //graphVertex(possibleposition[37]);
+ adjacentVertices[2]=&listOfVertices[39]; //graphVertex(possibleposition[39]);
}
- else if(jeanfindpos(actuelposition,possibleposition[39])){
- adjacentVertices[0]=possibleposition[38];
- adjacentVertices[1]=possibleposition[40];
- adjacentVertices[2]=possibleposition[45];
+ else if(findpos(actuelposition,possibleposition[39])){
+ adjacentVertices[0]=&listOfVertices[38]; //graphVertex(possibleposition[38]);
+ adjacentVertices[1]=&listOfVertices[40]; //graphVertex(possibleposition[40]);
+ adjacentVertices[2]=&listOfVertices[45]; //graphVertex(possibleposition[45]);
}
- else if(jeanfindpos(actuelposition,possibleposition[40])){
- adjacentVertices[0]=possibleposition[39];
- adjacentVertices[1]=possibleposition[41];
+ else if(findpos(actuelposition,possibleposition[40])){
+ adjacentVertices[0]=&listOfVertices[39]; //graphVertex(possibleposition[39]);
+ adjacentVertices[1]=&listOfVertices[41]; //graphVertex(possibleposition[41]);
}
- else if(jeanfindpos(actuelposition,possibleposition[41])){
- adjacentVertices[0]=possibleposition[35];
- adjacentVertices[1]=possibleposition[43];
+ else if(findpos(actuelposition,possibleposition[41])){
+ adjacentVertices[0]=&listOfVertices[35]; //graphVertex(possibleposition[35]);
+ adjacentVertices[1]=&listOfVertices[43]; //graphVertex(possibleposition[43]);
}
- else if(jeanfindpos(actuelposition,possibleposition[42])){
- adjacentVertices[0]=possibleposition[34];
- adjacentVertices[1]=possibleposition[43];
- adjacentVertices[2]=possibleposition[54];
+ else if(findpos(actuelposition,possibleposition[42])){
+ adjacentVertices[0]=&listOfVertices[34]; //graphVertex(possibleposition[34]);
+ adjacentVertices[1]=&listOfVertices[43]; //graphVertex(possibleposition[43]);
+ adjacentVertices[2]=&listOfVertices[54]; //graphVertex(possibleposition[54]);
}
- else if(jeanfindpos(actuelposition,possibleposition[43])){
- adjacentVertices[0]=possibleposition[41];
- adjacentVertices[1]=possibleposition[46];
+ else if(findpos(actuelposition,possibleposition[43])){
+ adjacentVertices[0]=&listOfVertices[41]; //graphVertex(possibleposition[41]);
+ adjacentVertices[1]=&listOfVertices[46]; //graphVertex(possibleposition[46]);
}
- else if(jeanfindpos(actuelposition,possibleposition[44])){
- adjacentVertices[0]=possibleposition[40];
- adjacentVertices[1]=possibleposition[66];
+ else if(findpos(actuelposition,possibleposition[44])){
+ adjacentVertices[0]=&listOfVertices[40]; //graphVertex(possibleposition[40]);
+ adjacentVertices[1]=&listOfVertices[66]; //graphVertex(possibleposition[66]);
}
- else if(jeanfindpos(actuelposition,possibleposition[45])){
- adjacentVertices[0]=possibleposition[10];
- adjacentVertices[1]=possibleposition[39];
- adjacentVertices[2]=possibleposition[49];
+ else if(findpos(actuelposition,possibleposition[45])){
+ adjacentVertices[0]=&listOfVertices[10]; //graphVertex(possibleposition[10]);
+ adjacentVertices[1]=&listOfVertices[39]; //graphVertex(possibleposition[39]);
+ adjacentVertices[2]=&listOfVertices[49]; //graphVertex(possibleposition[49]);
}
- else if(jeanfindpos(actuelposition,possibleposition[46])){
- adjacentVertices[0]=possibleposition[43];
- adjacentVertices[1]=possibleposition[47];
+ else if(findpos(actuelposition,possibleposition[46])){
+ adjacentVertices[0]=&listOfVertices[43]; //graphVertex(possibleposition[43]);
+ adjacentVertices[1]=&listOfVertices[47]; //graphVertex(possibleposition[47]);
}
- else if(jeanfindpos(actuelposition,possibleposition[47])){
- adjacentVertices[0]=possibleposition[46];
- adjacentVertices[1]=possibleposition[52];
- adjacentVertices[2]=possibleposition[66];
+ else if(findpos(actuelposition,possibleposition[47])){
+ adjacentVertices[0]=&listOfVertices[46]; //graphVertex(possibleposition[46]);
+ adjacentVertices[1]=&listOfVertices[52]; //graphVertex(possibleposition[52]);
+ adjacentVertices[2]=&listOfVertices[66]; //graphVertex(possibleposition[66]);
}
- else if(jeanfindpos(actuelposition,possibleposition[48])){
- adjacentVertices[0]=possibleposition[49];
- adjacentVertices[1]=possibleposition[51];
- adjacentVertices[2]=possibleposition[66];
+ else if(findpos(actuelposition,possibleposition[48])){
+ adjacentVertices[0]=&listOfVertices[49]; //graphVertex(possibleposition[49]);
+ adjacentVertices[1]=&listOfVertices[51]; //graphVertex(possibleposition[51]);
+ adjacentVertices[2]=&listOfVertices[66]; //graphVertex(possibleposition[66]);
}
- else if(jeanfindpos(actuelposition,possibleposition[49])){
- adjacentVertices[0]=possibleposition[45];
- adjacentVertices[1]=possibleposition[48];
+ else if(findpos(actuelposition,possibleposition[49])){
+ adjacentVertices[0]=&listOfVertices[45]; //graphVertex(possibleposition[45]);
+ adjacentVertices[1]=&listOfVertices[48]; //graphVertex(possibleposition[48]);
}
- else if(jeanfindpos(actuelposition,possibleposition[50])){
- adjacentVertices[0]=possibleposition[51];
- adjacentVertices[1]=possibleposition[61];
+ else if(findpos(actuelposition,possibleposition[50])){
+ adjacentVertices[0]=&listOfVertices[51]; //graphVertex(possibleposition[51]);
+ adjacentVertices[1]=&listOfVertices[61]; //graphVertex(possibleposition[61]);
}
- else if(jeanfindpos(actuelposition,possibleposition[51])){
- adjacentVertices[0]=possibleposition[48];
- adjacentVertices[1]=possibleposition[50];
+ else if(findpos(actuelposition,possibleposition[51])){
+ adjacentVertices[0]=&listOfVertices[48]; //graphVertex(possibleposition[48]);
+ adjacentVertices[1]=&listOfVertices[50]; //graphVertex(possibleposition[50]);
}
- else if(jeanfindpos(actuelposition,possibleposition[52])){
- adjacentVertices[0]=possibleposition[47];
- adjacentVertices[1]=possibleposition[53];
+ else if(findpos(actuelposition,possibleposition[52])){
+ adjacentVertices[0]=&listOfVertices[47]; //graphVertex(possibleposition[47]);
+ adjacentVertices[1]=&listOfVertices[53]; //graphVertex(possibleposition[53]);
}
- else if(jeanfindpos(actuelposition,possibleposition[53])){
- adjacentVertices[0]=possibleposition[52];
- adjacentVertices[1]=possibleposition[58];
+ else if(findpos(actuelposition,possibleposition[53])){
+ adjacentVertices[0]=&listOfVertices[52]; //graphVertex(possibleposition[52]);
+ adjacentVertices[1]=&listOfVertices[58]; //graphVertex(possibleposition[58]);
}
- else if(jeanfindpos(actuelposition,possibleposition[54])){
- adjacentVertices[0]=possibleposition[42];
- adjacentVertices[1]=possibleposition[55];
- adjacentVertices[2]=possibleposition[57];
+ else if(findpos(actuelposition,possibleposition[54])){
+ adjacentVertices[0]=&listOfVertices[42]; //graphVertex(possibleposition[42]);
+ adjacentVertices[1]=&listOfVertices[55]; //graphVertex(possibleposition[55]);
+ adjacentVertices[2]=&listOfVertices[57]; //graphVertex(possibleposition[57]);
}
- else if(jeanfindpos(actuelposition,possibleposition[55])){
- adjacentVertices[0]=possibleposition[54];
- adjacentVertices[1]=possibleposition[56];
+ else if(findpos(actuelposition,possibleposition[55])){
+ adjacentVertices[0]=&listOfVertices[54]; //graphVertex(possibleposition[54]);
+ adjacentVertices[1]=&listOfVertices[56]; //graphVertex(possibleposition[56]);
}
- else if(jeanfindpos(actuelposition,possibleposition[56])){
- adjacentVertices[0]=possibleposition[55];
- adjacentVertices[1]=possibleposition[57];
- adjacentVertices[2]=possibleposition[65];
+ else if(findpos(actuelposition,possibleposition[56])){
+ adjacentVertices[0]=&listOfVertices[55]; //graphVertex(possibleposition[55]);
+ adjacentVertices[1]=&listOfVertices[57]; //graphVertex(possibleposition[57]);
+ adjacentVertices[2]=&listOfVertices[65]; //graphVertex(possibleposition[65]);
}
- else if(jeanfindpos(actuelposition,possibleposition[57])){
- adjacentVertices[0]=possibleposition[54];
- adjacentVertices[1]=possibleposition[56];
- adjacentVertices[2]=possibleposition[58];
- adjacentVertices[3]=possibleposition[64];
+ else if(findpos(actuelposition,possibleposition[57])){
+ adjacentVertices[0]=&listOfVertices[54]; //graphVertex(possibleposition[54]);
+ adjacentVertices[1]=&listOfVertices[56]; //graphVertex(possibleposition[56]);
+ adjacentVertices[2]=&listOfVertices[58]; //graphVertex(possibleposition[58]);
+ adjacentVertices[3]=&listOfVertices[64]; //graphVertex(possibleposition[64]);
}
- else if(jeanfindpos(actuelposition,possibleposition[58])){
- adjacentVertices[0]=possibleposition[53];
- adjacentVertices[1]=possibleposition[57];
- adjacentVertices[2]=possibleposition[59];
+ else if(findpos(actuelposition,possibleposition[58])){
+ adjacentVertices[0]=&listOfVertices[53]; //graphVertex(possibleposition[53]);
+ adjacentVertices[1]=&listOfVertices[57]; //graphVertex(possibleposition[57]);
+ adjacentVertices[2]=&listOfVertices[59]; //graphVertex(possibleposition[59]);
}
- else if(jeanfindpos(actuelposition,possibleposition[59])){
- adjacentVertices[0]=possibleposition[58];
- adjacentVertices[1]=possibleposition[59];
- adjacentVertices[2]=possibleposition[63];
+ else if(findpos(actuelposition,possibleposition[59])){
+ adjacentVertices[0]=&listOfVertices[58]; //graphVertex(possibleposition[58]);
+ adjacentVertices[1]=&listOfVertices[59]; //graphVertex(possibleposition[59]);
+ adjacentVertices[2]=&listOfVertices[63]; //graphVertex(possibleposition[63]);
}
- else if(jeanfindpos(actuelposition,possibleposition[60])){
- adjacentVertices[0]=possibleposition[59];
- adjacentVertices[1]=possibleposition[61];
- adjacentVertices[2]=possibleposition[62];
+ else if(findpos(actuelposition,possibleposition[60])){
+ adjacentVertices[0]=&listOfVertices[59]; //graphVertex(possibleposition[59]);
+ adjacentVertices[1]=&listOfVertices[61]; //graphVertex(possibleposition[61]);
+ adjacentVertices[2]=&listOfVertices[62]; //graphVertex(possibleposition[62]);
}
- else if(jeanfindpos(actuelposition,possibleposition[61])){
- adjacentVertices[0]=possibleposition[13];
- adjacentVertices[1]=possibleposition[50];
- adjacentVertices[2]=possibleposition[60];
+ else if(findpos(actuelposition,possibleposition[61])){
+ adjacentVertices[0]=&listOfVertices[13]; //graphVertex(possibleposition[13]);
+ adjacentVertices[1]=&listOfVertices[50]; //graphVertex(possibleposition[50]);
+ adjacentVertices[2]=&listOfVertices[60]; //graphVertex(possibleposition[60]);
}
- else if(jeanfindpos(actuelposition,possibleposition[62])){
- adjacentVertices[0]=possibleposition[16];
- adjacentVertices[1]=possibleposition[60];
+ else if(findpos(actuelposition,possibleposition[62])){
+ adjacentVertices[0]=&listOfVertices[16]; //graphVertex(possibleposition[16]);
+ adjacentVertices[1]=&listOfVertices[60]; //graphVertex(possibleposition[60]);
}
- else if(jeanfindpos(actuelposition,possibleposition[63])){
- adjacentVertices[0]=possibleposition[59];
- adjacentVertices[1]=possibleposition[64];
+ else if(findpos(actuelposition,possibleposition[63])){
+ adjacentVertices[0]=&listOfVertices[59]; //graphVertex(possibleposition[59]);
+ adjacentVertices[1]=&listOfVertices[64]; //graphVertex(possibleposition[64]);
}
- else if(jeanfindpos(actuelposition,possibleposition[64])){
- adjacentVertices[0]=possibleposition[57];
- adjacentVertices[1]=possibleposition[63];
- adjacentVertices[2]=possibleposition[65];
+ else if(findpos(actuelposition,possibleposition[64])){
+ adjacentVertices[0]=&listOfVertices[57]; //graphVertex(possibleposition[57]);
+ adjacentVertices[1]=&listOfVertices[63]; //graphVertex(possibleposition[63]);
+ adjacentVertices[2]=&listOfVertices[65]; //graphVertex(possibleposition[65]);
}
- else if(jeanfindpos(actuelposition,possibleposition[65])){
- adjacentVertices[0]=possibleposition[56];
- adjacentVertices[1]=possibleposition[64];
+ else if(findpos(actuelposition,possibleposition[65])){
+ adjacentVertices[0]=&listOfVertices[56]; //graphVertex(possibleposition[56]);
+ adjacentVertices[1]=&listOfVertices[64]; //graphVertex(possibleposition[64]);
}
- else if(jeanfindpos(actuelposition,possibleposition[66])){
- adjacentVertices[0]=possibleposition[47];
- adjacentVertices[1]=possibleposition[48];
+ else if(findpos(actuelposition,possibleposition[66])){
+ adjacentVertices[0]=&listOfVertices[47]; //graphVertex(possibleposition[47]);
+ adjacentVertices[1]=&listOfVertices[48]; //graphVertex(possibleposition[48]);
}
}
+
}
Deleted: code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.h
===================================================================
--- code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.h 2019-04-11 14:57:22 UTC (rev 12303)
+++ code/branches/3DPacman_FS19/src/modules/pacman/getShortestPath.h 2019-04-18 11:26:10 UTC (rev 12304)
@@ -1,64 +0,0 @@
- #include "core/CoreIncludes.h"
- #include "core/XMLPort.h"
- #include "PacmanGhost.h"
-
- #include "worldentities/ControllableEntity.h"
- using namespace std;
-
-namespace orxonox
-{
-
- class getShortestPath
- {
-
- public:
-
- //Check if there is a collision
- bool jeanfindpos(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;
- }
-
-
- private:
-
- struct graphVertex;
-
- void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]);
-
- struct graphVertex {
-
- Vector3 position;
- graphVertex *adjacentVertices[4]; //neighbooring vertices
-
- //would a vector of vector storing the neighboors not be more suitable ?
-
- 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=NULL;
- alreadyVisited=false;
- for(int kl =0; kl <4;kl++){
- adjacentVertices[kl]=NULL; //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=NULL;
- alreadyVisited=false;
- for(int kl =0; kl <4;kl++){
- adjacentVertices[kl]=NULL; //first put all position in array listing neighboors to 0
- }
- }
- };
-
- };
-
-}
-
More information about the Orxonox-commit
mailing list