Go to the documentation of this file.
58 std::vector<xyLoc>
path;
103 std::cout <<
"No start terrain found! \n";
110 static std::vector<RacetrackMove> actions;
114 for (
int i=0; i < actions.size(); i++)
118 neighbors.push_back(temp);
132 for (
int x = -1; x <= 1; x++)
134 for (
int y = -1; y <= 1; y++)
137 if (
Legal(nodeID, m))
138 actions.push_back(m);
232 int expectedX = s2.
xLoc;
233 m.
xDelta = expectedX-newX;
236 int expectedY = s2.
yLoc;
237 m.
xDelta = expectedY-newY;
293 int numSegments =
static_cast<int>(2*ceilf((g-s).length()));
294 for (
int x = 1; x <= numSegments; x ++)
297 float ratio =
static_cast<float>(x)/
static_cast<float>(numSegments);
298 next = s*(1-ratio)+g*(ratio);
299 float offsets[5][2] = {{0, 0}, {0.4f, 0.4f}, {-0.4f, -0.4f}, {-0.4f, 0.4f}, {0.4f, -0.4f}};
300 for (
int y = 0; y < 5; y++)
303 int xNext =
static_cast<int>(roundf(next.
x+offsets[y][0]));
304 int yNext =
static_cast<int>(roundf(next.
y+offsets[y][1]));
332 int speed = abs(
node.xVelocity)+abs(
node.yVelocity);
347 return ((
static_cast<uint64_t
>(
node.xLoc)<<32) | (
static_cast<uint64_t
>(
node.yLoc)<<16) | (
static_cast<uint64_t
>(
node.xVelocity+
maxVelocity)<<8) | (
static_cast<uint64_t
>(
node.yVelocity+
maxVelocity)));
367 xyLoc agent(
static_cast<uint16_t
>(s.
xLoc),
static_cast<uint16_t
>(s.
yLoc));
401 GLdouble xx, yy, zz, r;
403 float rad = (float)r;
429 xyLoc agent(
static_cast<uint16_t
>(s.
xLoc),
static_cast<uint16_t
>(s.
yLoc));
454 display.
FillTriangle((middle+p1)*(1-v)+(middle+q1)*v, (middle+p2)*(1-v)+(middle+q2)*v, (middle+p3)*(1-v)+(middle+q3)*v,
GetColor());
466 xyLoc agent1(
static_cast<uint16_t
>(c.
xLoc),
static_cast<uint16_t
>(c.
yLoc));
467 xyLoc agent2(
static_cast<uint16_t
>(
d.xLoc),
static_cast<uint16_t
>(
d.yLoc));
void GetActions(const RacetrackState &nodeID, std::vector< RacetrackMove > &actions) const
bool operator!=(const RacetrackState &l1, const RacetrackState &l2)
void SetStopAfterGoal(bool val)
double min(double a, double b)
void FillTriangle(point p1, point p2, point p3, rgbColor c)
std::ostream & operator<<(std::ostream &out, const RacetrackState &s)
bool Legal(const RacetrackState &node1, RacetrackMove &act) const
void GetCarCoordinates(const RacetrackState &s, Graphics::point ¢er, Graphics::point &p1, Graphics::point &p2, Graphics::point &p3) const
int GetIndex(int x, int y) const
bool operator==(const RacetrackState &l1, const RacetrackState &l2)
unsigned int GetNumOpenItems()
void Draw(Graphics::Display &disp) const
void DrawLine(Graphics::Display &display, const RacetrackState &x, const RacetrackState &y, float width) const
virtual void SetColor(const rgbColor &r) const
uint64_t GetStateHash(const RacetrackState &node) const
void AddAdditionalStartState(const state &newState)
Add additional start state to the search.
A templated version of A*, based on HOG genericAStar.
long GetMapWidth() const
return the width of the map
virtual rgbColor GetColor() const
void Boundaries(RacetrackState &s, RacetrackMove &v) const
bool GoalTest(const RacetrackState &node, const RacetrackState &goal) const
long GetTerrainType(long x, long y, tSplitSide split=kWholeTile) const
Get the terrain type of the (split) tile at x, y.
std::vector< int > heuristic
uint64_t GetActionHash(RacetrackMove act) const
void Reset(RacetrackState &s) const
const AStarOpenClosedDataWithF< state > & GetItem(unsigned int which)
double HCost(const RacetrackState &node1, const RacetrackState &node2) const
Heuristic value between two arbitrary nodes.
std::vector< xyLoc > path
void Draw(Graphics::Display &display) const
void GetSuccessors(const RacetrackState &nodeID, std::vector< RacetrackState > &neighbors) const
bool InitializeSearch(environment *env, const state &from, const state &to, std::vector< state > &thePath)
Initialize the A* search.
long GetMapHeight() const
return the height of the map
void DrawLine(Graphics::Display &disp, const xyLoc &x, const xyLoc &y, double width=1.0) const
bool InvertAction(RacetrackMove &a) const
const tTerrain kStartTerrain
bool GetOpenGLCoord(int _x, int _y, GLdouble &x, GLdouble &y, GLdouble &z, GLdouble &radius) const
Get the openGL coordinates of a given tile.
A linked list of nodes which form a continuous path.
void ApplyAction(RacetrackState &s, RacetrackMove a) const
const tTerrain kEndTerrain
bool DoSingleSearchStep(std::vector< state > &thePath)
Expand a single node.
Nodes to be stored within a Graph.
A tile-based representation of the world.
RacetrackMove GetAction(const RacetrackState &s1, RacetrackState &s2) const