HOG2
|
#include <PancakePuzzle.h>
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< PancakePuzzleAction > | Get_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< PancakePuzzleAction > | Get_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< PDBTreeNode > | lookups |
std::vector< std::vector< uint64_t > > | factorialCache |
MR1KPermutation | mr1 |
Private Attributes | |
bool | real |
std::vector< PancakePuzzleAction > | operators |
std::vector< PancakePuzzleAction > | actCache |
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... | |
Definition at line 53 of file PancakePuzzle.h.
PancakePuzzle< N >::PancakePuzzle | ( | int | gap = 0 | ) |
Definition at line 188 of file PancakePuzzle.h.
References PancakePuzzle< N >::goal_stored, PancakePuzzle< N >::operators, PancakePuzzle< N >::pruneActions, PancakePuzzle< N >::use_dual_lookup, and PancakePuzzle< N >::use_memory_free.
PancakePuzzle< N >::PancakePuzzle | ( | const std::vector< unsigned > | op_order | ) |
Definition at line 204 of file PancakePuzzle.h.
References PancakePuzzle< N >::Change_Op_Order(), PancakePuzzle< N >::goal_stored, PancakePuzzle< N >::pruneActions, PancakePuzzle< N >::use_dual_lookup, and PancakePuzzle< N >::use_memory_free.
PancakePuzzle< N >::~PancakePuzzle |
Definition at line 216 of file PancakePuzzle.h.
void PancakePuzzle< N >::ApplyAction | ( | PancakePuzzleState< N > & | s, |
PancakePuzzleAction | a | ||
) | const |
Definition at line 337 of file PancakePuzzle.h.
References PancakePuzzleState< N >::puzzle, and PancakePuzzleState< N >::size().
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().
|
inline |
Definition at line 108 of file PancakePuzzle.h.
|
static |
Definition at line 572 of file PancakePuzzle.h.
References PancakePuzzle< N >::GetStateHash(), and PancakePuzzleState< N >::puzzle.
|
virtual |
Reimplemented from PermutationPuzzle::PermutationPuzzleEnvironment< PancakePuzzleState< N >, PancakePuzzleAction >.
Definition at line 456 of file PancakePuzzle.h.
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.
void PancakePuzzle< N >::Draw | ( | Graphics::Display & | display | ) | const |
Definition at line 760 of file PancakePuzzle.h.
References Colors::darkgray, and Graphics::Display::FillRect().
void PancakePuzzle< N >::Draw | ( | Graphics::Display & | display, |
const PancakePuzzleAction & | a | ||
) | const |
Definition at line 780 of file PancakePuzzle.h.
References Colors::black, Colors::blue, Graphics::Display::DrawArrow(), and Graphics::Display::DrawLine().
void PancakePuzzle< N >::Draw | ( | Graphics::Display & | display, |
const PancakePuzzleState< N > & | s | ||
) | const |
Definition at line 768 of file PancakePuzzle.h.
References Colors::black, Graphics::Display::FillRect(), Graphics::Display::FrameRect(), and PancakePuzzleState< N >::puzzle.
void PancakePuzzle< N >::Draw | ( | Graphics::Display & | display, |
const PancakePuzzleState< N > & | from, | ||
const PancakePuzzleState< N > & | to, | ||
float | p | ||
) | const |
Definition at line 796 of file PancakePuzzle.h.
References Colors::black, Graphics::Display::FillRect(), Graphics::Display::FrameRect(), Graphics::rect::lerp(), and PancakePuzzleState< N >::puzzle.
|
inline |
Definition at line 82 of file PancakePuzzle.h.
References PancakePuzzle< N >::real.
|
inline |
Definition at line 75 of file PancakePuzzle.h.
References PancakePuzzle< N >::GetAction(), and PancakePuzzle< N >::real.
|
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.
|
inline |
Definition at line 97 of file PancakePuzzle.h.
References PancakePuzzle< N >::operators.
|
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.
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.
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().
uint64_t PancakePuzzle< N >::GetActionHash | ( | PancakePuzzleAction | act | ) | const |
Definition at line 509 of file PancakePuzzle.h.
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.
|
virtual |
Definition at line 696 of file PancakePuzzle.h.
References Permutations< N >::MaxRank().
|
virtual |
Definition at line 222 of file PancakePuzzle.h.
|
virtual |
Definition at line 710 of file PancakePuzzle.h.
References PancakePuzzleState< N >::puzzle, and Permutations< N >::Unrank().
|
virtual |
Definition at line 703 of file PancakePuzzle.h.
References Permutations< N >::Rank().
Referenced by PancakePuzzle< N >::Create_Random_Pancake_Puzzles().
void PancakePuzzle< N >::GetSuccessors | ( | const PancakePuzzleState< N > & | state, |
std::vector< PancakePuzzleState< N >> & | neighbors | ||
) | const |
Definition at line 263 of file PancakePuzzle.h.
bool PancakePuzzle< N >::GoalTest | ( | const PancakePuzzleState< N > & | s | ) | const |
Definition at line 493 of file PancakePuzzle.h.
References PancakePuzzleState< N >::size().
bool PancakePuzzle< N >::GoalTest | ( | const PancakePuzzleState< N > & | state, |
const PancakePuzzleState< N > & | goal | ||
) | const |
Definition at line 487 of file PancakePuzzle.h.
double PancakePuzzle< N >::HCost | ( | const PancakePuzzleState< N > & | state1 | ) | const |
Definition at line 365 of file PancakePuzzle.h.
References max.
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.
bool PancakePuzzle< N >::InvertAction | ( | PancakePuzzleAction & | a | ) | const |
Definition at line 357 of file PancakePuzzle.h.
|
inline |
Definition at line 110 of file PancakePuzzle.h.
References PancakePuzzle< N >::goal_stored.
|
inline |
Definition at line 118 of file PancakePuzzle.h.
void PancakePuzzle< N >::OpenGLDraw | ( | const PancakePuzzleState< N > & | pps | ) | const |
Definition at line 717 of file PancakePuzzle.h.
References DrawBox(), PancakePuzzleState< N >::puzzle, and PancakePuzzleState< N >::size().
|
inline |
Definition at line 120 of file PancakePuzzle.h.
|
inline |
Definition at line 121 of file PancakePuzzle.h.
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().
|
static |
Definition at line 610 of file PancakePuzzle.h.
References PancakePuzzleState< N >::puzzle.
|
inline |
Definition at line 156 of file PancakePuzzle.h.
References PancakePuzzle< N >::use_dual_lookup.
|
inline |
Definition at line 155 of file PancakePuzzle.h.
References PancakePuzzle< N >::use_memory_free.
|
inline |
Definition at line 157 of file PancakePuzzle.h.
References PancakePuzzle< N >::real.
|
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().
void PancakePuzzle< N >::StoreGoal | ( | PancakePuzzleState< N > & | g | ) |
Definition at line 515 of file PancakePuzzle.h.
|
mutableprivate |
Definition at line 162 of file PancakePuzzle.h.
|
private |
Definition at line 166 of file PancakePuzzle.h.
|
private |
Definition at line 167 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::Get_Goal().
|
private |
Definition at line 168 of file PancakePuzzle.h.
|
private |
Definition at line 163 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::Get_Goal(), PancakePuzzle< N >::IsGoalStored(), and PancakePuzzle< N >::PancakePuzzle().
|
private |
Definition at line 161 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::Get_Op_Order(), and PancakePuzzle< N >::PancakePuzzle().
bool PancakePuzzle< N >::pruneActions |
Definition at line 158 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::PancakePuzzle().
|
private |
Definition at line 160 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::GCost(), and PancakePuzzle< N >::SetUseRealValueEdges().
|
private |
Definition at line 165 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::PancakePuzzle(), and PancakePuzzle< N >::Set_Use_Dual_Lookup().
|
private |
Definition at line 164 of file PancakePuzzle.h.
Referenced by PancakePuzzle< N >::PancakePuzzle(), and PancakePuzzle< N >::Set_Use_Memory_Free_Heuristic().