HOG2
|
#include <TopSpin.h>
Public Member Functions | |
TopSpin () | |
~TopSpin () | |
void | SetWeighted (bool w) |
bool | GetWeighted () |
void | SetPruneSuccessors (bool val) |
void | GetSuccessors (const TopSpinState< N > &stateID, std::vector< TopSpinState< N >> &neighbors) const |
void | GetActions (const TopSpinState< N > &stateID, std::vector< TopSpinAction > &actions) const |
void | ApplyAction (TopSpinState< N > &s, TopSpinAction a) const |
void | UndoAction (TopSpinState< N > &s, TopSpinAction a) const |
bool | InvertAction (TopSpinAction &a) const |
void | SetPattern (const std::vector< int > &pattern) |
double | AdditiveGCost (const TopSpinState< N > &s, const TopSpinAction &d) |
OccupancyInterface< TopSpinState< N >, TopSpinAction > * | GetOccupancyInfo () |
double | HCost (const TopSpinState< N > &state1, const TopSpinState< N > &state2) const |
double | GCost (const TopSpinState< N > &state1, const TopSpinState< N > &state2) const |
double | GCost (const TopSpinState< N > &, const TopSpinAction &) const |
bool | GoalTest (const TopSpinState< N > &state, const TopSpinState< N > &goal) const |
bool | GoalTest (const TopSpinState< N > &s) const |
void | GetGoals (std::vector< TopSpinState< N >> &goals) |
uint64_t | GetActionHash (TopSpinAction act) const |
void | OpenGLDraw () const |
void | OpenGLDraw (const TopSpinState< N > &s) const |
void | OpenGLDraw (const TopSpinState< N > &l1, const TopSpinState< N > &l2, float v) const |
void | OpenGLDraw (const TopSpinState< N > &, const TopSpinAction &) const |
void | StoreGoal (TopSpinState< N > &) |
TopSpinState< N > | Get_Goal () |
Returns stored goal state if it is stored. More... | |
virtual const std::string | GetName () |
void | ClearGoal () |
bool | IsGoalStored () const |
bool | State_Check (const TopSpinState< N > &to_check) |
Checks that the given state is a valid state for this domain. More... | |
void | PrintHStats () |
Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction > | |
PermutationPuzzleEnvironment () | |
double | HCost (const TopSpinState< N > &s) const |
void | GetStateFromHash (TopSpinState< N > &s, uint64_t hash) const |
uint64_t | GetStateHash (const TopSpinState< N > &s) const |
TopSpinState< N > | TranformToStandardGoal (const TopSpinState< N > &a, const TopSpinState< N > &b) const |
virtual void | FinishUnranking (TopSpinState< N > &s) const |
bool | Validate_Problems (std::vector< TopSpinState< N > > &puzzles) |
Static Public Member Functions | |
static unsigned | GetParity (TopSpinState< N > &state) |
Static Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction > | |
static uint64_t | Hash (const TopSpinState< 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< TopSpinState< 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) |
Private Member Functions | |
void | ComputeMovePruning () |
void | RecursiveMovePruning (int depth, TopSpinState< N > &state) |
Private Attributes | |
std::unordered_map< uint64_t, bool > | pruningMap |
std::unordered_map< uint64_t, int > | pruningCostMap |
std::vector< TopSpinAction > | operators |
std::vector< bool > | movePrune |
unsigned ** | h_increment |
TopSpinState< N > | goal |
std::vector< std::vector< int > > | hDist |
bool | pattern [N] |
std::vector< TopSpinAction > | history |
bool | pruneSuccessors |
bool | weighted |
bool | additive |
Additional Inherited Members | |
Public Attributes inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction > | |
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 |
Protected Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction > | |
uint64_t | Factorial (int val) const |
uint64_t | nUpperk (int n, int k) const |
Returns the value of n! / k! More... | |
Definition at line 182 of file TopSpin.h.
References TopSpin< N, k >::additive, TopSpin< N, k >::operators, TopSpin< N, k >::pruneSuccessors, and TopSpin< N, k >::weighted.
|
virtual |
Reimplemented from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >.
Definition at line 220 of file TopSpin.h.
References TopSpinState< N >::puzzle.
void TopSpin< N, k >::ApplyAction | ( | TopSpinState< N > & | s, |
TopSpinAction | a | ||
) | const |
Definition at line 321 of file TopSpin.h.
References TopSpinState< N >::puzzle, and swap().
|
inline |
|
private |
Definition at line 233 of file TopSpin.h.
Referenced by TopSpin< N, k >::SetPruneSuccessors().
double TopSpin< N, k >::GCost | ( | const TopSpinState< N > & | node, |
const TopSpinAction & | act | ||
) | const |
Definition at line 368 of file TopSpin.h.
References tsCostCount, and tscosts.
double TopSpin< N, k >::GCost | ( | const TopSpinState< N > & | state1, |
const TopSpinState< N > & | state2 | ||
) | const |
|
inline |
Returns stored goal state if it is stored.
Definition at line 123 of file TopSpin.h.
References TopSpin< N, k >::goal.
uint64_t TopSpin< N, k >::GetActionHash | ( | TopSpinAction | act | ) | const |
void TopSpin< N, k >::GetActions | ( | const TopSpinState< N > & | stateID, |
std::vector< TopSpinAction > & | actions | ||
) | const |
|
inline |
Definition at line 101 of file TopSpin.h.
References TopSpinState< N >::puzzle.
|
virtual |
|
inline |
|
static |
void TopSpin< N, k >::GetSuccessors | ( | const TopSpinState< N > & | stateID, |
std::vector< TopSpinState< N >> & | neighbors | ||
) | const |
|
inline |
Definition at line 82 of file TopSpin.h.
References TopSpin< N, k >::weighted.
bool TopSpin< N, k >::GoalTest | ( | const TopSpinState< N > & | s | ) | const |
Definition at line 279 of file TopSpin.h.
References TopSpinState< N >::puzzle.
bool TopSpin< N, k >::GoalTest | ( | const TopSpinState< N > & | state, |
const TopSpinState< N > & | goal | ||
) | const |
double TopSpin< N, k >::HCost | ( | const TopSpinState< N > & | state1, |
const TopSpinState< N > & | state2 | ||
) | const |
bool TopSpin< N, k >::InvertAction | ( | TopSpinAction & | a | ) | const |
|
inline |
|
inline |
void TopSpin< N, k >::OpenGLDraw | ( | const TopSpinState< N > & | l1, |
const TopSpinState< N > & | l2, | ||
float | v | ||
) | const |
void TopSpin< N, k >::OpenGLDraw | ( | const TopSpinState< N > & | s | ) | const |
Definition at line 455 of file TopSpin.h.
References DrawTSTile(), LocalDrawCircle(), and TopSpinState< N >::puzzle.
|
inline |
Definition at line 135 of file TopSpin.h.
References TopSpin< N, k >::hDist.
|
private |
void TopSpin< N, k >::SetPattern | ( | const std::vector< int > & | pattern | ) |
|
inline |
Definition at line 83 of file TopSpin.h.
References TopSpin< N, k >::ComputeMovePruning(), TopSpin< N, k >::history, and TopSpin< N, k >::pruneSuccessors.
|
inline |
Definition at line 81 of file TopSpin.h.
References TopSpin< N, k >::weighted.
|
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< TopSpinState< N >, TopSpinAction >.
void TopSpin< N, k >::StoreGoal | ( | TopSpinState< N > & | s | ) |
void TopSpin< N, k >::UndoAction | ( | TopSpinState< N > & | s, |
TopSpinAction | a | ||
) | const |
Definition at line 332 of file TopSpin.h.
References TopSpinState< N >::puzzle, and swap().
|
private |
Definition at line 174 of file TopSpin.h.
Referenced by TopSpin< N, k >::TopSpin().
|
private |
Definition at line 167 of file TopSpin.h.
Referenced by TopSpin< N, k >::Get_Goal().
|
private |
|
private |
Definition at line 168 of file TopSpin.h.
Referenced by TopSpin< N, k >::PrintHStats().
|
mutableprivate |
Definition at line 171 of file TopSpin.h.
Referenced by TopSpin< N, k >::SetPruneSuccessors().
|
private |
|
private |
Definition at line 162 of file TopSpin.h.
Referenced by TopSpin< N, k >::TopSpin().
|
private |
|
private |
Definition at line 172 of file TopSpin.h.
Referenced by TopSpin< N, k >::SetPruneSuccessors(), and TopSpin< N, k >::TopSpin().
|
private |
|
private |
|
private |
Definition at line 173 of file TopSpin.h.
Referenced by TopSpin< N, k >::GetWeighted(), TopSpin< N, k >::SetWeighted(), and TopSpin< N, k >::TopSpin().