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

#include <RC.h>

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

Public Member Functions

void DrawCubies (Graphics::Display &display) const
 
void DrawCubiesRotating (Graphics::Display &display) const
 
void RotateCubies (float add[3])
 
void RotateFace (int face, int move)
 
void InterpFaceRot (float progress)
 
void TestUpdate ()
 
 RC ()
 
std::string GetName ()
 
void SetPruneSuccessors (bool val)
 
void GetSuccessors (const RCState &nodeID, std::vector< RCState > &neighbors) const
 
void GetActions (const RCState &nodeID, std::vector< RCAction > &actions) const
 
void GetPrunedActions (const RCState &nodeID, RCAction lastAction, std::vector< RCAction > &actions) const
 
RCAction GetAction (const RCState &s1, const RCState &s2) const
 
void ApplyAction (RCState &s, RCAction a) const
 
void UndoAction (RCState &s, RCAction a) const
 
void GetNextState (const RCState &, RCAction, RCState &) const
 
bool InvertAction (RCAction &a) const
 
double HCost (const RCState &node1, const RCState &node2) const
 Heuristic value between two arbitrary nodes. More...
 
double HCost (const RCState &node1, const RCState &node2, double parentHCost) const
 
int Edge12PDBDist (const RCState &s)
 
double HCost (const RCState &node) const
 Heuristic value between node and the stored goal. More...
 
double GCost (const RCState &node1, const RCState &node2) const
 
double GCost (const RCState &node, const RCAction &act) const
 
bool GoalTest (const RCState &node, const RCState &goal) const
 
bool GoalTest (const RCState &node) const
 Goal Test if the goal is stored. More...
 
uint64_t GetStateHash (const RCState &node) const
 
uint64_t GetActionHash (RCAction act) const
 
void GetStateFromHash (uint64_t hash, RCState &node) const
 
void OpenGLDraw () const
 
void OpenGLDraw (const RCState &) const
 
void OpenGLDrawCorners (const RCState &) const
 
void OpenGLDrawEdges (const RCState &) const
 
void OpenGLDrawEdgeDual (const RCState &) const
 
void OpenGLDrawCenters () const
 
void OpenGLDrawCubeBackground () const
 
