HOG2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
PancakePuzzle< N > Class Template Reference

#include <PancakePuzzle.h>

Inheritance diagram for PancakePuzzle< N >:
Inheritance graph
[legend]
Collaboration diagram for PancakePuzzle< N >:
Collaboration graph
[legend]

Public Member Functions

 PancakePuzzle (int gap=0)
 
 PancakePuzzle (const std::vector< unsigned > op_order)
 
 ~PancakePuzzle ()
 
void GetSuccessors (const PancakePuzzleState< N > &state, std::vector< PancakePuzzleState< N >> &neighbors) const
 
void GetActions (const PancakePuzzleState< N > &state, std::vector< unsigned > &actions) const
 
PancakePuzzleAction GetAction (const PancakePuzzleState< N > &s1, const PancakePuzzleState< N > &s2) const
 
PancakePuzzleAction GetAction (const PancakePuzzleState< N > &l1, point3d p) const
 
void ApplyAction (PancakePuzzleState< N > &s, PancakePuzzleAction a) const
 
bool InvertAction (PancakePuzzleAction &a) const
 
virtual uint64_t GetMaxHash () const
 
virtual uint64_t GetStateHash (const PancakePuzzleState< N > &node)
 
virtual void GetStateFromHash (uint64_t parent, PancakePuzzleState< N > &s) const
 
double HCost (const PancakePuzzleState< N > &state1, const PancakePuzzleState< N > &state2) const
 
double DefaultH (const PancakePuzzleState< N > &state1) const
 
double DefaultH (const PancakePuzzleState< N > &state1, const std::vector< int > &goal_locs) const
 
double HCost (const PancakePuzzleState< N > &state1) const
 
double GCost (const PancakePuzzleState< N > &s1, const PancakePuzzleState< N > &s2) const
 
double GCost (const PancakePuzzleState< N > &, const PancakePuzzleAction &a) const
 
bool GoalTest (const PancakePuzzleState< N > &state, const PancakePuzzleState< N > &goal) const
 
bool GoalTest (const PancakePuzzleState< N > &s) const
 
uint64_t GetActionHash (PancakePuzzleAction act) const
 
void StoreGoal (PancakePuzzleState< N > &)
 
virtual const std::string GetName ()
 
std::vector< PancakePuzzleActionGet_Op_Order ()
 
PancakePuzzleState< N > Get_Goal ()
 Returns stored goal state if it is stored. More...
 
void ClearGoal ()
 
bool IsGoalStored () const
 
void Change_Op_Order (const std::vector< PancakePuzzleAction > op_order)
 Changes the ordering of operators to the new inputted order. More...
 
void OpenGLDraw () const
 
void OpenGLDraw (const PancakePuzzleState< N > &) const
 
void OpenGLDraw (const PancakePuzzleState< N > &, const PancakePuzzleAction &) const
 
void OpenGLDraw (const PancakePuzzleState< N > &, const PancakePuzzleState< N > &, float) const
 
void Draw (Graphics::Display &display) const
 
void Draw (Graphics::Display &display, const PancakePuzzleState< N > &) const
 
void Draw (Graphics::Display &display, const PancakePuzzleAction &) const
 
void Draw (Graphics::Display &display, const PancakePuzzleState< N > &from, const PancakePuzzleState< N > &to, float p) const
 
bool State_Check (const PancakePuzzleState< N > &to_check)
 Checks that the given state is a valid state for this domain. More...
 
bool Path_Check (PancakePuzzleState< N > start, PancakePuzzleState< N > goal, std::vector< PancakePuzzleAction > &actions)
 
void Set_Use_Memory_Free_Heuristic (bool to_use)
 
void Set_Use_Dual_Lookup (bool to_use)
 
void SetUseRealValueEdges (bool use)
 
- Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >
 PermutationPuzzleEnvironment ()
 
double HCost (const PancakePuzzleState< N > &s) const
 
virtual double AdditiveGCost (const PancakePuzzleState< N > &s, const PancakePuzzleAction &d)
 
void GetStateFromHash (PancakePuzzleState< N > &s, uint64_t hash) const
 
uint64_t GetStateHash (const PancakePuzzleState< N > &s) const
 
PancakePuzzleState< N > TranformToStandardGoal (const PancakePuzzleState< N > &a, const PancakePuzzleState< N > &b) const
 
virtual void FinishUnranking (PancakePuzzleState< N > &s) const
 
bool Validate_Problems (std::vector< PancakePuzzleState< N > > &puzzles)
 

Static Public Member Functions

static void Create_Random_Pancake_Puzzles (std::vector< PancakePuzzleState< N >> &puzzle_vector, unsigned num_puzzles)
 
static int read_in_pancake_puzzles (const char *filename, bool first_counter, unsigned max_puzzles, std::vector< PancakePuzzleState< N >> &puzzle_vector)
 
