HOG2
|
#include <Racetrack.h>
Public Member Functions | |
Racetrack (Map *map) | |
~Racetrack () | |
void | UpdateMap (Map *map) |
void | GetSuccessors (const RacetrackState &nodeID, std::vector< RacetrackState > &neighbors) const |
void | GetActions (const RacetrackState &nodeID, std::vector< RacetrackMove > &actions) const |
int | GetNumSuccessors (const RacetrackState &stateID) const |
void | Reset (RacetrackState &s) const |
void | ApplyAction (RacetrackState &s, RacetrackMove a) const |
bool | InvertAction (RacetrackMove &a) const |
RacetrackMove | GetAction (const RacetrackState &s1, RacetrackState &s2) const |
void | Boundaries (RacetrackState &s, RacetrackMove &v) const |
bool | Legal (const RacetrackState &node1, RacetrackMove &act) const |
double | HCost (const RacetrackState &node1, const RacetrackState &node2) const |
Heuristic value between two arbitrary nodes. More... | |
double | HCost (const RacetrackState &node) const |
Heuristic value between node and the stored goal. More... | |
double | GCost (const RacetrackState &node1, const RacetrackState &node2) const |
double | GCost (const RacetrackState &node, const RacetrackMove &act) const |
bool | GoalTest (const RacetrackState &node, const RacetrackState &goal) const |
uint64_t | GetStateHash (const RacetrackState &node) const |
uint64_t | GetActionHash (RacetrackMove act) const |
void | OpenGLDraw () const |
void | OpenGLDraw (const RacetrackState &) const |
void | OpenGLDraw (const RacetrackState &, const RacetrackMove &) const |
void | Draw (Graphics::Display &display) const |
void | Draw (Graphics::Display &display, const RacetrackState &s) const |
void | Draw (Graphics::Display &display, const RacetrackState &, RacetrackMove &) const |
void | Draw (Graphics::Display &display, const RacetrackState &l1, const RacetrackState &l2, float v) const |
void | DrawLine (Graphics::Display &display, const RacetrackState &x, const RacetrackState &y, float width) const |
Public Member Functions inherited from SearchEnvironment< RacetrackState, RacetrackMove > | |
virtual | ~SearchEnvironment () |
virtual RacetrackMove | GetAction (const RacetrackState &s1, const RacetrackState &s2) const |
virtual void | UndoAction (RacetrackState &s, RacetrackMove a) const |
virtual void | GetNextState (const RacetrackState &s1, RacetrackMove a, RacetrackState &s2) const |
virtual void | StoreGoal (RacetrackState &s) |
Stores the goal for use by single-state HCost. More... | |
virtual void | ClearGoal () |
Clears the goal from memory. More... | |
virtual bool | IsGoalStored () const |
Returns true if the goal is stored and false otherwise. More... | |
virtual double | HCost (const RacetrackState &node1, const RacetrackState &node2, double parentHCost) const |
virtual bool | GoalTest (const RacetrackState &node) const |
Goal Test if the goal is stored. More... | |
virtual uint64_t | GetMaxHash () const |
virtual void | GetStateFromHash (uint64_t parent, RacetrackState &s) const |
virtual double | GetPathLength (std::vector< RacetrackState > &neighbors) |
virtual double | GetPathLength (const RacetrackState &start, std::vector< RacetrackMove > &neighbors) |
virtual OccupancyInterface< RacetrackState, RacetrackMove > * | GetOccupancyInfo () |
virtual void | SetOccupancyInfo (OccupancyInterface< RacetrackState, RacetrackMove > *) |
virtual void | OpenGLDraw () const |
virtual void | OpenGLDraw (const RacetrackState &, const RacetrackState &, float) const |
Draw the transition at some percentage 0...1 between two states. More... | |
virtual void | GLLabelState (const RacetrackState &, const char *) const |
virtual void | GLDrawLine (const RacetrackState &x, const RacetrackState &y) const |
virtual void | GLDrawPath (const std::vector< RacetrackState > &x) const |
virtual void | SetColor (const rgbColor &r) const |
virtual void | SetColor (GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const |
virtual void | GetColor (GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const |
virtual rgbColor | GetColor () const |
Public Member Functions inherited from Heuristic< RacetrackState > | |
Heuristic () | |
virtual | ~Heuristic () |
Private Member Functions | |
int | GetIndex (int x, int y) const |
void | GetCarCoordinates (const RacetrackState &s, Graphics::point ¢er, Graphics::point &p1, Graphics::point &p2, Graphics::point &p3) const |
Private Attributes | |
MapEnvironment * | me |
Map * | map |
std::vector< int > | heuristic |
Additional Inherited Members | |
Public Attributes inherited from Heuristic< RacetrackState > | |
std::vector< HeuristicTreeNode > | lookups |
std::vector< Heuristic * > | heuristics |
uint64_t | histogram [256] |
Protected Attributes inherited from SearchEnvironment< RacetrackState, RacetrackMove > | |
bool | bValidSearchGoal |
RacetrackState | searchGoal |
rgbColor | color |
GLfloat | transparency |
Definition at line 47 of file Racetrack.h.
Racetrack::Racetrack | ( | Map * | map | ) |
Definition at line 40 of file Racetrack.cpp.
References map, and UpdateMap().
Racetrack::~Racetrack | ( | ) |
Definition at line 47 of file Racetrack.cpp.
References me.
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 165 of file Racetrack.cpp.
References RacetrackMove::hitGoal, RacetrackMove::xDelta, RacetrackMove::xGoal, RacetrackState::xLoc, RacetrackState::xVelocity, RacetrackMove::yDelta, RacetrackMove::yGoal, RacetrackState::yLoc, and RacetrackState::yVelocity.
Referenced by GetSuccessors(), and Legal().
void Racetrack::Boundaries | ( | RacetrackState & | s, |
RacetrackMove & | v | ||
) | const |
Definition at line 186 of file Racetrack.cpp.
References Map::GetMapHeight(), Map::GetMapWidth(), map, RacetrackState::xLoc, RacetrackState::xVelocity, RacetrackState::yLoc, and RacetrackState::yVelocity.
|
virtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 356 of file Racetrack.cpp.
References MapEnvironment::Draw(), and me.
void Racetrack::Draw | ( | Graphics::Display & | display, |
const RacetrackState & | s, | ||
RacetrackMove & | a | ||
) | const |
Definition at line 422 of file Racetrack.cpp.
References Colors::black, Colors::blue, MapEnvironment::Draw(), MapEnvironment::DrawLine(), me, Colors::red, SearchEnvironment< state, action >::SetColor(), RacetrackMove::xDelta, RacetrackState::xLoc, RacetrackState::xVelocity, RacetrackMove::yDelta, RacetrackState::yLoc, and RacetrackState::yVelocity.
void Racetrack::Draw | ( | Graphics::Display & | display, |
const RacetrackState & | l1, | ||
const RacetrackState & | l2, | ||
float | v | ||
) | const |
Definition at line 438 of file Racetrack.cpp.
References Colors::blue, Graphics::Display::FillTriangle(), GetCarCoordinates(), SearchEnvironment< RacetrackState, RacetrackMove >::GetColor(), me, and SearchEnvironment< state, action >::SetColor().
|
virtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 361 of file Racetrack.cpp.
References Colors::black, MapEnvironment::DrawLine(), Graphics::Display::FillTriangle(), GetCarCoordinates(), SearchEnvironment< RacetrackState, RacetrackMove >::GetColor(), Map::GetMapHeight(), Map::GetMapWidth(), map, me, SearchEnvironment< state, action >::SetColor(), xyLoc::x, RacetrackState::xLoc, RacetrackState::xVelocity, xyLoc::y, RacetrackState::yLoc, and RacetrackState::yVelocity.
|
virtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 463 of file Racetrack.cpp.
References d, MapEnvironment::DrawLine(), SearchEnvironment< RacetrackState, RacetrackMove >::GetColor(), me, SearchEnvironment< state, action >::SetColor(), width, RacetrackState::xLoc, and RacetrackState::yLoc.
|
inlinevirtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 74 of file Racetrack.h.
|
inlinevirtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 73 of file Racetrack.h.
RacetrackMove Racetrack::GetAction | ( | const RacetrackState & | s1, |
RacetrackState & | s2 | ||
) | const |
Definition at line 228 of file Racetrack.cpp.
References RacetrackMove::xDelta, RacetrackState::xLoc, RacetrackState::xVelocity, RacetrackState::yLoc, and RacetrackState::yVelocity.
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 350 of file Racetrack.cpp.
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 122 of file Racetrack.cpp.
References Legal().
Referenced by GetSuccessors().
|
private |
Definition at line 399 of file Racetrack.cpp.
References Map::GetOpenGLCoord(), map, Graphics::point::normalise(), RacetrackState::xLoc, RacetrackState::xVelocity, Graphics::point::y, RacetrackState::yLoc, and RacetrackState::yVelocity.
Referenced by Draw().
|
inlineprivate |
Definition at line 96 of file Racetrack.h.
References Map::GetMapWidth(), and map.
Referenced by HCost(), and UpdateMap().
|
inlinevirtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 54 of file Racetrack.h.
References GetSuccessors().
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 345 of file Racetrack.cpp.
References maxVelocity.
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 108 of file Racetrack.cpp.
References ApplyAction(), and GetActions().
Referenced by GetNumSuccessors().
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 247 of file Racetrack.cpp.
References Map::GetTerrainType(), kEndTerrain, and map.
|
virtual |
Heuristic value between node and the stored goal.
Asserts that the goal is stored
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 329 of file Racetrack.cpp.
References GetIndex(), heuristic, and min().
|
virtual |
Heuristic value between two arbitrary nodes.
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 324 of file Racetrack.cpp.
|
virtual |
Implements SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 222 of file Racetrack.cpp.
bool Racetrack::Legal | ( | const RacetrackState & | node1, |
RacetrackMove & | act | ||
) | const |
Definition at line 260 of file Racetrack.cpp.
References ApplyAction(), Map::GetMapHeight(), Map::GetMapWidth(), Map::GetTerrainType(), RacetrackMove::hitGoal, kEndTerrain, kObstacle, map, maxVelocity, Graphics::point::x, RacetrackMove::xDelta, RacetrackMove::xGoal, RacetrackState::xLoc, RacetrackState::xVelocity, Graphics::point::y, RacetrackMove::yDelta, RacetrackMove::yGoal, RacetrackState::yLoc, and RacetrackState::yVelocity.
Referenced by GetActions().
|
inline |
Definition at line 81 of file Racetrack.h.
|
inlinevirtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 82 of file Racetrack.h.
|
inlinevirtual |
Reimplemented from SearchEnvironment< RacetrackState, RacetrackMove >.
Definition at line 83 of file Racetrack.h.
void Racetrack::Reset | ( | RacetrackState & | s | ) | const |
Definition at line 87 of file Racetrack.cpp.
References Map::GetMapHeight(), Map::GetMapWidth(), Map::GetTerrainType(), kStartTerrain, map, RacetrackState::xLoc, RacetrackState::xVelocity, RacetrackState::yLoc, and RacetrackState::yVelocity.
void Racetrack::UpdateMap | ( | Map * | map | ) |
Definition at line 52 of file Racetrack.cpp.
References TemplateAStar< state, action, environment, openList >::AddAdditionalStartState(), TemplateAStar< state, action, environment, openList >::DoSingleSearchStep(), GetIndex(), TemplateAStar< state, action, environment, openList >::GetItem(), Map::GetMapHeight(), Map::GetMapWidth(), TemplateAStar< state, action, environment, openList >::GetNumItems(), TemplateAStar< state, action, environment, openList >::GetNumOpenItems(), Map::GetTerrainType(), heuristic, TemplateAStar< state, action, environment, openList >::InitializeSearch(), kEndTerrain, map, me, path, MapEnvironment::SetFourConnected(), and TemplateAStar< state, action, environment, openList >::SetStopAfterGoal().
Referenced by Racetrack().
|
private |
Definition at line 95 of file Racetrack.h.
Referenced by HCost(), and UpdateMap().
|
private |
Definition at line 94 of file Racetrack.h.
Referenced by Boundaries(), Draw(), GetCarCoordinates(), GetIndex(), GoalTest(), Legal(), Racetrack(), Reset(), and UpdateMap().
|
private |
Definition at line 93 of file Racetrack.h.
Referenced by Draw(), DrawLine(), UpdateMap(), and ~Racetrack().