HOG2
|
#include <Fling.h>
Public Member Functions | |
Fling () | |
virtual void | GetSuccessors (const FlingBoard &nodeID, std::vector< FlingBoard > &neighbors) const |
virtual void | GetActions (const FlingBoard &nodeID, std::vector< FlingMove > &actions) const |
virtual FlingMove | GetAction (const FlingBoard &s1, const FlingBoard &s2) const |
virtual void | ApplyAction (FlingBoard &s, FlingMove a) const |
virtual void | UndoAction (FlingBoard &s, FlingMove a) const |
virtual void | GetNextState (const FlingBoard &, FlingMove, FlingBoard &) const |
bool | LegalMove (const FlingBoard &, FlingMove) |
virtual bool | InvertAction (FlingMove &a) const |
virtual double | HCost (const FlingBoard &node1, const FlingBoard &node2) const |
Heuristic value between two arbitrary nodes. More... | |
virtual double | GCost (const FlingBoard &node1, const FlingBoard &node2) const |
virtual double | GCost (const FlingBoard &node, const FlingMove &act) const |
void | SetGoalPanda (int which) |
void | ClearGoalPanda () |
void | SetGoalLoc (int val) |
void | ClearGoalLoc () |
virtual bool | GoalTest (const FlingBoard &node, const FlingBoard &goal) const |
virtual uint64_t | GetStateHash (const FlingBoard &node) const |
virtual void | GetStateFromHash (uint64_t parent, FlingBoard &s) const |
virtual uint64_t | GetActionHash (FlingMove act) const |
bool | GetXYFromPoint (const FlingBoard &b, point3d loc, int &x, int &y) const |
void | IncrementRank (FlingBoard &b) const |
int64_t | getMaxSinglePlayerRank (int spots, int numPieces) |
int64_t | getMaxSinglePlayerRank2 (int spots, int numPieces) |
int64_t | getMaxSinglePlayerRank2 (int spots, int numPieces, int64_t firstIndex) |
int64_t | rankPlayer (FlingBoard &s) |
void | rankPlayer (FlingBoard &s, int64_t &index1, int64_t &index2) |
void | rankPlayerFirstTwo (FlingBoard &s, int64_t &index1) |
void | rankPlayerRemaining (FlingBoard &s, int64_t &index2) |
bool | unrankPlayer (int64_t theRank, int pieces, FlingBoard &s) |
int64_t | binomialSum (unsigned int n1, unsigned int n2, unsigned int k) |
void | initBinomial () |
int64_t | binomial (unsigned int n, unsigned int k) |
int64_t | bi (unsigned int n, unsigned int k) |
virtual void | OpenGLDraw () const |
virtual void | OpenGLDraw (const FlingBoard &) const |
virtual void | OpenGLDrawAlternate (const FlingBoard &) const |
virtual void | OpenGLDrawPlain (const FlingBoard &b) const |
virtual void | OpenGLDraw (const FlingBoard &, const FlingMove &) const |
virtual void | GLLabelState (const FlingBoard &, const char *) const |
Public Member Functions inherited from SearchEnvironment< FlingBoard, FlingMove > | |
virtual | ~SearchEnvironment () |
virtual int | GetNumSuccessors (const FlingBoard &stateID) const |
virtual void | StoreGoal (FlingBoard &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 FlingBoard &node1, const FlingBoard &node2, double parentHCost) const |
virtual double | HCost (const FlingBoard &node) const |
Heuristic value between node and the stored goal. More... | |
virtual bool | GoalTest (const FlingBoard &node) const |
Goal Test if the goal is stored. More... | |
virtual uint64_t | GetMaxHash () const |
virtual double | GetPathLength (std::vector< FlingBoard > &neighbors) |
virtual double | GetPathLength (const FlingBoard &start, std::vector< FlingMove > &neighbors) |
virtual OccupancyInterface< FlingBoard, FlingMove > * | GetOccupancyInfo () |
virtual void | SetOccupancyInfo (OccupancyInterface< FlingBoard, FlingMove > *) |
virtual void | OpenGLDraw () const |
virtual void | OpenGLDraw (const FlingBoard &, const FlingBoard &, float) const |
Draw the transition at some percentage 0...1 between two states. More... | |
virtual void | GLDrawLine (const FlingBoard &x, const FlingBoard &y) const |
virtual void | GLDrawPath (const std::vector< FlingBoard > &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 |
virtual void | Draw (Graphics::Display &display) const |
virtual void | Draw (Graphics::Display &display, const FlingBoard &) const |
virtual void | DrawLine (Graphics::Display &display, const FlingBoard &x, const FlingBoard &y, float width=1.0) const |
Public Member Functions inherited from Heuristic< FlingBoard > | |
Heuristic () | |
virtual | ~Heuristic () |
Private Member Functions | |
int | IncrementRank (FlingBoard &b, int piece) const |
Private Attributes | |
bool | specificGoalLoc |
bool | specificGoalPanda |
int | goalLoc |
std::vector< int64_t > | theSums |
std::vector< int64_t > | binomials |
Additional Inherited Members | |
Public Attributes inherited from Heuristic< FlingBoard > | |
std::vector< HeuristicTreeNode > | lookups |
std::vector< Heuristic * > | heuristics |
uint64_t | histogram [256] |
Protected Attributes inherited from SearchEnvironment< FlingBoard, FlingMove > | |
bool | bValidSearchGoal |
FlingBoard | searchGoal |
rgbColor | color |
GLfloat | transparency |
Fling::Fling | ( | ) |
Definition at line 365 of file Fling.cpp.
References initBinomial(), specificGoalLoc, and specificGoalPanda.
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 486 of file Fling.cpp.
References FlingMove::dir, kDown, kLeft, kRight, kUp, FlingBoard::Move(), and FlingMove::startLoc.
Referenced by GetNextState().
int64_t Fling::bi | ( | unsigned int | n, |
unsigned int | k | ||
) |
Definition at line 1080 of file Fling.cpp.
Referenced by initBinomial().
int64_t Fling::binomial | ( | unsigned int | n, |
unsigned int | k | ||
) |
Definition at line 1074 of file Fling.cpp.
References binomials, and maxPieces.
Referenced by binomialSum(), getMaxSinglePlayerRank(), getMaxSinglePlayerRank2(), and unrankPlayer().
int64_t Fling::binomialSum | ( | unsigned int | n1, |
unsigned int | n2, | ||
unsigned int | k | ||
) |
Definition at line 1046 of file Fling.cpp.
References binomial().
Referenced by rankPlayer(), rankPlayerFirstTwo(), and rankPlayerRemaining().
void Fling::ClearGoalLoc | ( | ) |
Definition at line 390 of file Fling.cpp.
References specificGoalLoc.
void Fling::ClearGoalPanda | ( | ) |
Definition at line 379 of file Fling.cpp.
References specificGoalPanda.
|
inlinevirtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
|
inlinevirtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 508 of file Fling.cpp.
References GetActions(), GetNextState(), and kUp.
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 439 of file Fling.cpp.
References FlingBoard::CanMove(), FlingMove::dir, kDown, kLeft, kRight, kUp, FlingBoard::locs, and FlingMove::startLoc.
Referenced by GetAction().
int64_t Fling::getMaxSinglePlayerRank | ( | int | spots, |
int | numPieces | ||
) |
Definition at line 874 of file Fling.cpp.
References binomial(), and numPieces.
int64_t Fling::getMaxSinglePlayerRank2 | ( | int | spots, |
int | numPieces | ||
) |
Definition at line 879 of file Fling.cpp.
References binomial(), and numPieces.
int64_t Fling::getMaxSinglePlayerRank2 | ( | int | spots, |
int | numPieces, | ||
int64_t | firstIndex | ||
) |
Definition at line 884 of file Fling.cpp.
References binomial(), and numPieces.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 502 of file Fling.cpp.
References ApplyAction().
Referenced by GetAction().
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 549 of file Fling.cpp.
References FlingBoard::AddFling(), FlingBoard::height, FlingBoard::Reset(), and FlingBoard::width.
Referenced by GetCanonicalHash().
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 530 of file Fling.cpp.
References goalLoc, and specificGoalPanda.
Referenced by GetCanonicalHash().
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 407 of file Fling.cpp.
References FlingBoard::CanMove(), FlingBoard::locs, and FlingBoard::Move().
bool Fling::GetXYFromPoint | ( | const FlingBoard & | b, |
point3d | loc, | ||
int & | x, | ||
int & | y | ||
) | const |
Definition at line 774 of file Fling.cpp.
References FlingBoard::height, max, FlingBoard::width, loc::x, and loc::y.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 791 of file Fling.cpp.
References FlingBoard::HasPiece(), FlingBoard::height, max, and FlingBoard::width.
|
virtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 395 of file Fling.cpp.
References goalLoc, specificGoalLoc, and specificGoalPanda.
|
inlinevirtual |
Heuristic value between two arbitrary nodes.
Implements SearchEnvironment< FlingBoard, FlingMove >.
void Fling::IncrementRank | ( | FlingBoard & | b | ) | const |
Definition at line 850 of file Fling.cpp.
Referenced by IncrementRank().
|
private |
Definition at line 855 of file Fling.cpp.
References FlingBoard::ClearPiece(), FlingBoard::GetPieceLocation(), FlingBoard::height, IncrementRank(), FlingBoard::locs, FlingBoard::SetPiece(), and FlingBoard::width.
void Fling::initBinomial | ( | ) |
|
inlinevirtual |
Implements SearchEnvironment< FlingBoard, FlingMove >.
bool Fling::LegalMove | ( | const FlingBoard & | s, |
FlingMove | a | ||
) |
Definition at line 472 of file Fling.cpp.
References FlingBoard::CanMove(), FlingMove::dir, FlingBoard::HasPiece(), kDown, kLeft, kRight, kUp, and FlingMove::startLoc.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 568 of file Fling.cpp.
References rgbColor::b, FlingBoard::currId, DrawBox(), DrawSphere(), rgbColor::g, Colors::GetColor(), FlingBoard::GetIndexInLocs(), FlingBoard::HasHole(), FlingBoard::HasObstacle(), FlingBoard::HasPiece(), FlingBoard::height, FlingBoard::locs, max, rgbColor::r, and FlingBoard::width.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
Definition at line 732 of file Fling.cpp.
References FlingMove::dir, FlingBoard::height, kDown, kLeft, kRight, kUp, max, FlingMove::startLoc, and FlingBoard::width.
|
virtual |
Definition at line 694 of file Fling.cpp.
References FlingBoard::HasPiece(), FlingBoard::height, max, and FlingBoard::width.
|
virtual |
Definition at line 629 of file Fling.cpp.
References FlingBoard::HasPiece(), FlingBoard::height, max, and FlingBoard::width.
int64_t Fling::rankPlayer | ( | FlingBoard & | s | ) |
Definition at line 911 of file Fling.cpp.
References binomialSum(), FlingBoard::height, FlingBoard::locs, and FlingBoard::width.
void Fling::rankPlayer | ( | FlingBoard & | s, |
int64_t & | index1, | ||
int64_t & | index2 | ||
) |
Definition at line 927 of file Fling.cpp.
References binomialSum(), FlingBoard::height, FlingBoard::locs, and FlingBoard::width.
void Fling::rankPlayerFirstTwo | ( | FlingBoard & | s, |
int64_t & | index1 | ||
) |
Definition at line 951 of file Fling.cpp.
References binomialSum(), FlingBoard::height, FlingBoard::locs, and FlingBoard::width.
void Fling::rankPlayerRemaining | ( | FlingBoard & | s, |
int64_t & | index2 | ||
) |
Definition at line 967 of file Fling.cpp.
References binomialSum(), FlingBoard::height, FlingBoard::locs, and FlingBoard::width.
void Fling::SetGoalLoc | ( | int | val | ) |
Definition at line 384 of file Fling.cpp.
References goalLoc, and specificGoalLoc.
void Fling::SetGoalPanda | ( | int | which | ) |
Definition at line 373 of file Fling.cpp.
References goalLoc, and specificGoalPanda.
|
virtual |
Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.
bool Fling::unrankPlayer | ( | int64_t | theRank, |
int | pieces, | ||
FlingBoard & | s | ||
) |
Definition at line 985 of file Fling.cpp.
References binomial(), FlingBoard::ClearPiece(), FlingBoard::height, FlingBoard::locs, pieces, FlingBoard::Reset(), FlingBoard::SetPiece(), and FlingBoard::width.
|
private |
Definition at line 202 of file Fling.h.
Referenced by binomial(), and initBinomial().
|
private |
Definition at line 200 of file Fling.h.
Referenced by GetStateHash(), GoalTest(), SetGoalLoc(), and SetGoalPanda().
|
private |
Definition at line 198 of file Fling.h.
Referenced by ClearGoalLoc(), Fling(), GoalTest(), and SetGoalLoc().
|
private |
Definition at line 199 of file Fling.h.
Referenced by ClearGoalPanda(), Fling(), GetStateHash(), GoalTest(), and SetGoalPanda().