static std::vector< PancakePuzzleActionGet_Puzzle_Order (int64_t order_num, unsigned num_pancakes)
 Returns a possible ordering of the operators. More...
 
- Static Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >
static uint64_t Hash (const PancakePuzzleState< N > &s)
 
static bool Check_Permutation (const std::vector< int > &to_check)
 Ensures that the state contains a valid permutation. More...
 
static bool Output_Puzzles (std::vector< PancakePuzzleState< N > > &puzzle_vector, bool write_puzz_num)
 Outputs the set of puzzles in puzzle_vector to standard output. More...
 
static bool Read_In_Permutations (const char *filename, unsigned size, unsigned max_puzzles, std::vector< std::vector< int > > &permutations, bool puzz_num_start)
 
static std::vector< int > Get_Random_Permutation (unsigned size)
 

Public Attributes

bool pruneActions
 
- Public Attributes inherited from PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >
bool additive
 
int maxItem
 
int minPattern
 
std::vector< std::vector< uint8_t > > PDB
 
std::vector< std::vector< int > > PDB_distincts
 
std::vector< PDBTreeNodelookups
 
std::vector< std::vector< uint64_t > > factorialCache
 
MR1KPermutation mr1
 

Private Attributes

bool real
 
std::vector< PancakePuzzleActionoperators
 
std::vector< PancakePuzzleActionactCache
 
bool goal_stored
 
bool use_memory_free
 
bool use_dual_lookup
 
int gap
 
PancakePuzzleState< N > goal
 
std::vector< int > goal_locations
 

Additional Inherited Members

- Protected Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >
uint64_t Factorial (int val) const
 
uint64_t nUpperk (int n, int k) const
 Returns the value of n! / k! More...
 

Detailed Description

template<int N>
class PancakePuzzle< N >

Definition at line 53 of file PancakePuzzle.h.

Constructor & Destructor Documentation

◆ PancakePuzzle() [1/2]

template<int N>
PancakePuzzle< N >::PancakePuzzle ( int  gap = 0)

◆ PancakePuzzle() [2/2]

template<int N>
PancakePuzzle< N >::PancakePuzzle ( const std::vector< unsigned >  op_order)

◆ ~PancakePuzzle()

template<int N>
PancakePuzzle< N >::~PancakePuzzle

Definition at line 216 of file PancakePuzzle.h.

Member Function Documentation

◆ ApplyAction()

template<int N>
void PancakePuzzle< N >::ApplyAction ( PancakePuzzleState< N > &  s,
PancakePuzzleAction  a 
) const

◆ Change_Op_Order()

template<int N>
void PancakePuzzle< N >::Change_Op_Order ( const std::vector< PancakePuzzleAction op_order)

Changes the ordering of operators to the new inputted order.

Definition at line 530 of file PancakePuzzle.h.

Referenced by PancakePuzzle< N >::PancakePuzzle().

◆ ClearGoal()

template<int N>
void PancakePuzzle< N >::ClearGoal ( )
inline

Definition at line 108 of file PancakePuzzle.h.

◆ Create_Random_Pancake_Puzzles()

template<int N>
void PancakePuzzle< N >::Create_Random_Pancake_Puzzles ( std::vector< PancakePuzzleState< N >> &  puzzle_vector,
unsigned  num_puzzles 
)
static

◆ DefaultH() [1/2]

template<int N>
double PancakePuzzle< N >::DefaultH ( const PancakePuzzleState< N > &  state1) const
virtual

◆ DefaultH() [2/2]

template<int N>
double PancakePuzzle< N >::DefaultH ( const PancakePuzzleState< N > &  state1,
const std::vector< int > &  goal_locs 
) const

Definition at line 462 of file PancakePuzzle.h.

References PancakePuzzleState< N >::puzzle.

◆ Draw() [1/4]

template<int N>
void PancakePuzzle< N >::Draw ( Graphics::Display display) const

Definition at line 760 of file PancakePuzzle.h.

References Colors::darkgray, and Graphics::Display::FillRect().

◆ Draw() [2/4]

template<int N>
void PancakePuzzle< N >::Draw ( Graphics::Display display,
const PancakePuzzleAction a 
) const

◆ Draw() [3/4]

template<int N>
void PancakePuzzle< N >::Draw ( Graphics::Display display,
const PancakePuzzleState< N > &  s 
) const

◆ Draw() [4/4]

template<int N>
void PancakePuzzle< N >::Draw ( Graphics::Display display,
const PancakePuzzleState< N > &  from,
const PancakePuzzleState< N > &  to,
float  p 
) const

◆ GCost() [1/2]

template<int N>
double PancakePuzzle< N >::GCost ( const PancakePuzzleState< N > &  ,
const PancakePuzzleAction a 
) const
inline

