HOG2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Fling Class Reference

#include <Fling.h>

Inheritance diagram for Fling:
Inheritance graph
[legend]
Collaboration diagram for Fling:
Collaboration graph
[legend]

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< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 
- Protected Attributes inherited from SearchEnvironment< FlingBoard, FlingMove >
bool bValidSearchGoal
 
FlingBoard searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 137 of file Fling.h.

Constructor & Destructor Documentation

◆ Fling()

Fling::Fling ( )

Definition at line 365 of file Fling.cpp.

References initBinomial(), specificGoalLoc, and specificGoalPanda.

Member Function Documentation

◆ ApplyAction()

void Fling::ApplyAction ( FlingBoard s,
FlingMove  a 
) const
virtual

◆ bi()

int64_t Fling::bi ( unsigned int  n,
unsigned int  k 
)

Definition at line 1080 of file Fling.cpp.

Referenced by initBinomial().

◆ binomial()

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().

◆ binomialSum()

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().

◆ ClearGoalLoc()

void Fling::ClearGoalLoc ( )

Definition at line 390 of file Fling.cpp.

References specificGoalLoc.

◆ ClearGoalPanda()

void Fling::ClearGoalPanda ( )

Definition at line 379 of file Fling.cpp.

References specificGoalPanda.

◆ GCost() [1/2]

virtual double Fling::GCost ( const FlingBoard node,
const FlingMove act 
) const
inlinevirtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 155 of file Fling.h.

◆ GCost() [2/2]

virtual double Fling::GCost ( const FlingBoard node1,
const FlingBoard node2 
) const
inlinevirtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 154 of file Fling.h.

◆ GetAction()

FlingMove Fling::GetAction ( const FlingBoard s1,
const FlingBoard s2 
) const
virtual

Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 508 of file Fling.cpp.

References GetActions(), GetNextState(), and kUp.

◆ GetActionHash()

uint64_t Fling::GetActionHash ( FlingMove  act) const
virtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 563 of file Fling.cpp.

◆ GetActions()

void Fling::GetActions ( const FlingBoard nodeID,
std::vector< FlingMove > &  actions 
) const
virtual

◆ getMaxSinglePlayerRank()

int64_t Fling::getMaxSinglePlayerRank ( int  spots,
int  numPieces 
)

Definition at line 874 of file Fling.cpp.

References binomial(), and numPieces.

◆ getMaxSinglePlayerRank2() [1/2]

int64_t Fling::getMaxSinglePlayerRank2 ( int  spots,
int  numPieces 
)

Definition at line 879 of file Fling.cpp.

References binomial(), and numPieces.

◆ getMaxSinglePlayerRank2() [2/2]

int64_t Fling::getMaxSinglePlayerRank2 ( int  spots,
int  numPieces,
int64_t  firstIndex 
)

Definition at line 884 of file Fling.cpp.

References binomial(), and numPieces.

◆ GetNextState()

void Fling::GetNextState ( const FlingBoard f,
FlingMove  a,
FlingBoard t 
) const
virtual

Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 502 of file Fling.cpp.

References ApplyAction().

Referenced by GetAction().

◆ GetStateFromHash()

void Fling::GetStateFromHash ( uint64_t  parent,
FlingBoard s 
) const
virtual

◆ GetStateHash()

uint64_t Fling::GetStateHash ( const FlingBoard node) const
virtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 530 of file Fling.cpp.

References goalLoc, and specificGoalPanda.

Referenced by GetCanonicalHash().

◆ GetSuccessors()

void Fling::GetSuccessors ( const FlingBoard nodeID,
std::vector< FlingBoard > &  neighbors 
) const
virtual

◆ GetXYFromPoint()

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.

◆ GLLabelState()

void Fling::GLLabelState ( const FlingBoard b,
const char *  text 
) const
virtual

◆ GoalTest()

bool Fling::GoalTest ( const FlingBoard node,
const FlingBoard goal 
) const
virtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 395 of file Fling.cpp.

References goalLoc, specificGoalLoc, and specificGoalPanda.

