Robot's source code

Dependencies:   mbed

Committer:
Jagang
Date:
Mon May 11 20:32:11 2015 +0000
Revision:
123:55e5e9acc541
Parent:
109:53918ba98306
Maj AI; Repositionnement du d?part (1000,177); Ajout de l'action sur les claps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jagang 109:53918ba98306 1 #ifndef POINT_H
Jagang 109:53918ba98306 2 #define POINT_H
Jagang 109:53918ba98306 3
Jagang 109:53918ba98306 4 #include <vector>
Jagang 109:53918ba98306 5
Jagang 109:53918ba98306 6 class Point;
Jagang 109:53918ba98306 7
Jagang 109:53918ba98306 8 class Point
Jagang 109:53918ba98306 9 {
Jagang 109:53918ba98306 10 public:
Jagang 109:53918ba98306 11 Point()
Jagang 109:53918ba98306 12 {
Jagang 109:53918ba98306 13 x=y=G=H=0;
Jagang 109:53918ba98306 14 }
Jagang 109:53918ba98306 15
Jagang 109:53918ba98306 16 Point(int x, int y, float G=0, float H=0) : x(x),y(y),G(G),H(H)
Jagang 109:53918ba98306 17 {
Jagang 109:53918ba98306 18
Jagang 109:53918ba98306 19 }
Jagang 109:53918ba98306 20
Jagang 109:53918ba98306 21 virtual ~Point()
Jagang 109:53918ba98306 22 {
Jagang 109:53918ba98306 23
Jagang 109:53918ba98306 24 }
Jagang 109:53918ba98306 25
Jagang 109:53918ba98306 26 Point operator=(const Point &acase)
Jagang 109:53918ba98306 27 {
Jagang 109:53918ba98306 28 x=acase.x;
Jagang 109:53918ba98306 29 y=acase.y;
Jagang 109:53918ba98306 30 G=acase.G;
Jagang 109:53918ba98306 31 H=acase.H;
Jagang 109:53918ba98306 32 p=acase.p;
Jagang 109:53918ba98306 33 return *this;
Jagang 109:53918ba98306 34 }
Jagang 109:53918ba98306 35
Jagang 109:53918ba98306 36 void setx(int xx) { x=xx; }
Jagang 109:53918ba98306 37 void sety(int yy) { y=yy; }
Jagang 109:53918ba98306 38 void setG(float GG) { G=GG; }
Jagang 109:53918ba98306 39 void setH(float HH) { H=HH; }
Jagang 109:53918ba98306 40 void setParent(Point *pp) { p=pp; }
Jagang 109:53918ba98306 41 void setParent() { p=0; }
Jagang 109:53918ba98306 42
Jagang 109:53918ba98306 43 int getx() { return x; }
Jagang 109:53918ba98306 44 int gety() { return y; }
Jagang 109:53918ba98306 45 float getF() { return G+H; }
Jagang 109:53918ba98306 46 float getG() { return G; }
Jagang 109:53918ba98306 47 float getH() { return H; }
Jagang 109:53918ba98306 48 Point* getParent() { return p; }
Jagang 109:53918ba98306 49
Jagang 109:53918ba98306 50
Jagang 109:53918ba98306 51 bool in(std::vector<Point*> &list, unsigned int &pos)
Jagang 109:53918ba98306 52 {
Jagang 109:53918ba98306 53 for(unsigned int i=0;i<list.size();i++)
Jagang 109:53918ba98306 54 if(list[i]->getx() == this->getx() && list[i]->gety() == this->gety())
Jagang 109:53918ba98306 55 {
Jagang 109:53918ba98306 56 pos = i;
Jagang 109:53918ba98306 57 return true;
Jagang 109:53918ba98306 58 }
Jagang 109:53918ba98306 59 return false;
Jagang 109:53918ba98306 60 }
Jagang 109:53918ba98306 61
Jagang 109:53918ba98306 62 bool in(std::vector<Point*> &list)
Jagang 109:53918ba98306 63 {
Jagang 109:53918ba98306 64 for(unsigned int i=0;i<list.size();i++)
Jagang 109:53918ba98306 65 if(list[i]->getx() == this->getx() && list[i]->gety() == this->gety())
Jagang 109:53918ba98306 66 return true;
Jagang 109:53918ba98306 67 return false;
Jagang 109:53918ba98306 68 }
Jagang 109:53918ba98306 69
Jagang 109:53918ba98306 70 private:
Jagang 109:53918ba98306 71 int x;
Jagang 109:53918ba98306 72 int y;
Jagang 109:53918ba98306 73 float G;
Jagang 109:53918ba98306 74 float H;
Jagang 109:53918ba98306 75 Point *p;
Jagang 109:53918ba98306 76 };
Jagang 109:53918ba98306 77
Jagang 109:53918ba98306 78 #endif // POINT_H