Definition at line 82 of file PancakePuzzle.h.

References PancakePuzzle< N >::real.

◆ GCost() [2/2]

template<int N>
double PancakePuzzle< N >::GCost ( const PancakePuzzleState< N > &  s1,
const PancakePuzzleState< N > &  s2 
) const
inline

Definition at line 75 of file PancakePuzzle.h.

References PancakePuzzle< N >::GetAction(), and PancakePuzzle< N >::real.

◆ Get_Goal()

template<int N>
PancakePuzzleState<N> PancakePuzzle< N >::Get_Goal ( )
inline

Returns stored goal state if it is stored.

Definition at line 100 of file PancakePuzzle.h.

References PancakePuzzle< N >::goal, and PancakePuzzle< N >::goal_stored.

◆ Get_Op_Order()

template<int N>
std::vector<PancakePuzzleAction> PancakePuzzle< N >::Get_Op_Order ( )
inline

Definition at line 97 of file PancakePuzzle.h.

References PancakePuzzle< N >::operators.

◆ Get_Puzzle_Order()

template<int N>
std::vector< unsigned > PancakePuzzle< N >::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 PancakePuzzle environment is created is num_pancakes, ..., 2 which is returned with a call of num_pancakes! -1.

Definition at line 650 of file PancakePuzzle.h.

◆ GetAction() [1/2]

template<int N>
PancakePuzzleAction PancakePuzzle< N >::GetAction ( const PancakePuzzleState< N > &  l1,
point3d  p 
) const

Definition at line 735 of file PancakePuzzle.h.

References Graphics::PointInRect(), and PancakePuzzleState< N >::puzzle.

◆ GetAction() [2/2]

template<int N>
PancakePuzzleAction PancakePuzzle< N >::GetAction ( const PancakePuzzleState< N > &  s1,
const PancakePuzzleState< N > &  s2 
) const

Definition at line 311 of file PancakePuzzle.h.

References PancakePuzzleState< N >::size().

Referenced by PancakePuzzle< N >::GCost().

◆ GetActionHash()

template<int N>
uint64_t PancakePuzzle< N >::GetActionHash ( PancakePuzzleAction  act) const

Definition at line 509 of file PancakePuzzle.h.

◆ GetActions()

template<int N>
void PancakePuzzle< N >::GetActions ( const PancakePuzzleState< N > &  state,
std::vector< unsigned > &  actions 
) const

Definition at line 287 of file PancakePuzzle.h.

References PancakePuzzleState< N >::puzzle.

◆ GetMaxHash()

template<int N>
uint64_t PancakePuzzle< N >::GetMaxHash
virtual

Definition at line 696 of file PancakePuzzle.h.

References Permutations< N >::MaxRank().

◆ GetName()

template<int N>
const std::string PancakePuzzle< N >::GetName
virtual

Definition at line 222 of file PancakePuzzle.h.

◆ GetStateFromHash()

template<int N>
void PancakePuzzle< N >::GetStateFromHash ( uint64_t  parent,
PancakePuzzleState< N > &  s 
) const
virtual

◆ GetStateHash()

template<int N>
uint64_t PancakePuzzle< N >::GetStateHash ( const PancakePuzzleState< N > &  node)
virtual

◆ GetSuccessors()

template<int N>
void PancakePuzzle< N >::GetSuccessors ( const PancakePuzzleState< N > &  state,
std::vector< PancakePuzzleState< N >> &  neighbors 
) const

Definition at line 263 of file PancakePuzzle.h.

◆ GoalTest() [1/2]

template<int N>
bool PancakePuzzle< N >::GoalTest ( const PancakePuzzleState< N > &  s) const

Definition at line 493 of file PancakePuzzle.h.

References PancakePuzzleState< N >::size().

◆ GoalTest() [2/2]

template<int N>
bool PancakePuzzle< N >::GoalTest ( const PancakePuzzleState< N > &  state,
const PancakePuzzleState< N > &  goal 
) const

Definition at line 487 of file PancakePuzzle.h.

◆ HCost() [1/2]

template<int N>
double PancakePuzzle< N >::HCost ( const PancakePuzzleState< N > &  state1) const

Definition at line 365 of file PancakePuzzle.h.

References max.

◆ HCost() [2/2]

template<int N>
double PancakePuzzle< N >::HCost ( const PancakePuzzleState< N > &  state1,
const PancakePuzzleState< N > &  state2 
) const

Definition at line 405 of file PancakePuzzle.h.

References PancakePuzzleState< N >::puzzle.

◆ InvertAction()

template<int N>
bool PancakePuzzle< N >::InvertAction ( PancakePuzzleAction a) const

Definition at line 357 of file PancakePuzzle.h.

◆ IsGoalStored()

