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

#include <BurnedPancakePuzzle.h>

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

Public Member Functions

 BurnedPancakePuzzle (unsigned s)
 
 BurnedPancakePuzzle (unsigned size, const std::vector< unsigned > op_order)
 
 ~BurnedPancakePuzzle ()
 
void GetSuccessors (const BurnedPancakePuzzleState &state, std::vector< BurnedPancakePuzzleState > &neighbors) const
 
void GetActions (const BurnedPancakePuzzleState &state, std::vector< unsigned > &actions) const
 
unsigned GetAction (const BurnedPancakePuzzleState &s1, const BurnedPancakePuzzleState &s2) const
 
void ApplyAction (BurnedPancakePuzzleState &s, unsigned a) const
 
bool InvertAction (unsigned &a) const
 
virtual uint64_t GetStateHash (const BurnedPancakePuzzleState &s) const
 
double HCost (const BurnedPancakePuzzleState &state1, const BurnedPancakePuzzleState &state2) const
 Heuristic value between two arbitrary nodes. More...
 
double Memory_Free_HCost (const BurnedPancakePuzzleState &state1, const std::vector< int > &goal_locs) const
 
double HCost (const BurnedPancakePuzzleState &state1) const
 Heuristic value between node and the stored goal. More...
 
double GCost (const BurnedPancakePuzzleState &, const BurnedPancakePuzzleState &) const
 
double GCost (const BurnedPancakePuzzleState &, const unsigned &) const
 
bool GoalTest (const BurnedPancakePuzzleState &state, const BurnedPancakePuzzleState &goal) const
 
bool GoalTest (const BurnedPancakePuzzleState &s) const
 Goal Test if the goal is stored. More...
 
uint64_t GetActionHash (unsigned act) const
 
void StoreGoal (BurnedPancakePuzzleState &)
 Stores the goal for use by single-state HCost. More...
 
std::vector< unsigned > Get_Op_Order ()
 
BurnedPancakePuzzleState Get_Goal ()
 Returns stored goal state if it is stored. More...
 
void ClearGoal ()
 Clears the goal from memory. More...
 
bool IsGoalStored () const
 
void Change_Op_Order (const std::vector< unsigned > op_order)
 Changes the ordering of operators to the new inputted order. More...
 
void OpenGLDraw () const
 
void OpenGLDraw (const BurnedPancakePuzzleState &) const
 
void OpenGLDraw (const BurnedPancakePuzzleState &, const unsigned &) const
 
void OpenGLDraw (const BurnedPancakePuzzleState &, const BurnedPancakePuzzleState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
void Set_Use_Memory_Free_Heuristic (bool to_use)
 
- Public Member Functions inherited from SearchEnvironment< BurnedPancakePuzzleState, unsigned >
virtual ~SearchEnvironment ()
 
virtual int GetNumSuccessors (const BurnedPancakePuzzleState &stateID) const
 
virtual void UndoAction (BurnedPancakePuzzleState &s, unsigned a) const
 
virtual void GetNextState (const BurnedPancakePuzzleState &s1, unsigned a, BurnedPancakePuzzleState &s2) const
 
virtual bool IsGoalStored () const
 Returns true if the goal is stored and false otherwise. More...
 
virtual double HCost (const BurnedPancakePuzzleState &node1, const BurnedPancakePuzzleState &node2, double parentHCost) const
 
virtual uint64_t GetMaxHash () const
 
virtual void GetStateFromHash (uint64_t parent, BurnedPancakePuzzleState &s) const
 
virtual double GetPathLength (std::vector< BurnedPancakePuzzleState > &neighbors)
 
virtual double GetPathLength (const BurnedPancakePuzzleState &start, std::vector< unsigned > &neighbors)
 
virtual OccupancyInterface< BurnedPancakePuzzleState, unsigned > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< BurnedPancakePuzzleState, unsigned > *)
 
virtual void OpenGLDraw () const
 
virtual void GLLabelState (const BurnedPancakePuzzleState &, const char *) const
 
virtual void GLDrawLine (const BurnedPancakePuzzleState &x, const BurnedPancakePuzzleState &y) const
 
virtual void GLDrawPath (const std::vector< BurnedPancakePuzzleState > &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 BurnedPancakePuzzleState &) const
 
