Go to the documentation of this file.
10 #ifndef GRAPHENVIRONMENT_H
11 #define GRAPHENVIRONMENT_H
22 #include <unordered_map>
26 #define UINT32_MAX 4294967295U
29 #define UINT16_MAX 65535
70 double straigtEdgeCost = 1.0,
72 int straightEdgeProb = 100,
73 int diagEdgeProb = 100);
97 for (
unsigned int x = 0; x <
heuristics.size(); x++)
111 {
g = graph;
goal = target; }
136 double a = ((x1>x2)?(x1-x2):(x2-x1));
137 double b = ((y1>y2)?(y1-y2):(y2-y1));
195 return dx-dy + sqrt(2)*dy;
197 return dy-dx + sqrt(2)*dx;
203 for (
int i=0;i<size;i++) {
204 #pragma message("drand was removed here. New code hasn't been tested.")
205 if ((random()%10000)/10000.0 <
prob)
239 std::vector<double> &
weight);
241 std::vector<double> &
weight, std::vector<double> &
sizes);
282 std::vector<double> &errors,
330 std::function<
float(
float,
float,
float)> l1,
331 std::function<
float(
float,
float,
float)> l2)
const;
345 fprintf(stderr,
"ERROR: Single State HCost not implemented for GraphEnvironment\n");
346 exit(1);
return -1.0;}
349 fprintf(stderr,
"ERROR: Single State Goal Test not implemented for GraphEnvironment\n");
350 exit(1);
return false;
virtual Graph * GetGraph()
void AddHeuristic(GraphHeuristic *h)
double GetOctileDistance(double dx, double dy) const
void SetMode(tHeuristicCombination mode)
void AddHeuristic(node *n=0)
Graphics::point GetLocation(const graphState &s) const
std::vector< GraphHeuristic * > heuristics
std::vector< std::vector< double > > heuristics
virtual void OpenGLDraw() const
double HCost(const graphState &state1, const graphState &state2) const
GraphMapPerfectHeuristic(Map *map, Graph *graph)
void SetProbability(double p)
void AddNodesToGraph(Map *m, Graph *g)
graphMove(uint32_t f, uint32_t t)
std::vector< double > dist
virtual double HCost(const graphState &state1, const graphState &state2) const
Graph * GetEightConnectedGraph(Map *m, bool directed)
std::vector< double > sizes
void ComputeSizes(node *n, std::vector< double > &dist, std::vector< double > &weight, std::vector< double > &sizes)
UnitSimulation< graphState, graphMove, GraphEnvironment > GraphSimulation
void IncreaseDisplayHeuristic()
virtual void GetSuccessors(const graphState &stateID, std::vector< graphState > &neighbors) const
virtual void OpenGLDraw() const
GraphLabelHeuristic(Graph *graph, graphState target)
virtual ~GraphEnvironment()
tHeuristicCombination hmode
GraphMapInconsistentHeuristic(Map *map, Graph *graph)
void SetNumUsedHeuristics(int count)
void SetNodeScale(double v)
tHeuristicCombination GetMode()
void DrawLERP(Graphics::Display &disp, Graph *a, Graph *b, float mix) const
node * GetNode(unsigned long num)
virtual bool GoalTest(const graphState &state, const graphState &goal) const
virtual void DrawStateLabel(Graphics::Display &disp, const graphState &l1, const char *txt) const
virtual void OpenGLDraw(const graphState &s, const graphState &, float) const
Draw the transition at some percentage 0...1 between two states.
virtual uint64_t GetStateHash(const graphState &state) const
virtual bool IsGoalStored() const
virtual double HCost(const graphState &state1, const graphState &state2) const
OccupancyInterface< graphState, graphMove > * GetOccupancyInfo()
virtual Graph * GetGraph()=0
node * FindAvoidNode(node *n)
virtual bool InvertAction(graphMove &a) const
std::vector< graphState > locations
virtual void ApplyAction(graphState &s, graphMove a) const
int GetNumUsedHeuristics()
double HCost(const graphState &state1, const graphState &state2) const
virtual uint64_t GetMaxHash() const
static const double ROOT_TWO
virtual void GetStateFromHash(uint64_t parent, graphState &s) const
Graph * GetFourConnectedGraph(Map *m, bool directed)
long GetMapWidth() const
return the width of the map
~GraphMapPerfectHeuristic()
~GraphHeuristicContainer()
virtual void Draw(Graphics::Display &disp) const
virtual double GCost(const graphState &state1, const graphState &state2) const
virtual void DrawLine(Graphics::Display &disp, const graphState &x, const graphState &y, double width=1.0) const
std::string SVGLabelState(const graphState &s, const char *) const
void ChooseStartGoal(graphState &start, graphState &goal)
void SetPlacement(placementScheme s)
virtual void ChooseStartGoal(graphState &, graphState &)
void SetDrawEdgeCosts(bool val)
virtual int GetNumSuccessors(const graphState &stateID) const
double HCost(const graphState &state1, const graphState &state2) const
void GetOptimalDistances(node *n, std::vector< double > &values)
virtual double HCost(const graphState &state1, const graphState &state2) const
Heuristic value between two arbitrary nodes.
double HCost(const graphState &state1, const graphState &state2) const
std::vector< double > weight
void AddEdges(Map *m, Graph *g, int x, int y, bool directed, double straigtEdgeCost, double diagEdgeCost, int straightEdgeProb, int diagEdgeProb)
AddEdges(map, Graph, x, y)
node * FindBestChild(int best, std::vector< double > &dist, std::vector< double > &weight)
virtual void GLDrawLine(const graphState &x, const graphState &y) const
void FillInCache(std::vector< double > &vals, std::vector< double > &errors, graphState state2) const
The basic simulation class for the world.
double GetLabelF(unsigned int index) const
virtual ~GraphHeuristic()
virtual uint64_t GetActionHash(graphMove act) const
placementScheme placement
long GetMapHeight() const
return the height of the map
GraphDistanceHeuristic(Graph *graph)
Graph * GetUndirectedGraph(Map *m)
GetMapGraph(map)
std::string SVGDraw() const
virtual bool GoalTest(const graphState &) const
Goal Test if the goal is stored.
virtual graphMove GetAction(const graphState &s1, const graphState &s2) const
virtual void GLLabelState(const graphState &, const char *) const
void SetDrawNodeLabels(bool val)
virtual void ClearGoal()
Clears the goal from memory.
node * FindFarNode(node *n)
virtual void GetActions(const graphState &stateID, std::vector< graphMove > &actions) const
const double kStraightEdgeCost
long GetLabelL(unsigned int index) const
GraphMapHeuristic(Map *map, Graph *graph)
virtual double HCost(const graphState &state1, const graphState &state2) const =0
GraphHeuristicContainer(Graph *gg)
virtual double HCost(const graphState &) const
Heuristic value between node and the stored goal.
void SetIntegerEdgeCosts(bool val)
virtual void StoreGoal(graphState &)
Stores the goal for use by single-state HCost.
~GraphDistanceHeuristic()
static bool operator==(const graphMove &l1, const graphMove &l2)
std::string SVGHeader() const
GraphEnvironment(Graph *g, GraphHeuristic *gh=0)
virtual void OpenGLDraw() const
const double kDiagonalEdgeCost
Nodes to be stored within a Graph.
A tile-based representation of the world.
virtual void OpenGLDraw() const