Go to the documentation of this file.
10 #ifndef MAP2DENVIRONMENT_H
11 #define MAP2DENVIRONMENT_H
40 xyLoc(uint16_t _x, uint16_t _y) :
x(_x),
y(_y) {}
57 return (x.
x<<16)|(x.
y);
64 out <<
"(" <<
loc.
x <<
", " <<
loc.
y <<
")";
69 return (l1.
x == l2.
x) && (l1.
y == l2.
y);
73 return (l1.
x != l2.
x) || (l1.
y != l2.
y);
115 return (((std::size_t)k.
x)<<16)|k.
y;
126 return sqrt((a.
x-b.
x)*(a.
x-b.
x) + (a.
y-b.
y)*(a.
y-b.
y));
145 void GetActions(
const xyLoc &nodeID, std::vector<tDirection> &actions)
const;
155 fprintf(stderr,
"ERROR: Single State HCost not implemented for MapEnvironment\n");
156 exit(1);
return -1.0;}
164 fprintf(stderr,
"ERROR: Single State Goal Test not implemented for MapEnvironment\n");
165 exit(1);
return false;}
183 std::string
SVGLabelState(
const xyLoc &,
const char *,
double scale,
double xoff,
double yoff)
const;
185 std::string
SVGFrameRect(
int left,
int top,
int right,
int bottom,
int width = 1);
bool GoalTest(const xyLoc &node, const xyLoc &goal) const
void DrawAlternate(Graphics::Display &disp, const xyLoc &l) const
virtual bool InvertAction(tDirection &a) const
std::vector< bool > bitvec
UnitSimulation< xyLoc, tDirection, MapEnvironment > UnitMapSimulation
void SetDrawOptions(drawOptions o)
long CalculateIndex(uint16_t x, uint16_t y)
used to compute index into bitvector
void GetStateFromHash(uint64_t parent, xyLoc &s) const
virtual bool GetStateOccupied(const xyLoc &)
Returns the occupancy of a state.
bool GetNext4Successor(const xyLoc &currOpenNode, const xyLoc &goal, xyLoc &next, double &currHCost, uint64_t &special, bool &validMove)
void SetGraphHeuristic(GraphHeuristic *h)
Graphics::point GetStateLoc(const xyLoc &l1)
const int numPrimitiveActions
virtual ~MapEnvironment()
bool IsGoalStored() const
static bool operator==(const xyLoc &l1, const xyLoc &l2)
BaseMapOccupancyInterface * oi
static bool operator!=(const xyLoc &l1, const xyLoc &l2)
virtual BaseMapOccupancyInterface * GetOccupancyInfo()
virtual void MoveUnitOccupancy(const xyLoc &, const xyLoc &)
Updates the occupancy interface when a unit moves.
std::string SVGLabelState(const xyLoc &, const char *, double scale) const
long mapHeight
Used to compute index into bitvector.
virtual double GCost(const xyLoc &node1, const xyLoc &node2) const
std::string SVGDrawLine(const xyLoc &x, const xyLoc &y, int width=1) const
virtual void OpenGLDraw() const
void Draw(Graphics::Display &disp) const
void ClearGoal()
Clears the goal from memory.
virtual void ApplyAction(xyLoc &s, tDirection dir) const
void GetMaxRect(long terrain, int x, int y, int endx, int endy, std::vector< bool > &drawn, Graphics::rect &r) const
void StoreGoal(xyLoc &)
Stores the goal for use by single-state HCost.
const tDirection possibleDir[numActions]
std::string SVGFrameRect(int left, int top, int right, int bottom, int width=1)
std::size_t operator()(const xyLoc &x) const
void SetDiagonalCost(double val)
MapEnvironment(Map *m, bool useOccupancy=false)
uint64_t GetMaxHash() const
GraphHeuristic * GetGraphHeuristic()
xyLoc(uint16_t _x, uint16_t _y)
void DrawArrow(Graphics::Display &disp, const xyLoc &x, const xyLoc &y, double width=1.0) const
virtual double HCost(const xyLoc &) const
Heuristic value between node and the stored goal.
virtual void GetSuccessors(const xyLoc &nodeID, std::vector< xyLoc > &neighbors) const
const char * GetMapName()
bool operator<(const xyLoc &b)
uint64_t GetStateHash(const xyLoc &node) const
double HCost(const xyLoc &a, const xyLoc &b) const
void GetActions(const xyLoc &nodeID, std::vector< tDirection > &actions) const
The basic simulation class for the world.
virtual void GLDrawLine(const xyLoc &x, const xyLoc &y) const
void DrawSingleTerrain(long terrain, Graphics::Display &disp, std::vector< bool > &drawn) const
virtual void SetStateOccupied(const xyLoc &, bool)
Sets the occupancy of a state.
void DrawLine(Graphics::Display &disp, const xyLoc &x, const xyLoc &y, double width=1.0) const
bool GoalTest(const xyLoc &)
bool GetNextSuccessor(const xyLoc &currOpenNode, const xyLoc &goal, xyLoc &next, double &currHCost, uint64_t &special, bool &validMove)
void DrawStateLabel(Graphics::Display &disp, const xyLoc &l1, const char *txt) const
BaseMapOccupancyInterface(Map *m)
Constructor for the BaseMapOccupancyInterface.
virtual void GetNextState(const xyLoc ¤ts, tDirection dir, xyLoc &news) const
bool GetNext8Successor(const xyLoc &currOpenNode, const xyLoc &goal, xyLoc &next, double &currHCost, uint64_t &special, bool &validMove)
uint64_t GetActionHash(tDirection act) const
static std::ostream & operator<<(std::ostream &out, const xyLoc &loc)
virtual ~BaseMapOccupancyInterface()
Destructor for the BaseMapOccupancyInterface.
Nodes to be stored within a Graph.
tDirection GetAction(const xyLoc &s1, const xyLoc &s2) const
virtual void GLLabelState(const xyLoc &, const char *) const
A tile-based representation of the world.
virtual bool CanMove(const xyLoc &, const xyLoc &)
std::size_t operator()(const xyLoc &k) const