void OpenGLDraw (const RCState &, const RCState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
void OpenGLDraw (const RCState &, const RCAction &) const
 
void Draw (Graphics::Display &display, const RCState &) const
 
void OpenGLDrawCube (int cube) const
 
void SetFaceColor (int face) const
 
uint64_t GetPDBSizeCorner () const
 
uint64_t GetPDBHashCorner (const RCState &s, int threadID) const
 
void GetStateFromPDBHashCorner (uint64_t hash, RCState &s, int threadID) const
 
uint64_t GetStateHashCorner (const RCState &s)
 
uint64_t FactorialUpperK (int n, int k) const
 
- Public Member Functions inherited from SearchEnvironment< RCState, RCAction >
virtual ~SearchEnvironment ()
 
virtual int GetNumSuccessors (const RCState &stateID) const
 
virtual void StoreGoal (RCState &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 uint64_t GetMaxHash () const
 
virtual double GetPathLength (std::vector< RCState > &neighbors)
 
virtual double GetPathLength (const RCState &start, std::vector< RCAction > &neighbors)
 
virtual OccupancyInterface< RCState, RCAction > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< RCState, RCAction > *)
 
virtual void OpenGLDraw () const
 
virtual void GLLabelState (const RCState &, const char *) const
 
virtual void GLDrawLine (const RCState &x, const RCState &y) const
 
virtual void GLDrawPath (const std::vector< RCState > &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 DrawLine (Graphics::Display &display, const RCState &x, const RCState &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< RCState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Public Attributes

std::vector< int > corners
 
std::vector< int > edges
 
const int fromFaceToCenter [6]
 
const int faceBlackUnderside [6]
 
const float piOver2 = 1.57079632679
 
const float turnSpd = 0.04
 
const int edgeOrder [4] = {1, 5, 7, 3}
 
const int cornerOrder [4] = {0, 2, 8, 6}
 
const int convertStatePos [20]
 
Cubie cubies [26]
 
float rotationTotal [3]
 
int cubiesOnFace [6][9]
 
int cubieInPos [26]
 
int faceTurning
 
int notInFaceTurning [6][17]
 
bool rotating = false
 
bool rotatingFaceBehind = false
 
float rotProgress = 0
 
float turnArr [3]
 
float interpArr [3]
 
bool passiveRot = true
 
std::vector< RCActionhistory
 
bool pruneSuccessors
 
- Public Attributes inherited from Heuristic< RCState >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 

Additional Inherited Members

- Protected Attributes inherited from SearchEnvironment< RCState, RCAction >
bool bValidSearchGoal
 
RCState searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 244 of file RC.h.

Constructor & Destructor Documentation

◆ RC()

RC::RC ( )
inline

Member Function Documentation

◆ ApplyAction()

void RC::ApplyAction ( RCState s,
RCAction  a 
) const
virtual

◆ Draw()

void RC::Draw ( Graphics::Display display,
const RCState state 
) const
virtual

◆ DrawCubies()

void RC::DrawCubies ( Graphics::Display display) const

Definition at line 964 of file RC.cpp.

References cubies, Cubie::Draw(), DrawCubiesRotating(), and rotating.

Referenced by Draw().

◆ DrawCubiesRotating()

void RC::DrawCubiesRotating ( Graphics::Display display) const

Definition at line 981 of file RC.cpp.

References cubieInPos, cubies, cubiesOnFace, Draw(), faceTurning, notInFaceTurning, and rotatingFaceBehind.

Referenced by DrawCubies().

◆ Edge12PDBDist()

int RC::Edge12PDBDist ( const RCState s)

◆ FactorialUpperK()

uint64_t RC::FactorialUpperK ( int  n,
int  k 
) const

Definition at line 1740 of file RC.cpp.

◆ GCost() [1/2]

double RC::GCost ( const RCState node,
const RCAction act 
) const
inlinevirtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 403 of file RC.h.

◆ GCost() [2/2]

double RC::GCost ( const RCState node1,
const RCState node2 
) const
inlinevirtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 402 of file RC.h.

◆ GetAction()

RCAction RC::GetAction ( const RCState s1,
const RCState s2 
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1267 of file RC.cpp.

References GetNextState().

◆ GetActionHash()

uint64_t RC::GetActionHash ( RCAction  act) const
inlinevirtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 411 of file RC.h.

◆ GetActions()

void RC::GetActions ( const RCState nodeID,
std::vector< RCAction > &  actions 
) const
virtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1235 of file RC.cpp.

References history, and pruneSuccessors.

Referenced by RubiksCubeInstances::GetRandomN().

◆ GetName()

std::string RC::GetName ( )
inline

Definition at line 380 of file RC.h.

◆ GetNextState()

void RC::GetNextState ( const RCState s1,
RCAction  a,
RCState s2 
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1303 of file RC.cpp.

References ApplyAction().

Referenced by GetAction(), and GetSuccessors().

◆ GetPDBHashCorner()

uint64_t RC::GetPDBHashCorner ( const RCState s,
int  threadID 
) const

Definition at line 1539 of file RC.cpp.

References corners, RCState::indices, min(), and RCState::rotation.

◆ GetPDBSizeCorner()

uint64_t RC::GetPDBSizeCorner ( ) const

Definition at line 1533 of file RC.cpp.

◆ GetPrunedActions()

void RC::GetPrunedActions ( const RCState nodeID,
RCAction  lastAction,
std::vector< RCAction > &  actions 
) const

Definition at line 1215 of file RC.cpp.

◆ GetStateFromHash()

void RC::GetStateFromHash ( uint64_t  hash,
RCState node 
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1365 of file RC.cpp.

◆ GetStateFromPDBHashCorner()

void RC::GetStateFromPDBHashCorner ( uint64_t  hash,
RCState s,
int  threadID 
) const

Definition at line 1576 of file RC.cpp.

References corners, RCState::indices, min(), and RCState::rotation.

◆ GetStateHash()

uint64_t RC::GetStateHash ( const RCState node) const
virtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1359 of file RC.cpp.

◆ GetStateHashCorner()

uint64_t RC::GetStateHashCorner ( const RCState s)

Definition at line 1625 of file RC.cpp.

References RCState::rotation.

◆ GetSuccessors()

void RC::GetSuccessors ( const RCState nodeID,
std::vector< RCState > &  neighbors 
) const
virtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1206 of file RC.cpp.

References GetNextState().

◆ GoalTest() [1/2]

bool RC::GoalTest ( const RCState node) const
virtual

Goal Test if the goal is stored.

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1347 of file RC.cpp.

◆ GoalTest() [2/2]

bool RC::GoalTest ( const RCState node,
const RCState goal 
) const
virtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1341 of file RC.cpp.

◆ HCost() [1/3]

double RC::HCost ( const RCState node) const
virtual

Heuristic value between node and the stored goal.

Asserts that the goal is stored

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1336 of file RC.cpp.

References HCost().

◆ HCost() [2/3]

double RC::HCost ( const RCState node1,
const RCState node2 
) const
virtual

Heuristic value between two arbitrary nodes.

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1329 of file RC.cpp.

Referenced by HCost().

◆ HCost() [3/3]

double RC::HCost ( const RCState node1,
const RCState node2,
double  parentHCost 
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1323 of file RC.cpp.

References HCost().

◆ InterpFaceRot()

void RC::InterpFaceRot ( float  progress)

◆ InvertAction()

bool RC::InvertAction ( RCAction a) const
virtual

Implements SearchEnvironment< RCState, RCAction >.

Definition at line 1309 of file RC.cpp.

Referenced by UndoAction().

◆ OpenGLDraw() [1/4]

void RC::OpenGLDraw ( ) const

Definition at line 1370 of file RC.cpp.

◆ OpenGLDraw() [2/4]

void RC::OpenGLDraw ( const RCState s) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1373 of file RC.cpp.

◆ OpenGLDraw() [3/4]

void RC::OpenGLDraw ( const RCState ,
const RCAction  
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1402 of file RC.cpp.

◆ OpenGLDraw() [4/4]

void RC::OpenGLDraw ( const RCState s1,
const RCState s2,
float  t 
) const
virtual

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

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1399 of file RC.cpp.

◆ OpenGLDrawCenters()

void RC::OpenGLDrawCenters ( ) const

Definition at line 1388 of file RC.cpp.

◆ OpenGLDrawCorners()

void RC::OpenGLDrawCorners ( const RCState s) const

Definition at line 1376 of file RC.cpp.

◆ OpenGLDrawCube()

void RC::OpenGLDrawCube ( int  cube) const

Definition at line 1391 of file RC.cpp.

◆ OpenGLDrawCubeBackground()

void RC::OpenGLDrawCubeBackground ( ) const

Definition at line 1385 of file RC.cpp.

◆ OpenGLDrawEdgeDual()

void RC::OpenGLDrawEdgeDual ( const RCState s) const

Definition at line 1382 of file RC.cpp.

◆ OpenGLDrawEdges()

void RC::OpenGLDrawEdges ( const RCState s) const

Definition at line 1379 of file RC.cpp.

◆ RotateCubies()

void RC::RotateCubies ( float  add[3])

Definition at line 1012 of file RC.cpp.

References cubies, Cubie::ResetToBase(), Cubie::RotateRelative(), and rotationTotal.

Referenced by TestUpdate().

◆ RotateFace()

void RC::RotateFace ( int  face,
int  move 
)

◆ SetFaceColor()

void RC::SetFaceColor ( int  face) const

Definition at line 1394 of file RC.cpp.

◆ SetPruneSuccessors()

void RC::SetPruneSuccessors ( bool  val)
inline

Definition at line 381 of file RC.h.

References history, and pruneSuccessors.

Referenced by RubiksCubeInstances::GetRandomN().

◆ TestUpdate()

void RC::TestUpdate ( )

◆ UndoAction()

void RC::UndoAction ( RCState s,
RCAction  a 
) const
virtual

Reimplemented from SearchEnvironment< RCState, RCAction >.

Definition at line 1289 of file RC.cpp.

References history, InvertAction(), pruneSuccessors, and RCState::RotateFace().

Member Data Documentation

◆ convertStatePos

const int RC::convertStatePos[20]
Initial value:
=
{
9,
3,
1,
5,
11,
22,
18,
20,
14,
7,
16,
24,
0,
2,
19,
17,
6,
8,
25,
23
}

Definition at line 267 of file RC.h.

Referenced by Draw().

◆ cornerOrder

const int RC::cornerOrder[4] = {0, 2, 8, 6}

Definition at line 266 of file RC.h.

Referenced by RotateFace().

◆ corners

std::vector<int> RC::corners

Definition at line 248 of file RC.h.

Referenced by GetPDBHashCorner(), GetStateFromPDBHashCorner(), and RC().

◆ cubieInPos

int RC::cubieInPos[26]

Definition at line 295 of file RC.h.

Referenced by DrawCubiesRotating(), InterpFaceRot(), RC(), and RotateFace().

◆ cubies

Cubie RC::cubies[26]
mutable

◆ cubiesOnFace

int RC::cubiesOnFace[6][9]

Definition at line 294 of file RC.h.

Referenced by DrawCubiesRotating(), InterpFaceRot(), RC(), and RotateFace().

◆ edgeOrder

const int RC::edgeOrder[4] = {1, 5, 7, 3}

Definition at line 265 of file RC.h.

Referenced by RotateFace().

◆ edges

std::vector<int> RC::edges

Definition at line 249 of file RC.h.

Referenced by RC().

◆ faceBlackUnderside

const int RC::faceBlackUnderside[6]
Initial value:
=
{
5, 3, 4, 1, 2, 0
}

Definition at line 259 of file RC.h.

Referenced by RotateFace().

◆ faceTurning

int RC::faceTurning

Definition at line 296 of file RC.h.

Referenced by DrawCubiesRotating(), InterpFaceRot(), and RotateFace().

◆ fromFaceToCenter

const int RC::fromFaceToCenter[6]
Initial value:
=
{
3, 9, 1, -9, -1, -3
}

Definition at line 253 of file RC.h.

Referenced by RotateFace().

◆ history

std::vector<RCAction> RC::history
mutable

Definition at line 429 of file RC.h.

Referenced by ApplyAction(), GetActions(), SetPruneSuccessors(), and UndoAction().

◆ interpArr

float RC::interpArr[3]

Definition at line 302 of file RC.h.

Referenced by InterpFaceRot().

◆ notInFaceTurning

int RC::notInFaceTurning[6][17]

Definition at line 297 of file RC.h.

Referenced by DrawCubiesRotating(), InterpFaceRot(), and RC().

◆ passiveRot

bool RC::passiveRot = true

Definition at line 303 of file RC.h.

Referenced by TestUpdate().

◆ piOver2

const float RC::piOver2 = 1.57079632679

Definition at line 263 of file RC.h.

Referenced by RotateFace().

◆ pruneSuccessors

bool RC::pruneSuccessors

Definition at line 431 of file RC.h.

Referenced by ApplyAction(), GetActions(), RC(), SetPruneSuccessors(), and UndoAction().

◆ rotating

bool RC::rotating = false

Definition at line 298 of file RC.h.

Referenced by DrawCubies(), RotateFace(), and TestUpdate().

◆ rotatingFaceBehind

bool RC::rotatingFaceBehind = false

Definition at line 299 of file RC.h.

Referenced by DrawCubiesRotating(), and InterpFaceRot().

◆ rotationTotal

float RC::rotationTotal[3]

Definition at line 293 of file RC.h.

Referenced by Draw(), InterpFaceRot(), RC(), RotateCubies(), and TestUpdate().

◆ rotProgress

float RC::rotProgress = 0

Definition at line 300 of file RC.h.

Referenced by RotateFace(), and TestUpdate().

◆ turnArr

float RC::turnArr[3]

Definition at line 301 of file RC.h.

Referenced by InterpFaceRot(), and RotateFace().

◆ turnSpd

const float RC::turnSpd = 0.04

Definition at line 264 of file RC.h.

Referenced by TestUpdate().


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