Go to the documentation of this file.
10 #ifndef SEARCHENVIRONMENT_H
11 #define SEARCHENVIRONMENT_H
25 {
return (
size_t)(x); }
29 template <
class state,
class action>
33 virtual void GetSuccessors(
const state &nodeID, std::vector<state> &neighbors)
const = 0;
34 virtual void GetActions(
const state &nodeID, std::vector<action> &actions)
const = 0;
36 { std::vector<state> neighbors;
GetSuccessors(stateID, neighbors);
return (
int)neighbors.size(); }
38 virtual action
GetAction(
const state &s1,
const state &s2)
const;
39 virtual void ApplyAction(state &s, action a)
const = 0;
43 virtual void GetNextState(
const state &s1, action a, state &s2)
const
64 virtual double HCost(
const state &node1,
const state &node2)
const = 0;
65 virtual double HCost(
const state &node1,
const state &node2,
double parentHCost)
const
66 {
return HCost(node1, node2); }
72 virtual double GCost(
const state &node1,
const state &node2)
const = 0;
73 virtual double GCost(
const state &
node,
const action &act)
const = 0;
74 virtual bool GoalTest(
const state &
node,
const state &goal)
const = 0;
87 virtual double GetPathLength(
const state &start, std::vector<action> &neighbors);
97 virtual void OpenGLDraw(
const state&,
const state&,
float)
const {}
98 virtual void OpenGLDraw(
const state&,
const action&)
const {};
100 virtual void GLDrawLine(
const state &x,
const state &y)
const {}
101 virtual void GLDrawPath(
const std::vector<state> &x)
const;
119 template <
class state,
class action>
122 std::vector<action> a;
124 for (
size_t x = 0; x < a.size(); x++)
127 ApplyAction(s, a[x]);
133 fprintf(stderr,
"No legal move found.");
143 template <
class state,
class action>
147 for (
unsigned int x = 1; x < neighbors.size(); x++)
149 length += GCost(neighbors[x-1], neighbors[x]);
154 template <
class state,
class action>
159 for (
unsigned int x = 0; x < neighbors.size(); x++)
161 length += GCost(tmp, neighbors[x]);
162 ApplyAction(tmp, neighbors[x]);
169 template <
class state,
class action>
172 for (
unsigned int x = 0; x+1 <
path.size(); x++)
virtual void DrawLine(Graphics::Display &display, const state &x, const state &y, float width=1.0) const
virtual void StoreGoal(state &s)
Stores the goal for use by single-state HCost.
virtual void SetColor(GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const
virtual void GLDrawPath(const std::vector< state > &x) const
virtual void Draw(Graphics::Display &display) const
virtual void GLLabelState(const state &, const char *) const
A color; r/g/b are between 0...1.
virtual action GetAction(const state &s1, const state &s2) const
virtual void Draw(Graphics::Display &display, const state &) const
virtual bool InvertAction(action &a) const =0
virtual bool IsGoalStored() const
Returns true if the goal is stored and false otherwise.
virtual void UndoAction(state &s, action a) const
virtual double GCost(const state &node1, const state &node2) const =0
virtual void OpenGLDraw(const state &, const state &, float) const
Draw the transition at some percentage 0...1 between two states.
virtual int GetNumSuccessors(const state &stateID) const
virtual void GetActions(const state &nodeID, std::vector< action > &actions) const =0
virtual void SetColor(const rgbColor &r) const
virtual void GetColor(GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const
virtual void OpenGLDraw(const state &) const
virtual void OpenGLDraw() const
virtual double GetPathLength(std::vector< state > &neighbors)
virtual rgbColor GetColor() const
virtual void GetSuccessors(const state &nodeID, std::vector< state > &neighbors) const =0
virtual ~SearchEnvironment()
virtual void GetStateFromHash(uint64_t parent, state &s) const
virtual uint64_t GetActionHash(action act) const =0
size_t operator()(const uint64_t &x) const
virtual double HCost(const state &node1, const state &node2) const =0
Heuristic value between two arbitrary nodes.
virtual bool GoalTest(const state &node) const
Goal Test if the goal is stored.
virtual void SetOccupancyInfo(OccupancyInterface< state, action > *)
virtual void OpenGLDraw(const state &, const action &) const
virtual uint64_t GetMaxHash() const
virtual OccupancyInterface< state, action > * GetOccupancyInfo()
virtual double HCost(const state &node) const
Heuristic value between node and the stored goal.
virtual double HCost(const state &node1, const state &node2, double parentHCost) const
virtual uint64_t GetStateHash(const state &node) const =0
virtual void ClearGoal()
Clears the goal from memory.
virtual void ApplyAction(state &s, action a) const =0
A linked list of nodes which form a continuous path.
virtual void GetNextState(const state &s1, action a, state &s2) const
virtual bool GoalTest(const state &node, const state &goal) const =0
Nodes to be stored within a Graph.
virtual void GLDrawLine(const state &x, const state &y) const