Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Red Pacman seems to work even better

  • Property svn:executable set to *
File size: 59.8 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::setPureArrayPos(Vector3 &posToSet){
227        //given that the position of a pacman is generally not "neat",
228        //we need to set it to the nearest point on the map
229        // if the pacman is not moving anymore, i.e. has reached a point
230        int i=0;
231        while(!(findpos(possibleposition[i], posToSet))){
232            i++;
233        }
234        return possibleposition[i];
235    }*/
236
237    Vector3 PacmanGhost::getPlayerPos()
238    {
239        for (PacmanGelb* player : ObjectList<PacmanGelb>())
240        {
241            return player->getWorldPosition();
242        }
243        return Vector3(0,0,0); //default, should not be used
244   
245    }
246
247
248
249
250    ///
251    //// getShortestPath   /////////
252    ///
253
254       
255       
256
257        Vector3 PacmanGhost::getShortestPath(Vector3 start, Vector3 goal){
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
262    graphVertex listOfVerticesM[67]; //our list of all possible graphs
263    graphVertex* actualVertex;// = new graphVertex(); //we will walk through the array with a pointer
264   
265        if(start==goal){ // basic case
266            return start; 
267        }
268
269        for(int an=0; an < 67; an++){
270      listOfVerticesM[an]= graphVertex(possibleposition[an]); //same position order as in other file
271    if(start==possibleposition[an]){
272     actualVertex= &listOfVerticesM[an]; //our pointer points to the graph with position start in array
273    //cout<<an<<endl;
274            }
275        }
276
277        actualVertex->alreadyVisited=true; //our start point is now visited
278        actualVertex->shortestDistanceToStart=0; //At our start point, distance from start is 0
279        findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
280        // second parameter is an array ! //third is our global array
281
282        while(actualVertex->position!=goal){
283            for(int h=0;h < 4; h++){
284                if(actualVertex->adjacentVertices[h]!=nullptr){ //check all neighboors of our current graphVertex
285 
286         //h=2 and 3 never reached
287                    updateShortestDistanceToStart(*actualVertex, *actualVertex->adjacentVertices[h]);
288                } //we "update" the neighboors of our new visited vertex
289       
290            }
291           
292            actualVertex=findNextVertexToConsider(listOfVerticesM);
293            actualVertex->alreadyVisited=true;
294    //cout<<actualVertex->position<<endl;
295            if(actualVertex->position!=goal){
296                findNeighboorVertices(actualVertex->position, actualVertex->adjacentVertices, listOfVerticesM); 
297                //we find the neighboors of our new visited vertex
298                }
299        }
300
301    //cout<<"meuejeeke"<<endl; never reached
302
303        //we should have reached our goal at this point
304
305        while(actualVertex->actuelPredecessor->actuelPredecessor!=nullptr){ //the predecessor of our predecessor
306            actualVertex=actualVertex->actuelPredecessor;
307        }
308        // the predecessor is our starting point, in other words we are now on an
309        //adjacent vertex of the start
310
311        return actualVertex->position; //we return the position of this - adjacent to start - vertex
312    }
313
314//end of getShortestPath
315
316
317    int PacmanGhost::graphDistance(Vector3 start, Vector3 goal){
318    //cout<<hgj++<<endl;
319        Vector3 differenceVector= Vector3(abs(goal.x-start.x), 0,abs(goal.z-start.z));
320
321        return differenceVector.x+differenceVector.z;
322    }
323
324    void PacmanGhost::updateShortestDistanceToStart(graphVertex &vertex, graphVertex &neighboor){
325        //apply this method to all non visited neighboors of a vertex.
326        // This method should always be run on a vertex after we marked it as visited.
327        if(neighboor.alreadyVisited==false){ //we only consider non visited neighboors.
328            if((vertex.shortestDistanceToStart!=std::numeric_limits<int>::max())&&
329        (neighboor.shortestDistanceToStart > vertex.shortestDistanceToStart + 
330                graphDistance(vertex.position, neighboor.position))){ //need to consider overflow case !
331       
332                neighboor.shortestDistanceToStart= vertex.shortestDistanceToStart + 
333                graphDistance(vertex.position, neighboor.position);
334                neighboor.actuelPredecessor = &vertex;
335            }
336        }
337    }
338
339    void PacmanGhost::findNearestNonVisitedNeighboor (graphVertex &vertex){ 
340            //find nearest non visited neighboor of a given already visited vertex
341        int shortestDistance = -1;
342        graphVertex* nearestNonVisitedNeighboor=nullptr;//=graphVertex(); //by default there is not any.
343        //Also, if all neighboors are already visited, we return nullptr, i.e. there is no
344        //nearest non visited neighboor.
345        for(int i=0; i < 4; i++){
346            if((vertex.adjacentVertices[i]!=nullptr)&&(vertex.adjacentVertices[i]->alreadyVisited==false)){
347                if(shortestDistance==-1){   //(concerns line above) we want a non visited neighboor
348                    shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
349                    nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
350    //cout<<shortestDistance<<endl;
351                }
352                else if(graphDistance(vertex.position, vertex.adjacentVertices[i]->position)<shortestDistance){
353                    shortestDistance= graphDistance(vertex.position, vertex.adjacentVertices[i]->position);
354                    nearestNonVisitedNeighboor=vertex.adjacentVertices[i]; //warning, both sides are pointer adresses !
355        //cout<<(hgj++)%4<<endl;
356                }
357            }
358        }
359        vertex.currentNearestNonVisitedNeighboor = nearestNonVisitedNeighboor; //warning, both sides are pointer adresses !
360    //cout<<hgj++<<endl;
361    }
362
363
364    PacmanGhost::graphVertex* PacmanGhost::findNextVertexToConsider(graphVertex listOfVerticesP[]){ //find next, nearest from start, non visited vertex in our listOfVertices array
365
366        int shortestDistance = -1;
367        graphVertex* nextVertexToConsider;
368
369        for(int i=0; i < 67; i++){ //we loop over all possible positions
370
371            if(listOfVerticesP[i].alreadyVisited==true){ //vertex should already be visited
372
373                findNearestNonVisitedNeighboor(listOfVerticesP[i]); //we update nearest neighboor
374                //of all visited vertices given that one of the nearest neighboor of a visited
375                // vertex is now also visited because it was chosen as next optimal vertex
376
377                if(listOfVerticesP[i].currentNearestNonVisitedNeighboor!=nullptr){ //we want a candidate!
378                if(shortestDistance==-1){ //our first possible candidate
379
380            shortestDistance=graphDistance(listOfVerticesP[i].position, 
381            listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
382            listOfVerticesP[i].shortestDistanceToStart;
383
384            nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
385    //adress of nextVertexToConsider is that of pointer currentNearestNonVisitedNeighboor
386
387                }
388                else if(shortestDistance > graphDistance(listOfVerticesP[i].position, 
389                listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
390                    listOfVerticesP[i].shortestDistanceToStart){//if better candidate than our first candidate available
391
392            shortestDistance=graphDistance(listOfVerticesP[i].position, 
393            listOfVerticesP[i].currentNearestNonVisitedNeighboor->position) + 
394            listOfVerticesP[i].shortestDistanceToStart;
395
396            nextVertexToConsider=listOfVerticesP[i].currentNearestNonVisitedNeighboor;
397    //we dont need the & because we are not giving the adress of the array element
398    //listOfVerticesP[i] but that of the pointer currentNearestNonVisitedNeighboor
399                    }
400                }
401            }
402            //we want after all to return the nearest non visited neighboor
403        }
404
405        return nextVertexToConsider; //returns adress nextVertexToConsider is pointing to in array
406    }
407
408    //////////////////////////////////////////////////////////////////////////////////////////////
409
410    //if vertex already visited, call function on it and reapeat until you reach non visited vertex
411    // ---> not sure if a good idea because we risk infinite loop
412
413    //-215 -185 -135 -70 -20 0 20 70 135 185 215
414
415    //-195 -135 -85 -35 15 60 105 150 195 245
416
417    void PacmanGhost::findNeighboorVertices(Vector3 actuelposition, graphVertex* adjacentVertices[], graphVertex listOfVerticesP2[]){     
418
419
420            if(findpos(actuelposition,possibleposition[0])){
421                // we should use listOfVerticesP2[i] instead of possibleposition[i] I think
422                // so that all neighboors are "the same"
423                adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]);  //need to do it everywhere !!!
424                adjacentVertices[1]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]);
425                adjacentVertices[2]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]); //maybe a vector would be more suitable ?
426            }
427            else if(findpos(actuelposition,possibleposition[1])){
428                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
429                adjacentVertices[1]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]);
430            }
431            else if(findpos(actuelposition,possibleposition[2])){
432                adjacentVertices[0]=&listOfVerticesP2[1]; //graphVertex(possibleposition[1]);
433                adjacentVertices[1]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
434            }
435            else if(findpos(actuelposition,possibleposition[3])){
436                adjacentVertices[0]=&listOfVerticesP2[2]; //graphVertex(possibleposition[2]);
437                adjacentVertices[1]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]);
438                adjacentVertices[2]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]);
439            }
440            else if(findpos(actuelposition,possibleposition[4])){
441                adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
442                adjacentVertices[1]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
443            }
444            else if(findpos(actuelposition,possibleposition[5])){
445                adjacentVertices[0]=&listOfVerticesP2[3]; //graphVertex(possibleposition[3]);
446                adjacentVertices[1]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]);
447            }
448            else if(findpos(actuelposition,possibleposition[6])){
449                adjacentVertices[0]=&listOfVerticesP2[4]; //graphVertex(possibleposition[4]);
450                adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
451                adjacentVertices[2]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
452            }
453            else if(findpos(actuelposition,possibleposition[7])){
454                adjacentVertices[0]=&listOfVerticesP2[5]; //graphVertex(possibleposition[5]);
455                adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]);
456            }
457            else if(findpos(actuelposition,possibleposition[8])){
458                adjacentVertices[0]=&listOfVerticesP2[7]; //graphVertex(possibleposition[7]);
459                adjacentVertices[1]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
460            }
461            else if(findpos(actuelposition,possibleposition[9])){
462                adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
463                adjacentVertices[1]=&listOfVerticesP2[8]; //graphVertex(possibleposition[8]);
464                adjacentVertices[2]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
465                adjacentVertices[3]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
466            }
467            else if(findpos(actuelposition,possibleposition[10])){
468                adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
469                adjacentVertices[1]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
470                adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
471            }
472            else if(findpos(actuelposition,possibleposition[11])){
473                adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
474                adjacentVertices[1]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]);
475                adjacentVertices[2]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
476            }
477            else if(findpos(actuelposition,possibleposition[12])){
478                adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
479                adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
480            }
481            else if(findpos(actuelposition,possibleposition[13])){
482                adjacentVertices[0]=&listOfVerticesP2[11]; //graphVertex(possibleposition[11]);
483                adjacentVertices[1]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
484                adjacentVertices[2]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
485                adjacentVertices[3]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
486            }
487            else if(findpos(actuelposition,possibleposition[14])){
488                adjacentVertices[0]=&listOfVerticesP2[12]; //graphVertex(possibleposition[12]);
489                adjacentVertices[1]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
490                adjacentVertices[2]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]);
491            }
492            else if(findpos(actuelposition,possibleposition[15])){
493                adjacentVertices[0]=&listOfVerticesP2[14]; //graphVertex(possibleposition[14]);
494                adjacentVertices[1]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
495            }
496            else if(findpos(actuelposition,possibleposition[16])){
497                adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
498                adjacentVertices[1]=&listOfVerticesP2[15]; //graphVertex(possibleposition[15]);
499                adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]);
500            }
501            else if(findpos(actuelposition,possibleposition[17])){
502                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
503                adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]);
504            }
505            else if(findpos(actuelposition,possibleposition[18])){
506                adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]);
507                adjacentVertices[1]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]);               
508            }
509            else if(findpos(actuelposition,possibleposition[19])){
510                adjacentVertices[0]=&listOfVerticesP2[0]; //graphVertex(possibleposition[0]);
511                adjacentVertices[1]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]);
512                adjacentVertices[2]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]);
513                         }
514            else if(findpos(actuelposition,possibleposition[20])){
515                adjacentVertices[0]=&listOfVerticesP2[19]; //graphVertex(possibleposition[19]);
516                adjacentVertices[1]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]);
517                       }
518            else if(findpos(actuelposition,possibleposition[21])){
519                adjacentVertices[0]=&listOfVerticesP2[20]; //graphVertex(possibleposition[20]);
520                adjacentVertices[1]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
521                       }
522            else if(findpos(actuelposition,possibleposition[22])){
523                adjacentVertices[0]=&listOfVerticesP2[21]; //graphVertex(possibleposition[21]);
524                adjacentVertices[1]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]);
525                adjacentVertices[2]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]);
526                          }
527            else if(findpos(actuelposition,possibleposition[23])){
528                adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
529                adjacentVertices[1]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
530                       }
531            else if(findpos(actuelposition,possibleposition[24])){
532                adjacentVertices[0]=&listOfVerticesP2[18]; //graphVertex(possibleposition[18]);
533                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
534                       }
535            else if(findpos(actuelposition,possibleposition[25])){
536                adjacentVertices[0]=&listOfVerticesP2[17]; //graphVertex(possibleposition[17]);
537                adjacentVertices[1]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
538                       }
539            else if(findpos(actuelposition,possibleposition[26])){
540                adjacentVertices[0]=&listOfVerticesP2[6]; //graphVertex(possibleposition[6]);
541                adjacentVertices[1]=&listOfVerticesP2[25]; //graphVertex(possibleposition[25]);
542                adjacentVertices[2]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
543                         }
544            else if(findpos(actuelposition,possibleposition[27])){
545                adjacentVertices[0]=&listOfVerticesP2[26]; //graphVertex(possibleposition[26]);
546                adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
547                adjacentVertices[2]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]);
548                          }
549            else if(findpos(actuelposition,possibleposition[28])){
550                adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
551                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
552                adjacentVertices[2]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]);
553                          }
554            else if(findpos(actuelposition,possibleposition[29])){
555                adjacentVertices[0]=&listOfVerticesP2[24]; //graphVertex(possibleposition[24]);
556                adjacentVertices[1]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
557                adjacentVertices[2]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
558                          }
559            else if(findpos(actuelposition,possibleposition[30])){
560                adjacentVertices[0]=&listOfVerticesP2[23]; //graphVertex(possibleposition[23]);
561                adjacentVertices[1]=&listOfVerticesP2[29]; //graphVertex(possibleposition[29]);
562                adjacentVertices[2]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
563                          }
564            else if(findpos(actuelposition,possibleposition[31])){
565                adjacentVertices[0]=&listOfVerticesP2[22]; //graphVertex(possibleposition[22]);
566                adjacentVertices[1]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]);
567                       }
568            else if(findpos(actuelposition,possibleposition[32])){
569                adjacentVertices[0]=&listOfVerticesP2[31]; //graphVertex(possibleposition[31]);
570                adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]);
571                       }
572            else if(findpos(actuelposition,possibleposition[33])){
573                adjacentVertices[0]=&listOfVerticesP2[32]; //graphVertex(possibleposition[32]);
574                adjacentVertices[1]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
575                       }
576            else if(findpos(actuelposition,possibleposition[34])){
577                adjacentVertices[0]=&listOfVerticesP2[30]; //graphVertex(possibleposition[30]);
578                adjacentVertices[1]=&listOfVerticesP2[33]; //graphVertex(possibleposition[33]);
579                adjacentVertices[2]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
580                adjacentVertices[3]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]);
581               
582            }
583            else if(findpos(actuelposition,possibleposition[35])){
584                adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
585                adjacentVertices[1]=&listOfVerticesP2[36]; //graphVertex(possibleposition[36]);
586                adjacentVertices[2]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
587                          }
588            else if(findpos(actuelposition,possibleposition[36])){
589                adjacentVertices[0]=&listOfVerticesP2[28]; //graphVertex(possibleposition[28]);
590                adjacentVertices[1]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
591                       }
592            else if(findpos(actuelposition,possibleposition[37])){
593                adjacentVertices[0]=&listOfVerticesP2[27]; //graphVertex(possibleposition[27]);
594                adjacentVertices[1]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
595                       }
596            else if(findpos(actuelposition,possibleposition[38])){
597                adjacentVertices[0]=&listOfVerticesP2[9]; //graphVertex(possibleposition[9]);
598                adjacentVertices[1]=&listOfVerticesP2[37]; //graphVertex(possibleposition[37]);
599                adjacentVertices[2]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
600                         }
601            else if(findpos(actuelposition,possibleposition[39])){
602                adjacentVertices[0]=&listOfVerticesP2[38]; //graphVertex(possibleposition[38]);
603                adjacentVertices[1]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]);
604                adjacentVertices[2]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
605                          }
606            else if(findpos(actuelposition,possibleposition[40])){
607                adjacentVertices[0]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
608                adjacentVertices[1]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
609            }
610            else if(findpos(actuelposition,possibleposition[41])){
611                adjacentVertices[0]=&listOfVerticesP2[35]; //graphVertex(possibleposition[35]);
612                adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
613                       }
614            else if(findpos(actuelposition,possibleposition[42])){
615                adjacentVertices[0]=&listOfVerticesP2[34]; //graphVertex(possibleposition[34]);
616                adjacentVertices[1]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
617                adjacentVertices[2]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
618                          }
619            else if(findpos(actuelposition,possibleposition[43])){
620                adjacentVertices[0]=&listOfVerticesP2[41]; //graphVertex(possibleposition[41]);
621                adjacentVertices[1]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]);
622                       }
623            else if(findpos(actuelposition,possibleposition[44])){
624                adjacentVertices[0]=&listOfVerticesP2[40]; //graphVertex(possibleposition[40]);
625                adjacentVertices[1]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
626                       }
627            else if(findpos(actuelposition,possibleposition[45])){
628                adjacentVertices[0]=&listOfVerticesP2[10]; //graphVertex(possibleposition[10]);
629                adjacentVertices[1]=&listOfVerticesP2[39]; //graphVertex(possibleposition[39]);
630                adjacentVertices[2]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]);
631                          }
632            else if(findpos(actuelposition,possibleposition[46])){
633                adjacentVertices[0]=&listOfVerticesP2[43]; //graphVertex(possibleposition[43]);
634                adjacentVertices[1]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
635                       }
636            else if(findpos(actuelposition,possibleposition[47])){
637                adjacentVertices[0]=&listOfVerticesP2[46]; //graphVertex(possibleposition[46]);
638                adjacentVertices[1]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]);
639                adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
640                          }
641            else if(findpos(actuelposition,possibleposition[48])){
642                adjacentVertices[0]=&listOfVerticesP2[49]; //graphVertex(possibleposition[49]);
643                adjacentVertices[1]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]);
644                adjacentVertices[2]=&listOfVerticesP2[66]; //graphVertex(possibleposition[66]);
645                          }
646            else if(findpos(actuelposition,possibleposition[49])){
647                adjacentVertices[0]=&listOfVerticesP2[45]; //graphVertex(possibleposition[45]);
648                adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
649                       }
650            else if(findpos(actuelposition,possibleposition[50])){
651                adjacentVertices[0]=&listOfVerticesP2[51]; //graphVertex(possibleposition[51]);
652                adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
653                       }
654            else if(findpos(actuelposition,possibleposition[51])){
655                adjacentVertices[0]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
656                adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]);
657                       }
658            else if(findpos(actuelposition,possibleposition[52])){
659                adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
660                adjacentVertices[1]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]);
661                       }
662            else if(findpos(actuelposition,possibleposition[53])){
663                adjacentVertices[0]=&listOfVerticesP2[52]; //graphVertex(possibleposition[52]);
664                adjacentVertices[1]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
665                       }
666            else if(findpos(actuelposition,possibleposition[54])){
667                adjacentVertices[0]=&listOfVerticesP2[42]; //graphVertex(possibleposition[42]);
668                adjacentVertices[1]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]);
669                adjacentVertices[2]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
670                          }
671            else if(findpos(actuelposition,possibleposition[55])){
672                adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
673                adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
674                       }
675            else if(findpos(actuelposition,possibleposition[56])){
676                adjacentVertices[0]=&listOfVerticesP2[55]; //graphVertex(possibleposition[55]);
677                adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
678                adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]);
679                          }
680            else if(findpos(actuelposition,possibleposition[57])){
681                adjacentVertices[0]=&listOfVerticesP2[54]; //graphVertex(possibleposition[54]);
682                adjacentVertices[1]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
683                adjacentVertices[2]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
684                adjacentVertices[3]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
685               
686            }
687            else if(findpos(actuelposition,possibleposition[58])){
688                adjacentVertices[0]=&listOfVerticesP2[53]; //graphVertex(possibleposition[53]);
689                adjacentVertices[1]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
690                adjacentVertices[2]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
691                          }
692            else if(findpos(actuelposition,possibleposition[59])){
693                adjacentVertices[0]=&listOfVerticesP2[58]; //graphVertex(possibleposition[58]);
694                adjacentVertices[1]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
695                adjacentVertices[2]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]);
696                          }
697            else if(findpos(actuelposition,possibleposition[60])){
698                adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
699                adjacentVertices[1]=&listOfVerticesP2[61]; //graphVertex(possibleposition[61]);
700                adjacentVertices[2]=&listOfVerticesP2[62]; //graphVertex(possibleposition[62]);
701                          }
702            else if(findpos(actuelposition,possibleposition[61])){
703                adjacentVertices[0]=&listOfVerticesP2[13]; //graphVertex(possibleposition[13]);
704                adjacentVertices[1]=&listOfVerticesP2[50]; //graphVertex(possibleposition[50]);
705                adjacentVertices[2]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]);
706                          }
707            else if(findpos(actuelposition,possibleposition[62])){
708                adjacentVertices[0]=&listOfVerticesP2[16]; //graphVertex(possibleposition[16]);
709                adjacentVertices[1]=&listOfVerticesP2[60]; //graphVertex(possibleposition[60]);
710                       }
711            else if(findpos(actuelposition,possibleposition[63])){
712                adjacentVertices[0]=&listOfVerticesP2[59]; //graphVertex(possibleposition[59]);
713                adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
714                       }
715            else if(findpos(actuelposition,possibleposition[64])){
716                adjacentVertices[0]=&listOfVerticesP2[57]; //graphVertex(possibleposition[57]);
717                adjacentVertices[1]=&listOfVerticesP2[63]; //graphVertex(possibleposition[63]);
718                adjacentVertices[2]=&listOfVerticesP2[65]; //graphVertex(possibleposition[65]);
719                          }
720            else if(findpos(actuelposition,possibleposition[65])){
721                adjacentVertices[0]=&listOfVerticesP2[56]; //graphVertex(possibleposition[56]);
722                adjacentVertices[1]=&listOfVerticesP2[64]; //graphVertex(possibleposition[64]);
723                       }
724            else if(findpos(actuelposition,possibleposition[66])){
725                adjacentVertices[0]=&listOfVerticesP2[47]; //graphVertex(possibleposition[47]);
726                adjacentVertices[1]=&listOfVerticesP2[48]; //graphVertex(possibleposition[48]);
727                       }
728    }
729
730
731
732
733    //functions taken from PacmanPink
734
735
736
737
738
739    Vector3 PacmanGhost::diffVector (Vector3 start, Vector3 goal){
740
741        Vector3 result;
742        result.x=goal.x-start.x;
743        result.z=goal.z-start.z;
744        return result;
745    }
746
747    int PacmanGhost::findPlayerTravDir (Vector3 playerPosBefore, Vector3 playerPos){
748        //return 0 for south, 1 for west, 2 for north, 3 for east
749
750        Vector3 difference = diffVector(playerPosBefore, playerPos);
751
752
753        if((difference.z < 0)&&(difference.z>difference.x)){ //move south
754
755            return 0;
756        }
757        else if((difference.z>0)&&(difference.z>difference.x)){ //mouve north
758
759            return 2;
760        }
761        else if((difference.x < 0)&&(difference.x > difference.z )){//move west
762
763            return 1;
764        }
765
766        else if((difference.x>0)&&(difference.x>difference.z)){ //move east
767            return 3;
768
769        }
770
771        else { //default move west Can still be changed
772
773        return 1;
774            }
775       
776        }
777
778    Vector3 PacmanGhost::getPointInFrontOfPacman(Vector3 pacLasVisPos,int indexForSWNE){
779        //return the Vector3 point that Pinky should target to
780        //be in front of pacman
781
782        Vector3 listOfNeighboors[4];
783        //first element is south, 2nd west, 3d north, 4th east
784
785            if(findpos(pacLasVisPos,possibleposition[0])){
786                //no south neighbor
787                listOfNeighboors[1]=possibleposition[19]; // west neighbor
788                listOfNeighboors[2]=possibleposition[17]; //north
789                listOfNeighboors[3]=possibleposition[1]; //east
790                return listOfNeighboors[indexForSWNE];
791            }
792            else if(findpos(pacLasVisPos,possibleposition[1])){
793                listOfNeighboors[1]=possibleposition[0]; // west neighbor
794                listOfNeighboors[2]=possibleposition[2]; //north
795                return listOfNeighboors[indexForSWNE];
796            }
797            else if(findpos(pacLasVisPos,possibleposition[2])){
798                listOfNeighboors[0]=possibleposition[1];  //south
799                listOfNeighboors[1]=possibleposition[3]; //west
800                return listOfNeighboors[indexForSWNE];
801            }
802            else if(findpos(pacLasVisPos,possibleposition[3])){
803                listOfNeighboors[1]=possibleposition[4]; //west
804                listOfNeighboors[2]=possibleposition[5]; //north
805                listOfNeighboors[3]=possibleposition[2]; //east
806                return listOfNeighboors[indexForSWNE];
807            }
808            else if(findpos(pacLasVisPos,possibleposition[4])){
809                listOfNeighboors[2]=possibleposition[6]; //north
810                listOfNeighboors[3]=possibleposition[3]; //east
811                return listOfNeighboors[indexForSWNE];
812            }
813            else if(findpos(pacLasVisPos,possibleposition[5])){
814                listOfNeighboors[0]=possibleposition[3]; //south
815                listOfNeighboors[3]=possibleposition[7]; //east
816                return listOfNeighboors[indexForSWNE];
817            }
818            else if(findpos(pacLasVisPos,possibleposition[6])){
819                listOfNeighboors[0]=possibleposition[4]; //south
820                listOfNeighboors[1]=possibleposition[26]; //west
821                listOfNeighboors[2]=possibleposition[9]; //north
822                return listOfNeighboors[indexForSWNE];
823            }
824            else if(findpos(pacLasVisPos,possibleposition[7])){
825                listOfNeighboors[1]=possibleposition[5]; //west
826                listOfNeighboors[2]=possibleposition[8]; //north
827                return listOfNeighboors[indexForSWNE];
828            }
829            else if(findpos(pacLasVisPos,possibleposition[8])){
830                listOfNeighboors[0]=possibleposition[7]; //south
831                listOfNeighboors[1]=possibleposition[9]; //west
832                return listOfNeighboors[indexForSWNE];
833            }
834            else if(findpos(pacLasVisPos,possibleposition[9])){
835                listOfNeighboors[0]=possibleposition[6]; //south
836                listOfNeighboors[1]=possibleposition[38]; //west
837                listOfNeighboors[2]=possibleposition[10]; //north
838                listOfNeighboors[3]=possibleposition[8]; //east
839                return listOfNeighboors[indexForSWNE];
840            }
841            else if(findpos(pacLasVisPos,possibleposition[10])){
842                listOfNeighboors[0]=possibleposition[9]; //south
843                listOfNeighboors[1]=possibleposition[45]; //west
844                listOfNeighboors[2]=possibleposition[11]; //north
845                return listOfNeighboors[indexForSWNE];
846            }
847            else if(findpos(pacLasVisPos,possibleposition[11])){
848                listOfNeighboors[0]=possibleposition[10]; //south
849                listOfNeighboors[2]=possibleposition[13]; //north
850                listOfNeighboors[3]=possibleposition[12]; //east
851                return listOfNeighboors[indexForSWNE];
852            }
853            else if(findpos(pacLasVisPos,possibleposition[12])){
854                listOfNeighboors[1]=possibleposition[11]; //west
855                listOfNeighboors[2]=possibleposition[14]; //north
856                return listOfNeighboors[indexForSWNE];
857            }
858            else if(findpos(pacLasVisPos,possibleposition[13])){
859                listOfNeighboors[0]=possibleposition[11]; //south
860                listOfNeighboors[1]=possibleposition[61]; //west
861                listOfNeighboors[2]=possibleposition[16]; //north
862                listOfNeighboors[3]=possibleposition[14]; //east
863                return listOfNeighboors[indexForSWNE];
864            }
865            else if(findpos(pacLasVisPos,possibleposition[14])){
866                listOfNeighboors[0]=possibleposition[12]; //south
867                listOfNeighboors[1]=possibleposition[13]; //west
868                listOfNeighboors[2]=possibleposition[15]; //north
869                return listOfNeighboors[indexForSWNE];
870            }
871            else if(findpos(pacLasVisPos,possibleposition[15])){
872                listOfNeighboors[0]=possibleposition[14]; //south
873                listOfNeighboors[1]=possibleposition[16]; //west
874                return listOfNeighboors[indexForSWNE];
875            }
876            else if(findpos(pacLasVisPos,possibleposition[16])){
877                listOfNeighboors[0]=possibleposition[13]; //south
878                listOfNeighboors[1]=possibleposition[62]; //west
879                listOfNeighboors[2]=possibleposition[15]; //north
880                return listOfNeighboors[indexForSWNE];
881            }
882            else if(findpos(pacLasVisPos,possibleposition[17])){
883                listOfNeighboors[0]=possibleposition[0]; //south
884                listOfNeighboors[3]=possibleposition[25]; //east
885                return listOfNeighboors[indexForSWNE];
886            }
887            else if(findpos(pacLasVisPos,possibleposition[18])){
888                listOfNeighboors[0]=possibleposition[19]; //south
889                listOfNeighboors[1]=possibleposition[24]; //west
890                return listOfNeighboors[indexForSWNE];
891            }
892            else if(findpos(pacLasVisPos,possibleposition[19])){
893                listOfNeighboors[1]=possibleposition[20]; //west
894                listOfNeighboors[2]=possibleposition[18]; //north
895                listOfNeighboors[3]=possibleposition[0]; //east
896                return listOfNeighboors[indexForSWNE];
897            }
898            else if(findpos(pacLasVisPos,possibleposition[20])){
899                listOfNeighboors[2]=possibleposition[21]; //north
900                listOfNeighboors[3]=possibleposition[19]; //east
901                return listOfNeighboors[indexForSWNE];
902            }
903            else if(findpos(pacLasVisPos,possibleposition[21])){
904                listOfNeighboors[0]=possibleposition[20]; //south
905                listOfNeighboors[3]=possibleposition[22]; //east
906                return listOfNeighboors[indexForSWNE];
907            }
908            else if(findpos(pacLasVisPos,possibleposition[22])){
909                listOfNeighboors[1]=possibleposition[21]; //west
910                listOfNeighboors[2]=possibleposition[31]; //north
911                listOfNeighboors[3]=possibleposition[23]; //east
912                return listOfNeighboors[indexForSWNE];
913            }
914            else if(findpos(pacLasVisPos,possibleposition[23])){
915                listOfNeighboors[1]=possibleposition[22]; //west
916                listOfNeighboors[2]=possibleposition[30]; //north
917                return listOfNeighboors[indexForSWNE];
918            }
919            else if(findpos(pacLasVisPos,possibleposition[24])){
920                listOfNeighboors[2]=possibleposition[29]; //north
921                listOfNeighboors[3]=possibleposition[18]; //east
922                return listOfNeighboors[indexForSWNE];
923            }
924            else if(findpos(pacLasVisPos,possibleposition[25])){
925                listOfNeighboors[1]=possibleposition[17]; //west
926                listOfNeighboors[2]=possibleposition[26]; //north
927                return listOfNeighboors[indexForSWNE];
928            }
929            else if(findpos(pacLasVisPos,possibleposition[26])){
930                listOfNeighboors[0]=possibleposition[25]; //south
931                listOfNeighboors[1]=possibleposition[27]; //west
932                listOfNeighboors[3]=possibleposition[6]; //east
933                return listOfNeighboors[indexForSWNE];
934            }
935            else if(findpos(pacLasVisPos,possibleposition[27])){
936                listOfNeighboors[1]=possibleposition[28]; //west
937                listOfNeighboors[2]=possibleposition[37]; //north
938                listOfNeighboors[3]=possibleposition[26]; //east
939                return listOfNeighboors[indexForSWNE];
940            }
941            else if(findpos(pacLasVisPos,possibleposition[28])){
942                listOfNeighboors[1]=possibleposition[29]; //west
943                listOfNeighboors[2]=possibleposition[36]; //north
944                listOfNeighboors[3]=possibleposition[27]; //east
945                return listOfNeighboors[indexForSWNE];
946            }
947            else if(findpos(pacLasVisPos,possibleposition[29])){
948                listOfNeighboors[0]=possibleposition[24]; //south
949                listOfNeighboors[1]=possibleposition[30]; //west
950                listOfNeighboors[3]=possibleposition[28]; //east
951                return listOfNeighboors[indexForSWNE];
952            }
953            else if(findpos(pacLasVisPos,possibleposition[30])){
954                listOfNeighboors[0]=possibleposition[23]; //south
955                listOfNeighboors[2]=possibleposition[34]; //north
956                listOfNeighboors[3]=possibleposition[29]; //east
957                return listOfNeighboors[indexForSWNE];
958            }
959            else if(findpos(pacLasVisPos,possibleposition[31])){
960                listOfNeighboors[0]=possibleposition[22]; //south
961                listOfNeighboors[1]=possibleposition[32]; //west
962                return listOfNeighboors[indexForSWNE];
963            }
964            else if(findpos(pacLasVisPos,possibleposition[32])){
965                listOfNeighboors[2]=possibleposition[33]; //north
966                listOfNeighboors[3]=possibleposition[31]; //east
967                return listOfNeighboors[indexForSWNE];
968            }
969            else if(findpos(pacLasVisPos,possibleposition[33])){
970                listOfNeighboors[0]=possibleposition[32]; //south
971                listOfNeighboors[3]=possibleposition[34]; //east
972                return listOfNeighboors[indexForSWNE];
973            }
974            else if(findpos(pacLasVisPos,possibleposition[34])){
975                listOfNeighboors[0]=possibleposition[30]; //south
976                listOfNeighboors[1]=possibleposition[33]; //west
977                listOfNeighboors[2]=possibleposition[92]; //north
978                listOfNeighboors[3]=possibleposition[35]; //east
979                return listOfNeighboors[indexForSWNE];
980            }
981            else if(findpos(pacLasVisPos,possibleposition[35])){
982                listOfNeighboors[1]=possibleposition[34]; //west
983                listOfNeighboors[2]=possibleposition[91]; //north
984                listOfNeighboors[3]=possibleposition[36]; //east
985                return listOfNeighboors[indexForSWNE];
986            }
987            else if(findpos(pacLasVisPos,possibleposition[36])){
988                listOfNeighboors[0]=possibleposition[28]; //south
989                listOfNeighboors[1]=possibleposition[35]; //west
990                return listOfNeighboors[indexForSWNE];
991            }
992            else if(findpos(pacLasVisPos,possibleposition[37])){
993                listOfNeighboors[0]=possibleposition[27]; //south
994                listOfNeighboors[3]=possibleposition[38]; //east
995                return listOfNeighboors[indexForSWNE];
996            }
997            else if(findpos(pacLasVisPos,possibleposition[38])){
998                listOfNeighboors[1]=possibleposition[37]; //west
999                listOfNeighboors[2]=possibleposition[39]; //north
1000                listOfNeighboors[3]=possibleposition[9]; //east
1001                return listOfNeighboors[indexForSWNE];
1002            }
1003            else if(findpos(pacLasVisPos,possibleposition[39])){
1004                listOfNeighboors[0]=possibleposition[38]; //south
1005                listOfNeighboors[1]=possibleposition[40]; //west
1006                listOfNeighboors[2]=possibleposition[45]; //north
1007                return listOfNeighboors[indexForSWNE];
1008            }
1009            else if(findpos(pacLasVisPos,possibleposition[40])){
1010                listOfNeighboors[1]=possibleposition[41]; //west
1011                //Not return in center
1012                listOfNeighboors[3]=possibleposition[39]; //east
1013                return listOfNeighboors[indexForSWNE];
1014            }
1015            else if(findpos(pacLasVisPos,possibleposition[41])){
1016                listOfNeighboors[0]=possibleposition[35]; //south
1017                listOfNeighboors[2]=possibleposition[43]; //north
1018                listOfNeighboors[3]=possibleposition[40]; //east
1019                return listOfNeighboors[indexForSWNE];
1020            }
1021            else if(findpos(pacLasVisPos,possibleposition[42])){
1022                listOfNeighboors[0]=possibleposition[39]; //south
1023                listOfNeighboors[2]=possibleposition[59]; //north
1024                listOfNeighboors[3]=possibleposition[43]; //east
1025                return listOfNeighboors[indexForSWNE];
1026            }
1027            else if(findpos(pacLasVisPos,possibleposition[43])){
1028                listOfNeighboors[0]=possibleposition[41]; //south
1029                listOfNeighboors[1]=possibleposition[42]; //west
1030                listOfNeighboors[2]=possibleposition[46]; //north
1031                return listOfNeighboors[indexForSWNE];
1032            }
1033            else if(findpos(pacLasVisPos,possibleposition[44])){
1034                listOfNeighboors[0]=possibleposition[40]; //south
1035                listOfNeighboors[2]=possibleposition[66]; //north
1036                return listOfNeighboors[indexForSWNE];
1037            }
1038            else if(findpos(pacLasVisPos,possibleposition[45])){
1039                listOfNeighboors[0]=possibleposition[39]; //south
1040                listOfNeighboors[2]=possibleposition[49]; //north
1041                listOfNeighboors[3]=possibleposition[10]; //east
1042                return listOfNeighboors[indexForSWNE];
1043            }
1044            else if(findpos(pacLasVisPos,possibleposition[46])){
1045                listOfNeighboors[0]=possibleposition[43]; //south
1046                listOfNeighboors[3]=possibleposition[47]; //east
1047                return listOfNeighboors[indexForSWNE];
1048            }
1049            else if(findpos(pacLasVisPos,possibleposition[47])){
1050                listOfNeighboors[1]=possibleposition[46]; //west
1051                listOfNeighboors[2]=possibleposition[52]; //north
1052                listOfNeighboors[3]=possibleposition[66]; //east
1053                return listOfNeighboors[indexForSWNE];
1054            }
1055            else if(findpos(pacLasVisPos,possibleposition[48])){
1056                listOfNeighboors[1]=possibleposition[66]; //west
1057                listOfNeighboors[2]=possibleposition[51]; //north
1058                listOfNeighboors[3]=possibleposition[49]; //east
1059                return listOfNeighboors[indexForSWNE];
1060            }
1061            else if(findpos(pacLasVisPos,possibleposition[49])){
1062                listOfNeighboors[0]=possibleposition[45]; //south
1063                listOfNeighboors[1]=possibleposition[48]; //west
1064                return listOfNeighboors[indexForSWNE];
1065            }
1066            else if(findpos(pacLasVisPos,possibleposition[50])){
1067                listOfNeighboors[1]=possibleposition[51]; //west
1068                listOfNeighboors[2]=possibleposition[61]; //north
1069                return listOfNeighboors[indexForSWNE];
1070            }
1071            else if(findpos(pacLasVisPos,possibleposition[51])){
1072                listOfNeighboors[0]=possibleposition[48]; //south
1073                listOfNeighboors[3]=possibleposition[50]; //east
1074                return listOfNeighboors[indexForSWNE];
1075            }
1076            else if(findpos(pacLasVisPos,possibleposition[52])){
1077                listOfNeighboors[0]=possibleposition[47]; //south
1078                listOfNeighboors[1]=possibleposition[53]; //west
1079                return listOfNeighboors[indexForSWNE];
1080            }
1081            else if(findpos(pacLasVisPos,possibleposition[53])){
1082                listOfNeighboors[2]=possibleposition[58]; //north
1083                listOfNeighboors[3]=possibleposition[52]; //east
1084                return listOfNeighboors[indexForSWNE];
1085            }
1086            else if(findpos(pacLasVisPos,possibleposition[54])){
1087                listOfNeighboors[0]=possibleposition[42]; //south
1088                listOfNeighboors[1]=possibleposition[55]; //west
1089                listOfNeighboors[2]=possibleposition[57]; //north
1090                return listOfNeighboors[indexForSWNE];
1091            }
1092            else if(findpos(pacLasVisPos,possibleposition[55])){
1093                listOfNeighboors[2]=possibleposition[56]; //north
1094                listOfNeighboors[3]=possibleposition[54]; //east
1095                return listOfNeighboors[indexForSWNE];
1096            }
1097            else if(findpos(pacLasVisPos,possibleposition[56])){
1098                listOfNeighboors[0]=possibleposition[55]; //south
1099                listOfNeighboors[2]=possibleposition[65]; //north
1100                listOfNeighboors[3]=possibleposition[57]; //east
1101                return listOfNeighboors[indexForSWNE];
1102            }
1103            else if(findpos(pacLasVisPos,possibleposition[57])){
1104                listOfNeighboors[0]=possibleposition[54]; //south
1105                listOfNeighboors[1]=possibleposition[56]; //west
1106                listOfNeighboors[2]=possibleposition[64]; //north
1107                listOfNeighboors[3]=possibleposition[58]; //east
1108                return listOfNeighboors[indexForSWNE];
1109            }
1110            else if(findpos(pacLasVisPos,possibleposition[58])){
1111                listOfNeighboors[0]=possibleposition[53]; //south
1112                listOfNeighboors[1]=possibleposition[57]; //west
1113                listOfNeighboors[3]=possibleposition[59]; //east
1114                return listOfNeighboors[indexForSWNE];
1115            }
1116            else if(findpos(pacLasVisPos,possibleposition[59])){
1117                listOfNeighboors[1]=possibleposition[58]; //west
1118                listOfNeighboors[2]=possibleposition[63]; //north
1119                listOfNeighboors[3]=possibleposition[60]; //east
1120                return listOfNeighboors[indexForSWNE];
1121            }
1122            else if(findpos(pacLasVisPos,possibleposition[60])){
1123                listOfNeighboors[1]=possibleposition[59]; //west
1124                listOfNeighboors[2]=possibleposition[62]; //north
1125                listOfNeighboors[3]=possibleposition[61]; //east
1126                return listOfNeighboors[indexForSWNE];
1127            }
1128            else if(findpos(pacLasVisPos,possibleposition[61])){
1129                listOfNeighboors[0]=possibleposition[50]; //south
1130                listOfNeighboors[1]=possibleposition[60]; //west
1131                listOfNeighboors[3]=possibleposition[13]; //east
1132                return listOfNeighboors[indexForSWNE];
1133            }
1134            else if(findpos(pacLasVisPos,possibleposition[62])){
1135                listOfNeighboors[0]=possibleposition[60]; //south
1136                listOfNeighboors[3]=possibleposition[16]; //east
1137                return listOfNeighboors[indexForSWNE];
1138            }
1139            else if(findpos(pacLasVisPos,possibleposition[63])){
1140                listOfNeighboors[0]=possibleposition[59]; //south
1141                listOfNeighboors[1]=possibleposition[64]; //west
1142                return listOfNeighboors[indexForSWNE];
1143            }
1144            else if(findpos(pacLasVisPos,possibleposition[64])){
1145                listOfNeighboors[0]=possibleposition[57]; //south
1146                listOfNeighboors[1]=possibleposition[65]; //west
1147                listOfNeighboors[3]=possibleposition[63]; //east
1148                return listOfNeighboors[indexForSWNE];
1149            }
1150            else if(findpos(pacLasVisPos,possibleposition[65])){
1151                listOfNeighboors[0]=possibleposition[56]; //south
1152                listOfNeighboors[3]=possibleposition[64]; //east
1153                return listOfNeighboors[indexForSWNE];
1154            }
1155            else if(findpos(pacLasVisPos,possibleposition[66])){
1156                //Not back in center
1157                listOfNeighboors[1]=possibleposition[47]; //west
1158                listOfNeighboors[3]=possibleposition[48]; //east
1159                return listOfNeighboors[indexForSWNE];           
1160            }
1161
1162        }
1163
1164
1165}
Note: See TracBrowser for help on using the repository browser.