Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/3DPacman_FS19/src/modules/pacman/PacmanGhost.cc @ 12325

Last change on this file since 12325 was 12325, checked in by peterf, 5 years ago

Red and Pink seem to work better

  • Property svn:executable set to *
File size: 89.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Marc Dreher
24 *   Co-authors:
25 *      ..
26 *
27 */
28
29#include "PacmanGhost.h"
30
31#include "core/CoreIncludes.h"
32#include "BulletDynamics/Dynamics/btRigidBody.h"
33
34namespace orxonox
35{
36
37
38    struct PacmanGhost::graphVertex {
39
40        public:
41
42            Vector3 position;
43            graphVertex *adjacentVertices[4]; //neighbooring vertices
44
45            //would a vector of vector storing the neighboors not be more suitable ?
46
47            int shortestDistanceToStart; //actual shortest distance to start point
48            graphVertex* actuelPredecessor; //the predecessor giving the for now shortest
49                                            //path to start
50            graphVertex* currentNearestNonVisitedNeighboor; 
51            bool alreadyVisited;
52            graphVertex(){ //default constructor
53                position=0;
54                shortestDistanceToStart= std::numeric_limits<int>::max();
55                actuelPredecessor=nullptr;
56                alreadyVisited=false;
57                for(int kl =0; kl <4;kl++){
58                    adjacentVertices[kl]=nullptr;  //first put all position in array listing neighboors to 0
59                }
60            }
61            graphVertex(Vector3 wantedPosition){  //normal constructor
62                position=wantedPosition;
63                shortestDistanceToStart= std::numeric_limits<int>::max(); //default distance is infinity
64                actuelPredecessor=nullptr;
65                alreadyVisited=false;
66                for(int kl =0; kl <4;kl++){
67                    adjacentVertices[kl]=nullptr;  //first put all position in array listing neighboors to 0
68                }
69            }
70            graphVertex& operator = (const graphVertex &rightSide){
71            this->position=rightSide.position;
72    this->shortestDistanceToStart=rightSide.shortestDistanceToStart;
73            this->actuelPredecessor=rightSide.actuelPredecessor;
74    this->currentNearestNonVisitedNeighboor=rightSide.currentNearestNonVisitedNeighboor;
75    this->alreadyVisited=rightSide.alreadyVisited;
76   
77            return *this;
78        }
79
80        };
81
82
83    static PacmanGhost::graphVertex listOfVertices[67];
84
85    //Check if there is a collision
86        bool findpos(Vector3 one, Vector3 other){
87       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
88        return false;
89        }
90
91    //All positions in the map, see documentation
92     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
93        Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9
94        Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14
95        Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19
96        Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24
97        Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29
98        Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105), //30-34
99        Vector3(-70,10,105),Vector3(-20,10,105),Vector3(20,10,105),Vector3(70,10,105),Vector3(70,10,60), //35-39
100        Vector3(0,10,60),Vector3(-70,10,60),Vector3(-135,10,15),Vector3(-70,10,60),Vector3(0,10,15), //40-44
101        Vector3(70,10,15),Vector3(-70,10,-35),Vector3(-20,10,-35),Vector3(20,10,-35),Vector3(70,10,-35), //45-49
102        Vector3(70,10,-85),Vector3(20,10,-85),Vector3(-20,10,-85),Vector3(-70,10,-85),Vector3(-135,10,-85), //50-54
103        Vector3(-215,10,-85),Vector3(-215,10,-135),Vector3(-135,10,-135),Vector3(-70,10,-135),Vector3(-20,10,-135), //55-59
104        Vector3(20,10,-135),Vector3(70,10,-135),Vector3(20,10,-195),Vector3(-20,10,-195),Vector3(-135,10,-195), //60-64
105        Vector3(-215,10,-195),Vector3(0,10,-35)}; //65-66
106
107    RegisterClass(PacmanGhost);
108
109    /**
110    @brief
111        Constructor. Registers the object and initializes some default values.
112    @param creator
113        The creator of this object.
114    */
115    PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context)
116    {
117        RegisterObject(PacmanGhost);
118
119        //this->pathAlgorithm = new GetShortestPathAlgorithm;
120
121
122        this->velocity = Vector3(0, 0, 0);
123
124        this->setCollisionType(CollisionType::Dynamic);
125       
126        this->actuelposition = this->getPosition();
127
128        if(findpos(actuelposition, Vector3(0,-20,0)))
129            dontmove = true;
130       
131        this->target_x = actuelposition.x;
132        this->target_z = actuelposition.z; 
133
134        //this->lastPlayerPassedPoint=Vector3(185,10,150); //no idea what to put
135
136    }
137
138    /**
139    @brief
140        Destructor. Destroys ghost, if present.
141    */
142    PacmanGhost::~PacmanGhost()
143    {
144        // Deletes the controller if the object was initialized and the pointer to the controller is not nullptr.
145    }
146
147    /**
148    @brief
149        Method for creating a ghost through XML.
150    */
151     void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
152    {
153        SUPER(PacmanGhost, XMLPort, xmlelement, mode);
154    }
155
156    //Change this with other ghost
157    void PacmanGhost::changewith(PacmanGhost* otherghost){
158
159        while(lockmove){};
160        lockmove = true;    //Prevent change of target while ghost is changed
161
162        otherghost->setPosition(this->getPosition());
163        this->setPosition(0,-20,0);
164        otherghost->target_x = this->target_x;   
165        otherghost->target_z = this->target_z;
166        otherghost->ismoving = this->ismoving;
167
168        this->dontmove = true;
169        otherghost->dontmove = false;
170
171        lockmove = false;
172    }
173
174    //Move ghost with rotation
175    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
176        if(!dontmove){
177            this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt));
178       
179        //Rotate ghost in the direction of movement
180        if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1)){
181            if(velocity.x<0){
182                 this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0))); 
183            }
184            else{
185                 this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0))); 
186            }
187        }
188        if((abs(abs(velocity.z)-1)<0.1) && (abs(velocity.x-0)<0.1)){
189            if(velocity.z<0){
190                 this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0))); 
191            }
192            else{
193                 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); 
194            }
195        }
196                     
197     }
198    }
199
200    //Change ability to move
201    void PacmanGhost::changemovability(){
202        if(dontmove){
203         dontmove = false;}
204        else{
205         dontmove = true;   
206        }
207    }
208
209    //ResetGhost
210    void PacmanGhost::resetGhost(){
211   
212        this->setPosition(this->resetposition);
213        this->ismoving = false;
214        this->actuelposition = this->getPosition();
215       
216        this->target_x = actuelposition.x;
217        this->target_z = actuelposition.z;
218   
219    }
220
221    //Increase speed of ghosts
222    void PacmanGhost::levelupvelo(){
223        speed ++;
224    }
225
226    Vector3 PacmanGhost::getPlayerPos()
227    {
228        for (PacmanGelb* player : ObjectList<PacmanGelb>())
229        {
230            return player->getWorldPosition();
231        }
232        //std::cout<<"bug ??"<<endl;
233        return Vector3(0,0,0); //default, should not be used
234   
235    }
236
237
238    bool PacmanGhost::jeanfindpos(Vector3 one, Vector3 other){
239       if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true;
240        return false;
241        }
242
243    void PacmanGhost::setNewTargetGhost(Vector3 goalToGo){
244
245                    this->target_x = goalToGo.x;
246                    this->target_z = goalToGo.z; 
247                    this->ismoving = true;
248    }
249
250
251    ///
252    //// getShortestPath   /////////
253    ///
254
255       
256       
257    Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal, Vector3 pointToAvoidP1){
258        //this function should then somehow produce the algorithm and call all other functions
259        //and finally return the best neighboor of the actual position of the pacman
260       
261    //(optional parameter) pointToAvoidP1 is a point that cannot be considered
262
263
264    graphVertex listOfVerticesM[67]; //our list of all possible graphs
265    graphVertex* actualVertex; //we will walk through the array with a pointer
266   
267        if(start==goal){ // basic case
268            return start; 
269        }
270
271        for(int an=0; an < 67; an++){
272      listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file
273    if(start==possibleposition[an]){
274     actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array
275    //cout<<an<<endl;
276        }
277        }
278
279        //graphVertex actualVertex= listOfVerticesM[an];
280
281        actualVertex->alreadyVisited=true; //our start point is now visited
282        actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0
283        findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
284        // second parameter is an array ! //third is our global array
285
286        while(actualVertex->position!=goal){
287            for(int h=0;h < 4; h++){
288                if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex
289 
290         //h=2 and 3 never reached
291                    updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]);
292                } //we "update" the neighboors of our new visited vertex
293       
294            }
295           
296            actualVertex=findNextVertexToConsider(listOfVerticesM, pointToAvoidP1);
297            actualVertex->alreadyVisited=true;
298    //cout<<actualVertex->position<<endl;
299            if(actualVertex->position!=goal){
300                findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
301                //we find the neighboors of our new visited vertex
302                }
303        }
304
305    //cout<<"meuejeeke"<<endl; never reached
306
307        //we should have reached our goal at this point
308
309        while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor
310            actualVertex=actualVertex->actuelPredecessor;
311        }
312        // the predecessor is our starting point, in other words we are now on an
313        //adjacent vertex of the start
314
315        return actualVertex->position; //we return the position of this - adjacent to start - vertex
316    }
317
318//end of getShortestPath
319
320
321    int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){
322    //cout<<hgj++<<endl;
323        Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
324
325        return differenceVector.x+differenceVector.z;
326    }
327
328    void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){
329        //apply this method to all non visited neighboors of a vertex.
330        // This method should always be run on a vertex after we marked it as visited.
331        if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors.
332            if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&&
333        (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + 
334                graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case !
335       
336                neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + 
337                graphDistance(vertex.position, neighboor.position);
338                neighboor.actuelPredecessor = &vertex;
339            }
340        }
341    }
342
343    void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex, Vector3 pointToAvoidP3){ 
344            //find nearest non visited neighboor of a given already visited vertex
345    //(optional parameter) pointToAvoidP3 is a point that cannot be considered
346        int shortestDistance = -1;
347        graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any.
348        //Also, if all neighboors are already visited, we return NULL, i.e. there is no
349        //nearest non visited neighboor.
350        for(int i=0; i < 4; i++){
351            if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)&&(vertex.adjacentVertices[i]->position!=pointToAvoidP3)){
352                if(shortestDistance==-1){   //(concerns line above) we want a non visited neighboor //(optional) if the position of the neighboor is the one we want
353    //to avoid, then we ignore it
354
355                    shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
356                    nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
357    //cout<<shortestDistance<<endl;
358                }
359                else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){
360                    shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
361                    nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
362        //cout<<(hgj++)%4<<endl;
363                }
364            }
365        }
366        vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses !
367    //cout<<hgj++<<endl;
368    }
369
370
371    PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[], Vector3 pointToAvoidP2){ //find next, nearest from start, non visited vertex in our listOfVertices array
372    //(optional parameter) pointToAvoidP2 is a point that cannot be considered
373
374        int shortestDistance = -1;
375        graphVertex* nextVertexToConsider;
376
377        for(int i=0; i < 67; i++){ //we loop over all possible positions
378
379            if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited
380
381                findNearestNonVisitedNeighboor(listOfVerticesP[i], pointToAvoidP2); //we update nearest neighboor
382                //of all visited vertices given that one of the nearest neighboor of a visited
383                // vertex is now also visited because it was chosen as next optimal vertex
384
385                if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate!
386                if(shortestDistance==-1){ //our first possible candidate
387
388            shortestDistance=graphDistance(listOfVerticesP[i].position, 
389            listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
390            listOfVerticesP[i].shortestDistanceToStart;
391
392            nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
393    //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor
394
395                }
396                else if(shortestDistance > graphDistance(listOfVerticesP[i].position, 
397                listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
398                    listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available
399
400            shortestDistance=graphDistance(listOfVerticesP[i].position, 
401            listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
402            listOfVerticesP[i].shortestDistanceToStart;
403
404            nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
405    //we dont need the & because we are not giving the adress of the array element
406    //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor
407                    }
408                }
409            }
410            //we want after all to return the nearest non visited neighboor
411        }
412
413        return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array
414    }
415
416    //////////////////////////////////////////////////////////////////////////////////////////////
417
418    //if vertex already visited, call function on it and reapeat until you reach non visited vertex
419    // ---> not sure if a good idea because we risk infinite loop
420
421    //-215 -185 -135 -70 -20 0 20 70 135 185 215
422
423    //-195 -135 -85 -35 15 60 105 150 195 245
424
425    void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){     
426
427
428            if(findpos(actuelposition,possibleposition[0])){
429                // we should use listOfVerticesP2[i] instead of possibleposition[i] I think
430                // so that all neighboors are "the same"
431                adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]);  //need to do it everywhere !!!
432                adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]);
433                adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
434            }
435            else if(findpos(actuelposition,possibleposition[1])){
436                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
437                adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]);
438            }
439            else if(findpos(actuelposition,possibleposition[2])){
440                adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]);
441                adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
442            }
443            else if(findpos(actuelposition,possibleposition[3])){
444                adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]);
445                adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]);
446                adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]);
447            }
448            else if(findpos(actuelposition,possibleposition[4])){
449                adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
450                adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
451            }
452            else if(findpos(actuelposition,possibleposition[5])){
453                adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
454                adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]);
455            }
456            else if(findpos(actuelposition,possibleposition[6])){
457                adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]);
458                adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
459                adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
460            }
461            else if(findpos(actuelposition,possibleposition[7])){
462                adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]);
463                adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]);
464            }
465            else if(findpos(actuelposition,possibleposition[8])){
466                adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]);
467                adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
468            }
469            else if(findpos(actuelposition,possibleposition[9])){
470                adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
471                adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]);
472                adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
473                adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
474            }
475            else if(findpos(actuelposition,possibleposition[10])){
476                adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
477                adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
478                adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
479            }
480            else if(findpos(actuelposition,possibleposition[11])){
481                adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
482                adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]);
483                adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
484            }
485            else if(findpos(actuelposition,possibleposition[12])){
486                adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
487                adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
488            }
489            else if(findpos(actuelposition,possibleposition[13])){
490                adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
491                adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
492                adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
493                adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
494            }
495            else if(findpos(actuelposition,possibleposition[14])){
496                adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]);
497                adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
498                adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]);
499            }
500            else if(findpos(actuelposition,possibleposition[15])){
501                adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
502                adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
503            }
504            else if(findpos(actuelposition,possibleposition[16])){
505                adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
506                adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]);
507                adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]);
508            }
509            else if(findpos(actuelposition,possibleposition[17])){
510                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
511                adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]);
512            }
513            else if(findpos(actuelposition,possibleposition[18])){
514                adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]);
515                adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]);               
516            }
517            else if(findpos(actuelposition,possibleposition[19])){
518                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
519                adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]);
520                adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]);
521                         }
522            else if(findpos(actuelposition,possibleposition[20])){
523                adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]);
524                adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]);
525                       }
526            else if(findpos(actuelposition,possibleposition[21])){
527                adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]);
528                adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
529                       }
530            else if(findpos(actuelposition,possibleposition[22])){
531                adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]);
532                adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]);
533                adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]);
534                          }
535            else if(findpos(actuelposition,possibleposition[23])){
536                adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
537                adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
538                       }
539            else if(findpos(actuelposition,possibleposition[24])){
540                adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]);
541                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
542                       }
543            else if(findpos(actuelposition,possibleposition[25])){
544                adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]);
545                adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
546                       }
547            else if(findpos(actuelposition,possibleposition[26])){
548                adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
549                adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]);
550                adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
551                         }
552            else if(findpos(actuelposition,possibleposition[27])){
553                adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
554                adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
555                adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]);
556                          }
557            else if(findpos(actuelposition,possibleposition[28])){
558                adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
559                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
560                adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]);
561                          }
562            else if(findpos(actuelposition,possibleposition[29])){
563                adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]);
564                adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
565                adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
566                          }
567            else if(findpos(actuelposition,possibleposition[30])){
568                adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]);
569                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
570                adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
571                          }
572            else if(findpos(actuelposition,possibleposition[31])){
573                adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
574                adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]);
575                       }
576            else if(findpos(actuelposition,possibleposition[32])){
577                adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]);
578                adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]);
579                       }
580            else if(findpos(actuelposition,possibleposition[33])){
581                adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]);
582                adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
583                       }
584            else if(findpos(actuelposition,possibleposition[34])){
585                adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
586                adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]);
587                adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
588                adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]);
589               
590            }
591            else if(findpos(actuelposition,possibleposition[35])){
592                adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
593                adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]);
594                adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
595                          }
596            else if(findpos(actuelposition,possibleposition[36])){
597                adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
598                adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
599                       }
600            else if(findpos(actuelposition,possibleposition[37])){
601                adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
602                adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
603                       }
604            else if(findpos(actuelposition,possibleposition[38])){
605                adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
606                adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]);
607                adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
608                         }
609            else if(findpos(actuelposition,possibleposition[39])){
610                adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
611                adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]);
612                adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
613                          }
614            else if(findpos(actuelposition,possibleposition[40])){
615                adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
616                adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
617            }
618            else if(findpos(actuelposition,possibleposition[41])){
619                adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
620                adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
621                       }
622            else if(findpos(actuelposition,possibleposition[42])){
623                adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
624                adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
625                adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
626                          }
627            else if(findpos(actuelposition,possibleposition[43])){
628                adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
629                adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]);
630                       }
631            else if(findpos(actuelposition,possibleposition[44])){
632                adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]);
633                adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
634                       }
635            else if(findpos(actuelposition,possibleposition[45])){
636                adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
637                adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
638                adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]);
639                          }
640            else if(findpos(actuelposition,possibleposition[46])){
641                adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
642                adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
643                       }
644            else if(findpos(actuelposition,possibleposition[47])){
645                adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]);
646                adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]);
647                adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
648                          }
649            else if(findpos(actuelposition,possibleposition[48])){
650                adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]);
651                adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]);
652                adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
653                          }
654            else if(findpos(actuelposition,possibleposition[49])){
655                adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
656                adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
657                       }
658            else if(findpos(actuelposition,possibleposition[50])){
659                adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]);
660                adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
661                       }
662            else if(findpos(actuelposition,possibleposition[51])){
663                adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
664                adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]);
665                       }
666            else if(findpos(actuelposition,possibleposition[52])){
667                adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
668                adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]);
669                       }
670            else if(findpos(actuelposition,possibleposition[53])){
671                adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]);
672                adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
673                       }
674            else if(findpos(actuelposition,possibleposition[54])){
675                adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]);
676                adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]);
677                adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
678                          }
679            else if(findpos(actuelposition,possibleposition[55])){
680                adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
681                adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
682                       }
683            else if(findpos(actuelposition,possibleposition[56])){
684                adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]);
685                adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
686                adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]);
687                          }
688            else if(findpos(actuelposition,possibleposition[57])){
689                adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
690                adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
691                adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
692                adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
693               
694            }
695            else if(findpos(actuelposition,possibleposition[58])){
696                adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]);
697                adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
698                adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
699                          }
700            else if(findpos(actuelposition,possibleposition[59])){
701                adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
702                adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[59]);
703                adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]);
704                          }
705            else if(findpos(actuelposition,possibleposition[60])){
706                adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
707                adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
708                adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]);
709                          }
710            else if(findpos(actuelposition,possibleposition[61])){
711                adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
712                adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]);
713                adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]);
714                          }
715            else if(findpos(actuelposition,possibleposition[62])){
716                adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
717                adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]);
718                       }
719            else if(findpos(actuelposition,possibleposition[63])){
720                adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
721                adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
722                       }
723            else if(findpos(actuelposition,possibleposition[64])){
724                adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
725                adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]);
726                adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]);
727                          }
728            else if(findpos(actuelposition,possibleposition[65])){
729                adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
730                adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
731                       }
732            else if(findpos(actuelposition,possibleposition[66])){
733                adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
734                adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
735                       }
736    }
737
738    //functions taken from PacmanPink
739
740
741    Vector3 PacmanGhost::diffVector (Vector3 start, Vector3 goal){
742
743        Vector3 result;
744        result.x=goal.x-start.x;
745        result.z=goal.z-start.z;
746        return result;
747    }
748
749
750    bool PacmanGhost::playerFindPos(Vector3 one, Vector3 other){
751       if((abs(one.x - other.x)<15) && (abs(one.z - other.z)<15)) return true;
752        return false;
753        }
754
755
756
757
758    int PacmanGhost::findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){
759        //return 0 for south, 1 for west, 2 for north, 3 for east
760
761
762        if(playerFindPos(playerPosBefore, playerPos)){
763            //if player is still near last crossed point
764
765            return 4; //return the last crossed point for simplicity
766        }
767
768
769        if(abs(playerPos.x-playerPosBefore.x)<14){ //player is moving vertically
770            if((playerPos.z-playerPosBefore.z)<0){//move west
771                return 0;
772            }
773            if((playerPos.z-playerPosBefore.z)>0){//move east
774                return 2;
775            }
776        }
777
778        if(abs(playerPos.z-playerPosBefore.z)<14){ //player is moving horizontally
779            if((playerPos.x-playerPosBefore.x)<0){//move south
780                return 1;
781            }
782            if((playerPos.x-playerPosBefore.x)>0){//move north
783                return 3;
784            }
785        }
786       
787        }
788
789    Vector3 PacmanGhost::getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){
790        //return the Vector3 point that Pinky should target to
791        //be in front of pacman
792
793        if(indexForSWNE==4){
794            //std::cout<<"Ryukyu"<<endl;
795            return pacLasVisPos;
796        }
797
798        Vector3 listOfNeighboors[4];
799        //first element is south, 2nd west, 3d north, 4th east
800
801            if(findpos(pacLasVisPos,possibleposition[0])){
802                //no south neighbor
803                listOfNeighboors[1]=possibleposition[19]; // west neighbor
804                listOfNeighboors[2]=possibleposition[17]; //north
805                listOfNeighboors[3]=possibleposition[1]; //east
806                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
807            }
808            else if(findpos(pacLasVisPos,possibleposition[1])){
809                listOfNeighboors[1]=possibleposition[0]; // west neighbor
810                listOfNeighboors[2]=possibleposition[2]; //north
811                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
812            }
813            else if(findpos(pacLasVisPos,possibleposition[2])){
814                listOfNeighboors[0]=possibleposition[1];  //south
815                listOfNeighboors[1]=possibleposition[3]; //west
816                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
817            }
818            else if(findpos(pacLasVisPos,possibleposition[3])){
819                listOfNeighboors[1]=possibleposition[4]; //west
820                listOfNeighboors[2]=possibleposition[5]; //north
821                listOfNeighboors[3]=possibleposition[2]; //east
822                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
823            }
824            else if(findpos(pacLasVisPos,possibleposition[4])){
825                listOfNeighboors[2]=possibleposition[6]; //north
826                listOfNeighboors[3]=possibleposition[3]; //east
827                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
828            }
829            else if(findpos(pacLasVisPos,possibleposition[5])){
830                listOfNeighboors[0]=possibleposition[3]; //south
831                listOfNeighboors[3]=possibleposition[7]; //east
832                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
833            }
834            else if(findpos(pacLasVisPos,possibleposition[6])){
835                listOfNeighboors[0]=possibleposition[4]; //south
836                listOfNeighboors[1]=possibleposition[26]; //west
837                listOfNeighboors[2]=possibleposition[9]; //north
838                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
839            }
840            else if(findpos(pacLasVisPos,possibleposition[7])){
841                listOfNeighboors[1]=possibleposition[5]; //west
842                listOfNeighboors[2]=possibleposition[8]; //north
843                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
844            }
845            else if(findpos(pacLasVisPos,possibleposition[8])){
846                listOfNeighboors[0]=possibleposition[7]; //south
847                listOfNeighboors[1]=possibleposition[9]; //west
848                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
849            }
850            else if(findpos(pacLasVisPos,possibleposition[9])){
851                listOfNeighboors[0]=possibleposition[6]; //south
852                listOfNeighboors[1]=possibleposition[38]; //west
853                listOfNeighboors[2]=possibleposition[10]; //north
854                listOfNeighboors[3]=possibleposition[8]; //east
855                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
856            }
857            else if(findpos(pacLasVisPos,possibleposition[10])){
858
859                if(indexForSWNE==3){ //nothing eastward
860                    return pacLasVisPos;
861                }
862
863                listOfNeighboors[0]=possibleposition[9]; //south
864                listOfNeighboors[1]=possibleposition[45]; //west
865                listOfNeighboors[2]=possibleposition[11]; //north
866                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
867            }
868            else if(findpos(pacLasVisPos,possibleposition[11])){
869                listOfNeighboors[0]=possibleposition[10]; //south
870                listOfNeighboors[2]=possibleposition[13]; //north
871                listOfNeighboors[3]=possibleposition[12]; //east
872                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
873            }
874            else if(findpos(pacLasVisPos,possibleposition[12])){
875                listOfNeighboors[1]=possibleposition[11]; //west
876                listOfNeighboors[2]=possibleposition[14]; //north
877                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
878            }
879            else if(findpos(pacLasVisPos,possibleposition[13])){
880                listOfNeighboors[0]=possibleposition[11]; //south
881                listOfNeighboors[1]=possibleposition[61]; //west
882                listOfNeighboors[2]=possibleposition[16]; //north
883                listOfNeighboors[3]=possibleposition[14]; //east
884                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
885            }
886            else if(findpos(pacLasVisPos,possibleposition[14])){
887                listOfNeighboors[0]=possibleposition[12]; //south
888                listOfNeighboors[1]=possibleposition[13]; //west
889                listOfNeighboors[2]=possibleposition[15]; //north
890                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
891            }
892            else if(findpos(pacLasVisPos,possibleposition[15])){
893                listOfNeighboors[0]=possibleposition[14]; //south
894                listOfNeighboors[1]=possibleposition[16]; //west
895                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
896            }
897            else if(findpos(pacLasVisPos,possibleposition[16])){
898                listOfNeighboors[0]=possibleposition[13]; //south
899                listOfNeighboors[1]=possibleposition[62]; //west
900                listOfNeighboors[2]=possibleposition[15]; //north
901                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
902            }
903            else if(findpos(pacLasVisPos,possibleposition[17])){
904                listOfNeighboors[0]=possibleposition[0]; //south
905                listOfNeighboors[3]=possibleposition[25]; //east
906                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
907            }
908            else if(findpos(pacLasVisPos,possibleposition[18])){
909                listOfNeighboors[0]=possibleposition[19]; //south
910                listOfNeighboors[1]=possibleposition[24]; //west
911                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
912            }
913            else if(findpos(pacLasVisPos,possibleposition[19])){
914                listOfNeighboors[1]=possibleposition[20]; //west
915                listOfNeighboors[2]=possibleposition[18]; //north
916                listOfNeighboors[3]=possibleposition[0]; //east
917                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
918            }
919            else if(findpos(pacLasVisPos,possibleposition[20])){
920                listOfNeighboors[2]=possibleposition[21]; //north
921                listOfNeighboors[3]=possibleposition[19]; //east
922                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
923            }
924            else if(findpos(pacLasVisPos,possibleposition[21])){
925                listOfNeighboors[0]=possibleposition[20]; //south
926                listOfNeighboors[3]=possibleposition[22]; //east
927                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
928            }
929            else if(findpos(pacLasVisPos,possibleposition[22])){
930                listOfNeighboors[1]=possibleposition[21]; //west
931                listOfNeighboors[2]=possibleposition[31]; //north
932                listOfNeighboors[3]=possibleposition[23]; //east
933                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
934            }
935            else if(findpos(pacLasVisPos,possibleposition[23])){
936                listOfNeighboors[1]=possibleposition[22]; //west
937                listOfNeighboors[2]=possibleposition[30]; //north
938                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
939            }
940            else if(findpos(pacLasVisPos,possibleposition[24])){
941                listOfNeighboors[2]=possibleposition[29]; //north
942                listOfNeighboors[3]=possibleposition[18]; //east
943                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
944            }
945            else if(findpos(pacLasVisPos,possibleposition[25])){
946                listOfNeighboors[1]=possibleposition[17]; //west
947                listOfNeighboors[2]=possibleposition[26]; //north
948                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
949            }
950            else if(findpos(pacLasVisPos,possibleposition[26])){
951                listOfNeighboors[0]=possibleposition[25]; //south
952                listOfNeighboors[1]=possibleposition[27]; //west
953                listOfNeighboors[3]=possibleposition[6]; //east
954                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
955            }
956            else if(findpos(pacLasVisPos,possibleposition[27])){
957                listOfNeighboors[1]=possibleposition[28]; //west
958                listOfNeighboors[2]=possibleposition[37]; //north
959                listOfNeighboors[3]=possibleposition[26]; //east
960                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
961            }
962            else if(findpos(pacLasVisPos,possibleposition[28])){
963                listOfNeighboors[1]=possibleposition[29]; //west
964                listOfNeighboors[2]=possibleposition[36]; //north
965                listOfNeighboors[3]=possibleposition[27]; //east
966                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
967            }
968            else if(findpos(pacLasVisPos,possibleposition[29])){
969                listOfNeighboors[0]=possibleposition[24]; //south
970                listOfNeighboors[1]=possibleposition[30]; //west
971                listOfNeighboors[3]=possibleposition[28]; //east
972                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
973            }
974            else if(findpos(pacLasVisPos,possibleposition[30])){
975                listOfNeighboors[0]=possibleposition[23]; //south
976                listOfNeighboors[2]=possibleposition[34]; //north
977                listOfNeighboors[3]=possibleposition[29]; //east
978                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
979            }
980            else if(findpos(pacLasVisPos,possibleposition[31])){
981                listOfNeighboors[0]=possibleposition[22]; //south
982                listOfNeighboors[1]=possibleposition[32]; //west
983                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
984            }
985            else if(findpos(pacLasVisPos,possibleposition[32])){
986                listOfNeighboors[2]=possibleposition[33]; //north
987                listOfNeighboors[3]=possibleposition[31]; //east
988                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
989            }
990            else if(findpos(pacLasVisPos,possibleposition[33])){
991                listOfNeighboors[0]=possibleposition[32]; //south
992                listOfNeighboors[3]=possibleposition[34]; //east
993                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
994            }
995            else if(findpos(pacLasVisPos,possibleposition[34])){
996                listOfNeighboors[0]=possibleposition[30]; //south
997                listOfNeighboors[1]=possibleposition[33]; //west
998                listOfNeighboors[2]=possibleposition[92]; //north
999                listOfNeighboors[3]=possibleposition[35]; //east
1000                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1001            }
1002            else if(findpos(pacLasVisPos,possibleposition[35])){
1003                listOfNeighboors[1]=possibleposition[34]; //west
1004                listOfNeighboors[2]=possibleposition[91]; //north
1005                listOfNeighboors[3]=possibleposition[36]; //east
1006                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1007            }
1008            else if(findpos(pacLasVisPos,possibleposition[36])){
1009                listOfNeighboors[0]=possibleposition[28]; //south
1010                listOfNeighboors[1]=possibleposition[35]; //west
1011                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1012            }
1013            else if(findpos(pacLasVisPos,possibleposition[37])){
1014                listOfNeighboors[0]=possibleposition[27]; //south
1015                listOfNeighboors[3]=possibleposition[38]; //east
1016                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1017            }
1018            else if(findpos(pacLasVisPos,possibleposition[38])){
1019                listOfNeighboors[1]=possibleposition[37]; //west
1020                listOfNeighboors[2]=possibleposition[39]; //north
1021                listOfNeighboors[3]=possibleposition[9]; //east
1022                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1023            }
1024            else if(findpos(pacLasVisPos,possibleposition[39])){
1025                listOfNeighboors[0]=possibleposition[38]; //south
1026                listOfNeighboors[1]=possibleposition[40]; //west
1027                listOfNeighboors[2]=possibleposition[45]; //north
1028                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1029            }
1030            else if(findpos(pacLasVisPos,possibleposition[40])){
1031                listOfNeighboors[1]=possibleposition[41]; //west
1032                //Not return in center
1033                listOfNeighboors[3]=possibleposition[39]; //east
1034                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1035            }
1036            else if(findpos(pacLasVisPos,possibleposition[41])){
1037                listOfNeighboors[0]=possibleposition[35]; //south
1038                listOfNeighboors[2]=possibleposition[43]; //north
1039                listOfNeighboors[3]=possibleposition[40]; //east
1040                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1041            }
1042            else if(findpos(pacLasVisPos,possibleposition[42])){
1043
1044                if(indexForSWNE==1){//nothing westward
1045                    return pacLasVisPos;
1046                }
1047
1048                listOfNeighboors[0]=possibleposition[39]; //south
1049                listOfNeighboors[2]=possibleposition[59]; //north
1050                listOfNeighboors[3]=possibleposition[43]; //east
1051                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1052            }
1053            else if(findpos(pacLasVisPos,possibleposition[43])){
1054                listOfNeighboors[0]=possibleposition[41]; //south
1055                listOfNeighboors[1]=possibleposition[42]; //west
1056                listOfNeighboors[2]=possibleposition[46]; //north
1057                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1058            }
1059            else if(findpos(pacLasVisPos,possibleposition[44])){
1060                listOfNeighboors[0]=possibleposition[40]; //south
1061                listOfNeighboors[2]=possibleposition[66]; //north
1062                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1063            }
1064            else if(findpos(pacLasVisPos,possibleposition[45])){
1065                listOfNeighboors[0]=possibleposition[39]; //south
1066                listOfNeighboors[2]=possibleposition[49]; //north
1067                listOfNeighboors[3]=possibleposition[10]; //east
1068                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1069            }
1070            else if(findpos(pacLasVisPos,possibleposition[46])){
1071                listOfNeighboors[0]=possibleposition[43]; //south
1072                listOfNeighboors[3]=possibleposition[47]; //east
1073                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1074            }
1075            else if(findpos(pacLasVisPos,possibleposition[47])){
1076                listOfNeighboors[1]=possibleposition[46]; //west
1077                listOfNeighboors[2]=possibleposition[52]; //north
1078                listOfNeighboors[3]=possibleposition[66]; //east
1079                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1080            }
1081            else if(findpos(pacLasVisPos,possibleposition[48])){
1082                listOfNeighboors[1]=possibleposition[66]; //west
1083                listOfNeighboors[2]=possibleposition[51]; //north
1084                listOfNeighboors[3]=possibleposition[49]; //east
1085                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1086            }
1087            else if(findpos(pacLasVisPos,possibleposition[49])){
1088                listOfNeighboors[0]=possibleposition[45]; //south
1089                listOfNeighboors[1]=possibleposition[48]; //west
1090                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1091            }
1092            else if(findpos(pacLasVisPos,possibleposition[50])){
1093                listOfNeighboors[1]=possibleposition[51]; //west
1094                listOfNeighboors[2]=possibleposition[61]; //north
1095                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1096            }
1097            else if(findpos(pacLasVisPos,possibleposition[51])){
1098                listOfNeighboors[0]=possibleposition[48]; //south
1099                listOfNeighboors[3]=possibleposition[50]; //east
1100                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1101            }
1102            else if(findpos(pacLasVisPos,possibleposition[52])){
1103                listOfNeighboors[0]=possibleposition[47]; //south
1104                listOfNeighboors[1]=possibleposition[53]; //west
1105                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1106            }
1107            else if(findpos(pacLasVisPos,possibleposition[53])){
1108                listOfNeighboors[2]=possibleposition[58]; //north
1109                listOfNeighboors[3]=possibleposition[52]; //east
1110                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1111            }
1112            else if(findpos(pacLasVisPos,possibleposition[54])){
1113                listOfNeighboors[0]=possibleposition[42]; //south
1114                listOfNeighboors[1]=possibleposition[55]; //west
1115                listOfNeighboors[2]=possibleposition[57]; //north
1116                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1117            }
1118            else if(findpos(pacLasVisPos,possibleposition[55])){
1119                listOfNeighboors[2]=possibleposition[56]; //north
1120                listOfNeighboors[3]=possibleposition[54]; //east
1121                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1122            }
1123            else if(findpos(pacLasVisPos,possibleposition[56])){
1124                listOfNeighboors[0]=possibleposition[55]; //south
1125                listOfNeighboors[2]=possibleposition[65]; //north
1126                listOfNeighboors[3]=possibleposition[57]; //east
1127                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1128            }
1129            else if(findpos(pacLasVisPos,possibleposition[57])){
1130                listOfNeighboors[0]=possibleposition[54]; //south
1131                listOfNeighboors[1]=possibleposition[56]; //west
1132                listOfNeighboors[2]=possibleposition[64]; //north
1133                listOfNeighboors[3]=possibleposition[58]; //east
1134                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1135            }
1136            else if(findpos(pacLasVisPos,possibleposition[58])){
1137                listOfNeighboors[0]=possibleposition[53]; //south
1138                listOfNeighboors[1]=possibleposition[57]; //west
1139                listOfNeighboors[3]=possibleposition[59]; //east
1140                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1141            }
1142            else if(findpos(pacLasVisPos,possibleposition[59])){
1143                listOfNeighboors[1]=possibleposition[58]; //west
1144                listOfNeighboors[2]=possibleposition[63]; //north
1145                listOfNeighboors[3]=possibleposition[60]; //east
1146                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1147            }
1148            else if(findpos(pacLasVisPos,possibleposition[60])){
1149                listOfNeighboors[1]=possibleposition[59]; //west
1150                listOfNeighboors[2]=possibleposition[62]; //north
1151                listOfNeighboors[3]=possibleposition[61]; //east
1152                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1153            }
1154            else if(findpos(pacLasVisPos,possibleposition[61])){
1155                listOfNeighboors[0]=possibleposition[50]; //south
1156                listOfNeighboors[1]=possibleposition[60]; //west
1157                listOfNeighboors[3]=possibleposition[13]; //east
1158                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1159            }
1160            else if(findpos(pacLasVisPos,possibleposition[62])){
1161                listOfNeighboors[0]=possibleposition[60]; //south
1162                listOfNeighboors[3]=possibleposition[16]; //east
1163                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1164            }
1165            else if(findpos(pacLasVisPos,possibleposition[63])){
1166                listOfNeighboors[0]=possibleposition[59]; //south
1167                listOfNeighboors[1]=possibleposition[64]; //west
1168                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1169            }
1170            else if(findpos(pacLasVisPos,possibleposition[64])){
1171                listOfNeighboors[0]=possibleposition[57]; //south
1172                listOfNeighboors[1]=possibleposition[65]; //west
1173                listOfNeighboors[3]=possibleposition[63]; //east
1174                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1175            }
1176            else if(findpos(pacLasVisPos,possibleposition[65])){
1177                listOfNeighboors[0]=possibleposition[56]; //south
1178                listOfNeighboors[3]=possibleposition[64]; //east
1179                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);
1180            }
1181            else if(findpos(pacLasVisPos,possibleposition[66])){
1182                //Not back in center
1183                listOfNeighboors[1]=possibleposition[47]; //west
1184                listOfNeighboors[3]=possibleposition[48]; //east
1185                return listOfNeighboors[indexForSWNE]; //Vector3(listOfNeighboors[indexForSWNE].x, 10, listOfNeighboors[indexForSWNE].z);           
1186            }
1187
1188        }
1189
1190
1191
1192
1193///////////////////////
1194
1195
1196
1197
1198
1199    Vector3 PacmanGhost::frontPosition(){
1200
1201    Vector3 neighborPos[4] = {Vector3(-1,-1,-1)};
1202    Vector3 frontPoint = Vector3(0,-1,0);
1203
1204
1205    findNeighboorPositions(this->lastPlayerPassedPoint, neighborPos, possibleposition);
1206
1207    for(int i=0; i<4; i++){
1208
1209     if((neighborPos[i]!=Vector3(-1,-1,-1))&&(neighborPos[i].y==10)){
1210     //y==10 to ignore many unwanted strange positions that pop up otherwise and create SIGSEV
1211       
1212        if(frontPoint==Vector3(0,-1,0)){
1213            frontPoint=neighborPos[i];
1214
1215                        }
1216        else if (graphDistance(this->getPlayerPos(), frontPoint)>graphDistance(this->getPlayerPos(), neighborPos[i])){
1217            frontPoint=neighborPos[i];
1218                        }
1219
1220                    }
1221        std::cout<<"bra"<<frontPoint<<endl;
1222                }
1223
1224    if(frontPoint==Vector3(0,-1,0)){
1225        //default
1226        return this->lastPlayerPassedPoint;
1227            }
1228    else{
1229        std::cout<<frontPoint<<endl;
1230        return frontPoint;
1231            }
1232    }
1233
1234
1235
1236
1237
1238
1239    void PacmanGhost::findNeighboorPositions(Vector3 actuelposition, Vector3 adjacentPositions[], Vector3 positionArray[]){     
1240            //this function should put in adjacentPosition[] the neighboors of lastPlayerPastPoint
1241
1242            if(findpos(actuelposition,possibleposition[0])){
1243               
1244
1245                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);  //need to do it everywhere !!!
1246                adjacentPositions[1]=positionArray[17]; //graphVertex(possibleposition[17]);
1247                adjacentPositions[2]=positionArray[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
1248            }
1249            else if(findpos(actuelposition,possibleposition[1])){
1250                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
1251                adjacentPositions[1]=positionArray[2]; //graphVertex(possibleposition[2]);
1252            }
1253            else if(findpos(actuelposition,possibleposition[2])){
1254                adjacentPositions[0]=positionArray[1]; //graphVertex(possibleposition[1]);
1255                adjacentPositions[1]=positionArray[3]; //graphVertex(possibleposition[3]);
1256            }
1257            else if(findpos(actuelposition,possibleposition[3])){
1258                adjacentPositions[0]=positionArray[2]; //graphVertex(possibleposition[2]);
1259                adjacentPositions[1]=positionArray[4]; //graphVertex(possibleposition[4]);
1260                adjacentPositions[2]=positionArray[5]; //graphVertex(possibleposition[5]);
1261            }
1262            else if(findpos(actuelposition,possibleposition[4])){
1263                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
1264                adjacentPositions[1]=positionArray[6]; //graphVertex(possibleposition[6]);
1265            }
1266            else if(findpos(actuelposition,possibleposition[5])){
1267                adjacentPositions[0]=positionArray[3]; //graphVertex(possibleposition[3]);
1268                adjacentPositions[1]=positionArray[7]; //graphVertex(possibleposition[7]);
1269            }
1270            else if(findpos(actuelposition,possibleposition[6])){
1271                adjacentPositions[0]=positionArray[4]; //graphVertex(possibleposition[4]);
1272                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
1273                adjacentPositions[2]=positionArray[26]; //graphVertex(possibleposition[26]);
1274            }
1275            else if(findpos(actuelposition,possibleposition[7])){
1276                adjacentPositions[0]=positionArray[5]; //graphVertex(possibleposition[5]);
1277                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
1278            }
1279            else if(findpos(actuelposition,possibleposition[8])){
1280                adjacentPositions[0]=positionArray[7]; //graphVertex(possibleposition[7]);
1281                adjacentPositions[1]=positionArray[9]; //graphVertex(possibleposition[9]);
1282            }
1283            else if(findpos(actuelposition,possibleposition[9])){
1284                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
1285                adjacentPositions[1]=positionArray[8]; //graphVertex(possibleposition[8]);
1286                adjacentPositions[2]=positionArray[10]; //graphVertex(possibleposition[10]);
1287                adjacentPositions[3]=positionArray[38]; //graphVertex(possibleposition[38]);
1288            }
1289            else if(findpos(actuelposition,possibleposition[10])){
1290                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
1291                adjacentPositions[1]=positionArray[11]; //graphVertex(possibleposition[11]);
1292                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
1293            }
1294            else if(findpos(actuelposition,possibleposition[11])){
1295                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
1296                adjacentPositions[1]=positionArray[12]; //graphVertex(possibleposition[12]);
1297                adjacentPositions[2]=positionArray[13]; //graphVertex(possibleposition[13]);
1298            }
1299            else if(findpos(actuelposition,possibleposition[12])){
1300                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
1301                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
1302            }
1303            else if(findpos(actuelposition,possibleposition[13])){
1304                adjacentPositions[0]=positionArray[11]; //graphVertex(possibleposition[11]);
1305                adjacentPositions[1]=positionArray[14]; //graphVertex(possibleposition[14]);
1306                adjacentPositions[2]=positionArray[16]; //graphVertex(possibleposition[16]);
1307                adjacentPositions[3]=positionArray[61]; //graphVertex(possibleposition[61]);
1308            }
1309            else if(findpos(actuelposition,possibleposition[14])){
1310                adjacentPositions[0]=positionArray[12]; //graphVertex(possibleposition[12]);
1311                adjacentPositions[1]=positionArray[13]; //graphVertex(possibleposition[13]);
1312                adjacentPositions[2]=positionArray[15]; //graphVertex(possibleposition[15]);
1313            }
1314            else if(findpos(actuelposition,possibleposition[15])){
1315                adjacentPositions[0]=positionArray[14]; //graphVertex(possibleposition[14]);
1316                adjacentPositions[1]=positionArray[16]; //graphVertex(possibleposition[16]);
1317            }
1318            else if(findpos(actuelposition,possibleposition[16])){
1319                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
1320                adjacentPositions[1]=positionArray[15]; //graphVertex(possibleposition[15]);
1321                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
1322            }
1323            else if(findpos(actuelposition,possibleposition[17])){
1324                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
1325                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
1326            }
1327            else if(findpos(actuelposition,possibleposition[18])){
1328                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
1329                adjacentPositions[1]=positionArray[24]; //graphVertex(possibleposition[24]);               
1330            }
1331            else if(findpos(actuelposition,possibleposition[19])){
1332                adjacentPositions[0]=positionArray[0]; //graphVertex(possibleposition[0]);
1333                adjacentPositions[1]=positionArray[18]; //graphVertex(possibleposition[18]);
1334                adjacentPositions[2]=positionArray[20]; //graphVertex(possibleposition[20]);
1335                         }
1336            else if(findpos(actuelposition,possibleposition[20])){
1337                adjacentPositions[0]=positionArray[19]; //graphVertex(possibleposition[19]);
1338                adjacentPositions[1]=positionArray[21]; //graphVertex(possibleposition[21]);
1339                       }
1340            else if(findpos(actuelposition,possibleposition[21])){
1341                adjacentPositions[0]=positionArray[20]; //graphVertex(possibleposition[20]);
1342                adjacentPositions[1]=positionArray[22]; //graphVertex(possibleposition[22]);
1343                       }
1344            else if(findpos(actuelposition,possibleposition[22])){
1345                adjacentPositions[0]=positionArray[21]; //graphVertex(possibleposition[21]);
1346                adjacentPositions[1]=positionArray[23]; //graphVertex(possibleposition[23]);
1347                adjacentPositions[2]=positionArray[31]; //graphVertex(possibleposition[31]);
1348                          }
1349            else if(findpos(actuelposition,possibleposition[23])){
1350                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
1351                adjacentPositions[1]=positionArray[30]; //graphVertex(possibleposition[30]);
1352                       }
1353            else if(findpos(actuelposition,possibleposition[24])){
1354                adjacentPositions[0]=positionArray[18]; //graphVertex(possibleposition[18]);
1355                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
1356                       }
1357            else if(findpos(actuelposition,possibleposition[25])){
1358                adjacentPositions[0]=positionArray[17]; //graphVertex(possibleposition[17]);
1359                adjacentPositions[1]=positionArray[26]; //graphVertex(possibleposition[26]);
1360                       }
1361            else if(findpos(actuelposition,possibleposition[26])){
1362                adjacentPositions[0]=positionArray[6]; //graphVertex(possibleposition[6]);
1363                adjacentPositions[1]=positionArray[25]; //graphVertex(possibleposition[25]);
1364                adjacentPositions[2]=positionArray[27]; //graphVertex(possibleposition[27]);
1365                         }
1366            else if(findpos(actuelposition,possibleposition[27])){
1367                adjacentPositions[0]=positionArray[26]; //graphVertex(possibleposition[26]);
1368                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
1369                adjacentPositions[2]=positionArray[37]; //graphVertex(possibleposition[37]);
1370                          }
1371            else if(findpos(actuelposition,possibleposition[28])){
1372                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
1373                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
1374                adjacentPositions[2]=positionArray[36]; //graphVertex(possibleposition[36]);
1375                          }
1376            else if(findpos(actuelposition,possibleposition[29])){
1377                adjacentPositions[0]=positionArray[24]; //graphVertex(possibleposition[24]);
1378                adjacentPositions[1]=positionArray[28]; //graphVertex(possibleposition[28]);
1379                adjacentPositions[2]=positionArray[30]; //graphVertex(possibleposition[30]);
1380                          }
1381            else if(findpos(actuelposition,possibleposition[30])){
1382                adjacentPositions[0]=positionArray[23]; //graphVertex(possibleposition[23]);
1383                adjacentPositions[1]=positionArray[29]; //graphVertex(possibleposition[29]);
1384                adjacentPositions[2]=positionArray[34]; //graphVertex(possibleposition[34]);
1385                          }
1386            else if(findpos(actuelposition,possibleposition[31])){
1387                adjacentPositions[0]=positionArray[22]; //graphVertex(possibleposition[22]);
1388                adjacentPositions[1]=positionArray[32]; //graphVertex(possibleposition[32]);
1389                       }
1390            else if(findpos(actuelposition,possibleposition[32])){
1391                adjacentPositions[0]=positionArray[31]; //graphVertex(possibleposition[31]);
1392                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
1393                       }
1394            else if(findpos(actuelposition,possibleposition[33])){
1395                adjacentPositions[0]=positionArray[32]; //graphVertex(possibleposition[32]);
1396                adjacentPositions[1]=positionArray[34]; //graphVertex(possibleposition[34]);
1397                       }
1398            else if(findpos(actuelposition,possibleposition[34])){
1399                adjacentPositions[0]=positionArray[30]; //graphVertex(possibleposition[30]);
1400                adjacentPositions[1]=positionArray[33]; //graphVertex(possibleposition[33]);
1401                adjacentPositions[2]=positionArray[35]; //graphVertex(possibleposition[35]);
1402                adjacentPositions[3]=positionArray[42]; //graphVertex(possibleposition[42]);
1403               
1404            }
1405            else if(findpos(actuelposition,possibleposition[35])){
1406                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
1407                adjacentPositions[1]=positionArray[36]; //graphVertex(possibleposition[36]);
1408                adjacentPositions[2]=positionArray[41]; //graphVertex(possibleposition[41]);
1409                          }
1410            else if(findpos(actuelposition,possibleposition[36])){
1411                adjacentPositions[0]=positionArray[28]; //graphVertex(possibleposition[28]);
1412                adjacentPositions[1]=positionArray[35]; //graphVertex(possibleposition[35]);
1413                       }
1414            else if(findpos(actuelposition,possibleposition[37])){
1415                adjacentPositions[0]=positionArray[27]; //graphVertex(possibleposition[27]);
1416                adjacentPositions[1]=positionArray[38]; //graphVertex(possibleposition[38]);
1417                       }
1418            else if(findpos(actuelposition,possibleposition[38])){
1419                adjacentPositions[0]=positionArray[9]; //graphVertex(possibleposition[9]);
1420                adjacentPositions[1]=positionArray[37]; //graphVertex(possibleposition[37]);
1421                adjacentPositions[2]=positionArray[39]; //graphVertex(possibleposition[39]);
1422                         }
1423            else if(findpos(actuelposition,possibleposition[39])){
1424                adjacentPositions[0]=positionArray[38]; //graphVertex(possibleposition[38]);
1425                adjacentPositions[1]=positionArray[40]; //graphVertex(possibleposition[40]);
1426                adjacentPositions[2]=positionArray[45]; //graphVertex(possibleposition[45]);
1427                          }
1428            else if(findpos(actuelposition,possibleposition[40])){
1429                adjacentPositions[0]=positionArray[39]; //graphVertex(possibleposition[39]);
1430                adjacentPositions[1]=positionArray[41]; //graphVertex(possibleposition[41]);
1431            }
1432            else if(findpos(actuelposition,possibleposition[41])){
1433                adjacentPositions[0]=positionArray[35]; //graphVertex(possibleposition[35]);
1434                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
1435                       }
1436            else if(findpos(actuelposition,possibleposition[42])){
1437                adjacentPositions[0]=positionArray[34]; //graphVertex(possibleposition[34]);
1438                adjacentPositions[1]=positionArray[43]; //graphVertex(possibleposition[43]);
1439                adjacentPositions[2]=positionArray[54]; //graphVertex(possibleposition[54]);
1440                          }
1441            else if(findpos(actuelposition,possibleposition[43])){
1442                adjacentPositions[0]=positionArray[41]; //graphVertex(possibleposition[41]);
1443                adjacentPositions[1]=positionArray[46]; //graphVertex(possibleposition[46]);
1444                       }
1445            else if(findpos(actuelposition,possibleposition[44])){
1446                adjacentPositions[0]=positionArray[40]; //graphVertex(possibleposition[40]);
1447                adjacentPositions[1]=positionArray[66]; //graphVertex(possibleposition[66]);
1448                       }
1449            else if(findpos(actuelposition,possibleposition[45])){
1450                adjacentPositions[0]=positionArray[10]; //graphVertex(possibleposition[10]);
1451                adjacentPositions[1]=positionArray[39]; //graphVertex(possibleposition[39]);
1452                adjacentPositions[2]=positionArray[49]; //graphVertex(possibleposition[49]);
1453                          }
1454            else if(findpos(actuelposition,possibleposition[46])){
1455                adjacentPositions[0]=positionArray[43]; //graphVertex(possibleposition[43]);
1456                adjacentPositions[1]=positionArray[47]; //graphVertex(possibleposition[47]);
1457                       }
1458            else if(findpos(actuelposition,possibleposition[47])){
1459                adjacentPositions[0]=positionArray[46]; //graphVertex(possibleposition[46]);
1460                adjacentPositions[1]=positionArray[52]; //graphVertex(possibleposition[52]);
1461                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
1462                          }
1463            else if(findpos(actuelposition,possibleposition[48])){
1464                adjacentPositions[0]=positionArray[49]; //graphVertex(possibleposition[49]);
1465                adjacentPositions[1]=positionArray[51]; //graphVertex(possibleposition[51]);
1466                adjacentPositions[2]=positionArray[66]; //graphVertex(possibleposition[66]);
1467                          }
1468            else if(findpos(actuelposition,possibleposition[49])){
1469                adjacentPositions[0]=positionArray[45]; //graphVertex(possibleposition[45]);
1470                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
1471                       }
1472            else if(findpos(actuelposition,possibleposition[50])){
1473                adjacentPositions[0]=positionArray[51]; //graphVertex(possibleposition[51]);
1474                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
1475                       }
1476            else if(findpos(actuelposition,possibleposition[51])){
1477                adjacentPositions[0]=positionArray[48]; //graphVertex(possibleposition[48]);
1478                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
1479                       }
1480            else if(findpos(actuelposition,possibleposition[52])){
1481                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
1482                adjacentPositions[1]=positionArray[53]; //graphVertex(possibleposition[53]);
1483                       }
1484            else if(findpos(actuelposition,possibleposition[53])){
1485                adjacentPositions[0]=positionArray[52]; //graphVertex(possibleposition[52]);
1486                adjacentPositions[1]=positionArray[58]; //graphVertex(possibleposition[58]);
1487                       }
1488            else if(findpos(actuelposition,possibleposition[54])){
1489                adjacentPositions[0]=positionArray[42]; //graphVertex(possibleposition[42]);
1490                adjacentPositions[1]=positionArray[55]; //graphVertex(possibleposition[55]);
1491                adjacentPositions[2]=positionArray[57]; //graphVertex(possibleposition[57]);
1492                          }
1493            else if(findpos(actuelposition,possibleposition[55])){
1494                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
1495                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
1496                       }
1497            else if(findpos(actuelposition,possibleposition[56])){
1498                adjacentPositions[0]=positionArray[55]; //graphVertex(possibleposition[55]);
1499                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
1500                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
1501                          }
1502            else if(findpos(actuelposition,possibleposition[57])){
1503                adjacentPositions[0]=positionArray[54]; //graphVertex(possibleposition[54]);
1504                adjacentPositions[1]=positionArray[56]; //graphVertex(possibleposition[56]);
1505                adjacentPositions[2]=positionArray[58]; //graphVertex(possibleposition[58]);
1506                adjacentPositions[3]=positionArray[64]; //graphVertex(possibleposition[64]);
1507               
1508            }
1509            else if(findpos(actuelposition,possibleposition[58])){
1510                adjacentPositions[0]=positionArray[53]; //graphVertex(possibleposition[53]);
1511                adjacentPositions[1]=positionArray[57]; //graphVertex(possibleposition[57]);
1512                adjacentPositions[2]=positionArray[59]; //graphVertex(possibleposition[59]);
1513                          }
1514            else if(findpos(actuelposition,possibleposition[59])){
1515                adjacentPositions[0]=positionArray[58]; //graphVertex(possibleposition[58]);
1516                adjacentPositions[1]=positionArray[59]; //graphVertex(possibleposition[59]);
1517                adjacentPositions[2]=positionArray[63]; //graphVertex(possibleposition[63]);
1518                          }
1519            else if(findpos(actuelposition,possibleposition[60])){
1520                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
1521                adjacentPositions[1]=positionArray[61]; //graphVertex(possibleposition[61]);
1522                adjacentPositions[2]=positionArray[62]; //graphVertex(possibleposition[62]);
1523                          }
1524            else if(findpos(actuelposition,possibleposition[61])){
1525                adjacentPositions[0]=positionArray[13]; //graphVertex(possibleposition[13]);
1526                adjacentPositions[1]=positionArray[50]; //graphVertex(possibleposition[50]);
1527                adjacentPositions[2]=positionArray[60]; //graphVertex(possibleposition[60]);
1528                          }
1529            else if(findpos(actuelposition,possibleposition[62])){
1530                adjacentPositions[0]=positionArray[16]; //graphVertex(possibleposition[16]);
1531                adjacentPositions[1]=positionArray[60]; //graphVertex(possibleposition[60]);
1532                       }
1533            else if(findpos(actuelposition,possibleposition[63])){
1534                adjacentPositions[0]=positionArray[59]; //graphVertex(possibleposition[59]);
1535                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
1536                       }
1537            else if(findpos(actuelposition,possibleposition[64])){
1538                adjacentPositions[0]=positionArray[57]; //graphVertex(possibleposition[57]);
1539                adjacentPositions[1]=positionArray[63]; //graphVertex(possibleposition[63]);
1540                adjacentPositions[2]=positionArray[65]; //graphVertex(possibleposition[65]);
1541                          }
1542            else if(findpos(actuelposition,possibleposition[65])){
1543                adjacentPositions[0]=positionArray[56]; //graphVertex(possibleposition[56]);
1544                adjacentPositions[1]=positionArray[64]; //graphVertex(possibleposition[64]);
1545                       }
1546            else if(findpos(actuelposition,possibleposition[66])){
1547                adjacentPositions[0]=positionArray[47]; //graphVertex(possibleposition[47]);
1548                adjacentPositions[1]=positionArray[48]; //graphVertex(possibleposition[48]);
1549                       }
1550    }
1551
1552
1553}
Note: See TracBrowser for help on using the repository browser.