◆ HCost()

virtual double Fling::HCost ( const FlingBoard node1,
const FlingBoard node2 
) const
inlinevirtual

Heuristic value between two arbitrary nodes.

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 152 of file Fling.h.

◆ IncrementRank() [1/2]

void Fling::IncrementRank ( FlingBoard b) const

Definition at line 850 of file Fling.cpp.

Referenced by IncrementRank().

◆ IncrementRank() [2/2]

int Fling::IncrementRank ( FlingBoard b,
int  piece 
) const
private

◆ initBinomial()

void Fling::initBinomial ( )

Definition at line 1060 of file Fling.cpp.

References bi(), binomials, and maxPieces.

Referenced by Fling().

◆ InvertAction()

virtual bool Fling::InvertAction ( FlingMove a) const
inlinevirtual

Implements SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 149 of file Fling.h.

◆ LegalMove()

bool Fling::LegalMove ( const FlingBoard s,
FlingMove  a 
)

◆ OpenGLDraw() [1/3]

virtual void Fling::OpenGLDraw ( ) const
inlinevirtual

Definition at line 187 of file Fling.h.

◆ OpenGLDraw() [2/3]

void Fling::OpenGLDraw ( const FlingBoard b) const
virtual

◆ OpenGLDraw() [3/3]

void Fling::OpenGLDraw ( const FlingBoard b,
const FlingMove m 
) const
virtual

◆ OpenGLDrawAlternate()

void Fling::OpenGLDrawAlternate ( const FlingBoard b) const
virtual

Definition at line 694 of file Fling.cpp.

References FlingBoard::HasPiece(), FlingBoard::height, max, and FlingBoard::width.

◆ OpenGLDrawPlain()

void Fling::OpenGLDrawPlain ( const FlingBoard b) const
virtual

Definition at line 629 of file Fling.cpp.

References FlingBoard::HasPiece(), FlingBoard::height, max, and FlingBoard::width.

◆ rankPlayer() [1/2]

int64_t Fling::rankPlayer ( FlingBoard s)

Definition at line 911 of file Fling.cpp.

References binomialSum(), FlingBoard::height, FlingBoard::locs, and FlingBoard::width.

◆ rankPlayer() [2/2]

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.

◆ rankPlayerFirstTwo()

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.

◆ rankPlayerRemaining()

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.

◆ SetGoalLoc()

void Fling::SetGoalLoc ( int  val)

Definition at line 384 of file Fling.cpp.

References goalLoc, and specificGoalLoc.

◆ SetGoalPanda()

void Fling::SetGoalPanda ( int  which)

Definition at line 373 of file Fling.cpp.

References goalLoc, and specificGoalPanda.

◆ UndoAction()

void Fling::UndoAction ( FlingBoard s,
FlingMove  a 
) const
virtual

Reimplemented from SearchEnvironment< FlingBoard, FlingMove >.

Definition at line 497 of file Fling.cpp.

◆ unrankPlayer()

bool Fling::unrankPlayer ( int64_t  theRank,
int  pieces,
FlingBoard s 
)

Member Data Documentation

◆ binomials

std::vector<int64_t> Fling::binomials
private

Definition at line 202 of file Fling.h.

Referenced by binomial(), and initBinomial().

◆ goalLoc

int Fling::goalLoc
private

Definition at line 200 of file Fling.h.

Referenced by GetStateHash(), GoalTest(), SetGoalLoc(), and SetGoalPanda().

◆ specificGoalLoc

bool Fling::specificGoalLoc
private

Definition at line 198 of file Fling.h.

Referenced by ClearGoalLoc(), Fling(), GoalTest(), and SetGoalLoc().

◆ specificGoalPanda

bool Fling::specificGoalPanda
private

Definition at line 199 of file Fling.h.

Referenced by ClearGoalPanda(), Fling(), GetStateHash(), GoalTest(), and SetGoalPanda().

◆ theSums

std::vector<int64_t> Fling::theSums
private

Definition at line 201 of file Fling.h.


The documentation for this class was generated from the following files: