Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pacman/getShortestPath.h @ 12289

Last change on this file since 12289 was 12289, checked in by peterf, 5 years ago
File size: 2.1 KB
Line 
1    #include "core/CoreIncludes.h"
2    #include "core/XMLPort.h"
3    #include "PacmanGhost.h"
4
5    #include "worldentities/ControllableEntity.h"
6    using namespace std;
7
8namespace orxonox
9{
10
11    class getShortestPath
12    {
13
14        public:
15
16            //Check if there is a collision
17        bool jeanfindpos(Vector3 one, Vector3 other){
18       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
19        return false;
20        }
21       
22
23       private:
24
25        struct graphVertex;
26
27        void findNeighboorVertices(Vector3 actuelposition, graphVertex adjacentVertices[]);
28
29            struct graphVertex {
30
31            Vector3 position;
32            graphVertex *adjacentVertices[4]; //neighbooring vertices
33
34            //would a vector of vector storing the neighboors not be more suitable ?
35
36            int shortestDistanceToStart; //actual shortest distance to start point
37            graphVertex* actuelPredecessor; //the predecessor giving the for now shortest
38                                            //path to start
39            graphVertex* currentNearestNonVisitedNeighboor; 
40            bool alreadyVisited;
41            graphVertex(){ //default constructor
42                position=0;
43                shortestDistanceToStart= std::numeric_limits<int>::max();
44                actuelPredecessor=NULL;
45                alreadyVisited=false;
46                for(int kl =0; kl <4;kl++){
47                    adjacentVertices[kl]=NULL;  //first put all position in array listing neighboors to 0
48                }
49            }
50            graphVertex(Vector3 wantedPosition){  //normal constructor
51                position=wantedPosition;
52                shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity
53                actuelPredecessor=NULL;
54                alreadyVisited=false;
55                for(int kl =0; kl <4;kl++){
56                    adjacentVertices[kl]=NULL;  //first put all position in array listing neighboors to 0
57                }
58            }
59        };
60       
61    };
62
63}
64
Note: See TracBrowser for help on using the repository browser.