template<int N>
bool PancakePuzzle< N >::IsGoalStored ( ) const
inline

Definition at line 110 of file PancakePuzzle.h.

References PancakePuzzle< N >::goal_stored.

◆ OpenGLDraw() [1/4]

template<int N>
void PancakePuzzle< N >::OpenGLDraw ( ) const
inline

Definition at line 118 of file PancakePuzzle.h.

◆ OpenGLDraw() [2/4]

template<int N>
void PancakePuzzle< N >::OpenGLDraw ( const PancakePuzzleState< N > &  pps) const

◆ OpenGLDraw() [3/4]

template<int N>
void PancakePuzzle< N >::OpenGLDraw ( const PancakePuzzleState< N > &  ,
const PancakePuzzleAction  
) const
inline

Definition at line 120 of file PancakePuzzle.h.

◆ OpenGLDraw() [4/4]

template<int N>
void PancakePuzzle< N >::OpenGLDraw ( const PancakePuzzleState< N > &  ,
const PancakePuzzleState< N > &  ,
float   
) const
inline

Definition at line 121 of file PancakePuzzle.h.

◆ Path_Check()

template<int N>
bool PancakePuzzle< N >::Path_Check ( PancakePuzzleState< N >  start,
PancakePuzzleState< N >  goal,
std::vector< PancakePuzzleAction > &  actions 
)

Definition at line 631 of file PancakePuzzle.h.

References PancakePuzzleState< N >::size().

◆ read_in_pancake_puzzles()

template<int N>
int PancakePuzzle< N >::read_in_pancake_puzzles ( const char *  filename,
bool  first_counter,
unsigned  max_puzzles,
std::vector< PancakePuzzleState< N >> &  puzzle_vector 
)
static

Definition at line 610 of file PancakePuzzle.h.

References PancakePuzzleState< N >::puzzle.

◆ Set_Use_Dual_Lookup()

template<int N>
void PancakePuzzle< N >::Set_Use_Dual_Lookup ( bool  to_use)
inline

Definition at line 156 of file PancakePuzzle.h.

References PancakePuzzle< N >::use_dual_lookup.

◆ Set_Use_Memory_Free_Heuristic()

template<int N>
void PancakePuzzle< N >::Set_Use_Memory_Free_Heuristic ( bool  to_use)
inline

Definition at line 155 of file PancakePuzzle.h.

References PancakePuzzle< N >::use_memory_free.

◆ SetUseRealValueEdges()

template<int N>
void PancakePuzzle< N >::SetUseRealValueEdges ( bool  use)
inline

Definition at line 157 of file PancakePuzzle.h.

References PancakePuzzle< N >::real.

◆ State_Check()

template<int N>
bool PancakePuzzle< N >::State_Check ( const PancakePuzzleState< N > &  to_check)
inlinevirtual

Checks that the given state is a valid state for this domain.

Note, is not a check of solvability, just legality (ie. has the right size, dimensions). Note, this method should be a quick check that can be used for debugging purposes and so should not call Check_Permutation which is O(state size)

Implements PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >.

Definition at line 136 of file PancakePuzzle.h.

References PancakePuzzleState< N >::size().

◆ StoreGoal()

template<int N>
void PancakePuzzle< N >::StoreGoal ( PancakePuzzleState< N > &  g)

Definition at line 515 of file PancakePuzzle.h.

Member Data Documentation

◆ actCache

template<int N>
std::vector<PancakePuzzleAction> PancakePuzzle< N >::actCache
mutableprivate

Definition at line 162 of file PancakePuzzle.h.

◆ gap

template<int N>
int PancakePuzzle< N >::gap
private

Definition at line 166 of file PancakePuzzle.h.

◆ goal

template<int N>
PancakePuzzleState<N> PancakePuzzle< N >::goal
private

Definition at line 167 of file PancakePuzzle.h.

Referenced by PancakePuzzle< N >::Get_Goal().

◆ goal_locations

template<int N>
std::vector<int> PancakePuzzle< N >::goal_locations
private

Definition at line 168 of file PancakePuzzle.h.

◆ goal_stored

template<int N>
bool PancakePuzzle< N >::goal_stored
private

◆ operators

template<int N>
std::vector<PancakePuzzleAction> PancakePuzzle< N >::operators
private

◆ pruneActions

template<int N>
bool PancakePuzzle< N >::pruneActions

Definition at line 158 of file PancakePuzzle.h.

Referenced by PancakePuzzle< N >::PancakePuzzle().

◆ real

template<int N>
bool PancakePuzzle< N >::real
private

◆ use_dual_lookup

template<int N>
bool PancakePuzzle< N >::use_dual_lookup
private

◆ use_memory_free

template<int N>
bool PancakePuzzle< N >::use_memory_free
private

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