Go to the documentation of this file.
19 for (
int x = 0; x <=
d; x++)
38 for (
int x = 0; x <
b; x++)
39 neighbors.push_back(nodeID*
b+x+1);
49 for (
unsigned x = 0; x < actions.size(); x++)
81 { a = -a;
return true; }
85 {
if (node1 == node2)
return 0;
return 1; }
92 {
return node == goal; }
101 float sqdist(
float x1,
float y1,
float x2,
float y2)
103 return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
108 float bestDist = 100;
114 if (
sqdist(x, y, x1, y1) < bestDist)
116 bestDist =
sqdist(x, y, x1, y1);
129 y = 2.0*float(depth)/float(
d)-1;
165 std::vector<NaryState> succ;
166 float x1, y1, x2, y2;
168 glColor3f(1.0, 1.0, 1.0);
173 for (uint64_t s : succ)
176 glVertex3f(x1, y1, 0);
177 glVertex3f(x2, y2, 0);
188 glColor4f(r, g,
b, t);
197 float x1, y1, x2, y2;
202 glColor4f(r, g,
b, t);
205 glVertex3f(x1, y1, 0);
206 glVertex3f(x2, y2, 0);
214 std::vector<NaryState> succ;
215 float x1, y1, x2, y2;
224 for (uint64_t s : succ)
229 float theta = atan2(x1-x2, y1-y2);
230 float stheta = -sin(theta);
231 float ctheta = cos(theta);
238 display.
FillTriangle({x1-r1*ctheta, y1-r1*stheta}, {x2-r2*ctheta, y2-r2*stheta}, {x1+r1*ctheta, y1+r1*stheta},
color);
239 display.
FillTriangle({x1+r1*ctheta, y1+r1*stheta}, {x2-r2*ctheta, y2-r2*stheta}, {x2+r2*ctheta, y2+r2*stheta},
color);
265 float x1, y1, x2, y2;
273 float theta = atan2(x1-x2, y1-y2);
274 float stheta = -sin(theta);
275 float ctheta = cos(theta);
279 display.
FillTriangle({x1-r1*ctheta, y1-r1*stheta}, {x2-r2*ctheta, y2-r2*stheta}, {x1+r1*ctheta, y1+r1*stheta},
color);
280 display.
FillTriangle({x1+r1*ctheta, y1+r1*stheta}, {x2-r2*ctheta, y2-r2*stheta}, {x2+r2*ctheta, y2+r2*stheta},
color);
virtual void OpenGLDraw() const
virtual double HCost(const NaryState &node1, const NaryState &node2) const
Heuristic value between two arbitrary nodes.
uint64_t GetOffset(const NaryState s) const
A color; r/g/b are between 0...1.
virtual void DrawLine(Graphics::Display &display, const NaryState &, const NaryState &, float width) const
NaryState GetClosestNode(float x, float y)
double min(double a, double b)
void GetLocation(const NaryState &s, float &x, float &y) const
virtual void Draw(Graphics::Display &display) const
void FillTriangle(point p1, point p2, point p3, rgbColor c)
std::vector< uint64_t > totalNodesAtDepth
void DrawSphere(GLdouble _x, GLdouble _y, GLdouble _z, GLdouble tRadius)
int GetDepth(const NaryState s) const
virtual void GetActions(const NaryState &nodeID, std::vector< NaryAction > &actions) const
virtual void ApplyAction(NaryState &s, NaryAction a) const
float sqdist(float x1, float y1, float x2, float y2)
std::vector< uint64_t > nodesAtDepth
virtual double GCost(const NaryState &node1, const NaryState &node2) const
float GetDepthRadius(int depth) const
virtual uint64_t GetActionHash(NaryAction act) const
virtual uint64_t GetStateHash(const NaryState &node) const
virtual rgbColor GetColor() const
virtual bool GoalTest(const NaryState &node, const NaryState &goal) const
virtual bool InvertAction(NaryAction &a) const
virtual void GetNextState(const NaryState &, NaryAction, NaryState &) const
void FillCircle(rect r, rgbColor c)
void GLDrawLine(const NaryState &x, const NaryState &y) const
NaryTree(int branchingFactor, int depth)
virtual void GetSuccessors(const NaryState &nodeID, std::vector< NaryState > &neighbors) const
NaryState GetParent(NaryState s) const
virtual NaryAction GetAction(const NaryState &s1, const NaryState &s2) const
Nodes to be stored within a Graph.