virtual void DrawLine (Graphics::Display &display, const BurnedPancakePuzzleState &x, const BurnedPancakePuzzleState &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< BurnedPancakePuzzleState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Static Public Member Functions

static std::vector< unsigned > Get_Puzzle_Order (int64_t order_num, unsigned num_pancakes)
 Returns a possible ordering of the operators. More...
 

Private Member Functions

uint64_t Factorial (int val) const
 

Private Attributes

std::vector< unsigned > operators
 
bool goal_stored
 
bool use_memory_free
 
BurnedPancakePuzzleState goal
 
std::vector< int > goal_locations
 
unsigned size
 

Additional Inherited Members

- Public Attributes inherited from Heuristic< BurnedPancakePuzzleState >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 
- Protected Attributes inherited from SearchEnvironment< BurnedPancakePuzzleState, unsigned >
bool bValidSearchGoal
 
BurnedPancakePuzzleState searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 41 of file BurnedPancakePuzzle.h.

Constructor & Destructor Documentation

◆ BurnedPancakePuzzle() [1/2]

BurnedPancakePuzzle::BurnedPancakePuzzle ( unsigned  s)

Definition at line 4 of file BurnedPancakePuzzle.cpp.

References goal_stored, operators, size, and use_memory_free.

◆ BurnedPancakePuzzle() [2/2]

BurnedPancakePuzzle::BurnedPancakePuzzle ( unsigned  size,
const std::vector< unsigned >  op_order 
)

Definition at line 17 of file BurnedPancakePuzzle.cpp.

References Change_Op_Order(), goal_stored, size, and use_memory_free.

◆ ~BurnedPancakePuzzle()

BurnedPancakePuzzle::~BurnedPancakePuzzle ( )

Definition at line 27 of file BurnedPancakePuzzle.cpp.

References ClearGoal().

Member Function Documentation

◆ ApplyAction()

void BurnedPancakePuzzle::ApplyAction ( BurnedPancakePuzzleState s,
unsigned  a 
) const
virtual

◆ Change_Op_Order()

void BurnedPancakePuzzle::Change_Op_Order ( const std::vector< unsigned >  op_order)

Changes the ordering of operators to the new inputted order.

Definition at line 314 of file BurnedPancakePuzzle.cpp.

References operators, and size.

Referenced by BurnedPancakePuzzle().

◆ ClearGoal()

void BurnedPancakePuzzle::ClearGoal ( )
inlinevirtual

Clears the goal from memory.

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 81 of file BurnedPancakePuzzle.h.

Referenced by ~BurnedPancakePuzzle().

◆ Factorial()

uint64_t BurnedPancakePuzzle::Factorial ( int  val) const
inlineprivate

Definition at line 133 of file BurnedPancakePuzzle.h.

Referenced by GetStateHash().

◆ GCost() [1/2]

double BurnedPancakePuzzle::GCost ( const BurnedPancakePuzzleState ,
const BurnedPancakePuzzleState  
) const
inlinevirtual

◆ GCost() [2/2]

double BurnedPancakePuzzle::GCost ( const BurnedPancakePuzzleState ,
const unsigned &   
) const
inlinevirtual

◆ Get_Goal()

BurnedPancakePuzzleState BurnedPancakePuzzle::Get_Goal ( )
inline

Returns stored goal state if it is stored.

Definition at line 73 of file BurnedPancakePuzzle.h.

References goal, and goal_stored.

◆ Get_Op_Order()

std::vector<unsigned> BurnedPancakePuzzle::Get_Op_Order ( )
inline

Definition at line 70 of file BurnedPancakePuzzle.h.

References operators.

◆ Get_Puzzle_Order()

static std::vector<unsigned> BurnedPancakePuzzle::Get_Puzzle_Order ( int64_t  order_num,
unsigned  num_pancakes 
)
static

Returns a possible ordering of the operators.

The orders are in a "lexicographic" with the original ordering being 2, 3, ..., num_pancakes. This is therefore the order returned with a call of order_num=0. The default ordering used when a BurnedPancakePuzzle environment is created is num_pancakes, ..., 2 which is returned with a call of num_pancakes! -1.

◆ GetAction()

unsigned BurnedPancakePuzzle::GetAction ( const BurnedPancakePuzzleState s1,
const BurnedPancakePuzzleState s2 
) const
virtual

◆ GetActionHash()

uint64_t BurnedPancakePuzzle::GetActionHash ( unsigned  act) const
virtual

◆ GetActions()

void BurnedPancakePuzzle::GetActions ( const BurnedPancakePuzzleState state,
std::vector< unsigned > &  actions 
) const
virtual

◆ GetStateHash()

uint64_t BurnedPancakePuzzle::GetStateHash ( const BurnedPancakePuzzleState s) const
virtual

◆ GetSuccessors()

void BurnedPancakePuzzle::GetSuccessors ( const BurnedPancakePuzzleState state,
std::vector< BurnedPancakePuzzleState > &  neighbors 
) const
virtual

◆ GoalTest() [1/2]

bool BurnedPancakePuzzle::GoalTest ( const BurnedPancakePuzzleState node) const
virtual

Goal Test if the goal is stored.

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 280 of file BurnedPancakePuzzle.cpp.

References goal, goal_stored, BurnedPancakePuzzleState::puzzle, and size.

◆ GoalTest() [2/2]

bool BurnedPancakePuzzle::GoalTest ( const BurnedPancakePuzzleState state,
const BurnedPancakePuzzleState goal 
) const
virtual

◆ HCost() [1/2]

double BurnedPancakePuzzle::HCost ( const BurnedPancakePuzzleState node) const
virtual

Heuristic value between node and the stored goal.

Asserts that the goal is stored

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 150 of file BurnedPancakePuzzle.cpp.

References goal, goal_locations, goal_stored, max, Memory_Free_HCost(), BurnedPancakePuzzleState::puzzle, size, and use_memory_free.

◆ HCost() [2/2]

double BurnedPancakePuzzle::HCost ( const BurnedPancakePuzzleState node1,
const BurnedPancakePuzzleState node2 
) const
virtual

◆ InvertAction()

bool BurnedPancakePuzzle::InvertAction ( unsigned &  a) const
virtual

Implements SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 143 of file BurnedPancakePuzzle.cpp.

References size.

Referenced by GetAction().

◆ IsGoalStored()

bool BurnedPancakePuzzle::IsGoalStored ( ) const
inline

Definition at line 83 of file BurnedPancakePuzzle.h.

References goal_stored.

◆ Memory_Free_HCost()

double BurnedPancakePuzzle::Memory_Free_HCost ( const BurnedPancakePuzzleState state1,
const std::vector< int > &  goal_locs 
) const

Definition at line 233 of file BurnedPancakePuzzle.cpp.

References GetDualEntryLoc(), BurnedPancakePuzzleState::puzzle, and size.

Referenced by HCost().

◆ OpenGLDraw() [1/4]

void BurnedPancakePuzzle::OpenGLDraw ( ) const
inline

Definition at line 91 of file BurnedPancakePuzzle.h.

◆ OpenGLDraw() [2/4]

void BurnedPancakePuzzle::OpenGLDraw ( const BurnedPancakePuzzleState ) const
inlinevirtual

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 92 of file BurnedPancakePuzzle.h.

◆ OpenGLDraw() [3/4]

void BurnedPancakePuzzle::OpenGLDraw ( const BurnedPancakePuzzleState ,
const BurnedPancakePuzzleState ,
float   
) const
inlinevirtual

Draw the transition at some percentage 0...1 between two states.

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 94 of file BurnedPancakePuzzle.h.

◆ OpenGLDraw() [4/4]

void BurnedPancakePuzzle::OpenGLDraw ( const BurnedPancakePuzzleState ,
const unsigned &   
) const
inlinevirtual

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 93 of file BurnedPancakePuzzle.h.

◆ Set_Use_Memory_Free_Heuristic()

void BurnedPancakePuzzle::Set_Use_Memory_Free_Heuristic ( bool  to_use)
inline

Definition at line 120 of file BurnedPancakePuzzle.h.

References use_memory_free.

◆ StoreGoal()

void BurnedPancakePuzzle::StoreGoal ( BurnedPancakePuzzleState s)
virtual

Stores the goal for use by single-state HCost.

Reimplemented from SearchEnvironment< BurnedPancakePuzzleState, unsigned >.

Definition at line 300 of file BurnedPancakePuzzle.cpp.

References goal, goal_locations, goal_stored, BurnedPancakePuzzleState::puzzle, and size.

Member Data Documentation

◆ goal

BurnedPancakePuzzleState BurnedPancakePuzzle::goal
private

Definition at line 128 of file BurnedPancakePuzzle.h.

Referenced by Get_Goal(), GoalTest(), HCost(), and StoreGoal().

◆ goal_locations

std::vector<int> BurnedPancakePuzzle::goal_locations
private

Definition at line 129 of file BurnedPancakePuzzle.h.

Referenced by HCost(), and StoreGoal().

◆ goal_stored

bool BurnedPancakePuzzle::goal_stored
private

◆ operators

std::vector<unsigned> BurnedPancakePuzzle::operators
private

◆ size

unsigned BurnedPancakePuzzle::size
private

◆ use_memory_free

bool BurnedPancakePuzzle::use_memory_free
private

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