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

#include <Hexagon.h>

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

Public Member Functions

 HexagonEnvironment ()
 
 ~HexagonEnvironment ()
 
void SetPieces (const std::vector< tPieceName > &pieces)
 
void SetFlippable (const std::array< tFlipType, numPieces > &flips)
 
void GetSuccessors (const HexagonSearchState &nodeID, std::vector< HexagonSearchState > &neighbors) const
 
void GetActions (const HexagonSearchState &nodeID, std::vector< HexagonAction > &actions) const
 
HexagonAction GetAction (const HexagonSearchState &s1, const HexagonSearchState &s2) const
 
void ApplyAction (HexagonSearchState &s, HexagonAction a) const
 
void UndoAction (HexagonSearchState &s, HexagonAction a) const
 
void GetNextState (const HexagonSearchState &, HexagonAction, HexagonSearchState &) const
 
bool InvertAction (HexagonAction &a) const
 
void RotateCW (HexagonSearchState &s) const
 
HexagonAction RotateCW (HexagonAction a) const
 
void Flip (HexagonSearchState &s) const
 
HexagonAction Flip (HexagonAction a) const
 
bool GoalTest (const HexagonSearchState &node) const
 Goal Test if the goal is stored. More...
 
double HCost (const HexagonSearchState &node1, const HexagonSearchState &node2) const
 Heuristic value between two arbitrary nodes. More...
 
double GCost (const HexagonSearchState &node1, const HexagonSearchState &node2) const
 
double GCost (const HexagonSearchState &node, const HexagonAction &act) const
 
bool GoalTest (const HexagonSearchState &node, const HexagonSearchState &goal) const
 
uint64_t GetStateHash (const HexagonSearchState &node) const
 
uint64_t GetActionHash (HexagonAction act) const
 
void GeneratePieceCoordinates (tPieceName p)
 Prints out the triangles used for this piece in HOG2 coordinates. More...
 
void GenerateBoardBorder ()
 Prints out the outer coorsinates of the board. More...
 
void Draw (Graphics::Display &display) const
 
void DrawSetup (Graphics::Display &display) const
 Draws available pieces and constraints. More...
 
void Draw (Graphics::Display &display, const HexagonSearchState &) const
 
- Public Member Functions inherited from SearchEnvironment< HexagonSearchState, HexagonAction >
virtual ~SearchEnvironment ()
 
virtual int GetNumSuccessors (const HexagonSearchState &stateID) const
 
virtual void StoreGoal (HexagonSearchState &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 double HCost (const HexagonSearchState &node1, const HexagonSearchState &node2, double parentHCost) const
 
virtual double HCost (const HexagonSearchState &node) const
 Heuristic value between node and the stored goal. More...
 
virtual uint64_t GetMaxHash () const
 
virtual void GetStateFromHash (uint64_t parent, HexagonSearchState &s) const
 
virtual double GetPathLength (std::vector< HexagonSearchState > &neighbors)
 
virtual double GetPathLength (const HexagonSearchState &start, std::vector< HexagonAction > &neighbors)
 
virtual OccupancyInterface< HexagonSearchState, HexagonAction > * GetOccupancyInfo ()
 
virtual void SetOccupancyInfo (OccupancyInterface< HexagonSearchState, HexagonAction > *)
 
virtual void OpenGLDraw () const
 
virtual void OpenGLDraw (const HexagonSearchState &) const
 
virtual void OpenGLDraw (const HexagonSearchState &, const HexagonSearchState &, float) const
 Draw the transition at some percentage 0...1 between two states. More...
 
virtual void OpenGLDraw (const HexagonSearchState &, const HexagonAction &) const
 
virtual void GLLabelState (const HexagonSearchState &, const char *) const
 
virtual void GLDrawLine (const HexagonSearchState &x, const HexagonSearchState &y) const
 
virtual void GLDrawPath (const std::vector< HexagonSearchState > &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 DrawLine (Graphics::Display &display, const HexagonSearchState &x, const HexagonSearchState &y, float width=1.0) const
 
- Public Member Functions inherited from Heuristic< HexagonSearchState >
 Heuristic ()
 
virtual ~Heuristic ()
 

Private Member Functions

void BuildRotationTable ()
 
void BuildFlipTable ()
 
void IndexToXY (int index, int &x, int &y) const
 
void GetCorners (int x, int y, Graphics::point &p1, Graphics::point &p2, Graphics::point &p3) const
 
bool GetBorder (int x, int y, int xoff, int yoff, Graphics::point &p1, Graphics::point &p2) const
 
bool Valid (int x, int y) const
 

Private Attributes

std::vector< rgbColorpieceColors
 
std::vector< int > pieces
 
std::array< tFlipType, numPiecesflippable
 
Hexagon hex
 
int rotate30Map [numPieces][14 *6 *2+1]
 
int flipMap [numPieces][14 *6 *2+1]
 

Additional Inherited Members

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

Detailed Description

Definition at line 175 of file Hexagon.h.

Constructor & Destructor Documentation

◆ HexagonEnvironment()

HexagonEnvironment::HexagonEnvironment ( )

◆ ~HexagonEnvironment()

HexagonEnvironment::~HexagonEnvironment ( )

Definition at line 597 of file Hexagon.cpp.

Member Function Documentation

◆ ApplyAction()

void HexagonEnvironment::ApplyAction ( HexagonSearchState s,
HexagonAction  a 
) const
virtual

◆ BuildFlipTable()

void HexagonEnvironment::BuildFlipTable ( )
private

Definition at line 641 of file Hexagon.cpp.

References flipMap, flipTable, locations, and numPieces.

Referenced by HexagonEnvironment().

◆ BuildRotationTable()

void HexagonEnvironment::BuildRotationTable ( )
private

Definition at line 602 of file Hexagon.cpp.

References locations, numPieces, rotate30Map, and rotateCWTable.

Referenced by HexagonEnvironment().

◆ Draw() [1/2]

void HexagonEnvironment::Draw ( Graphics::Display display) const
virtual

Reimplemented from SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 895 of file Hexagon.cpp.

◆ Draw() [2/2]

void HexagonEnvironment::Draw ( Graphics::Display display,
const HexagonSearchState s 
) const
virtual

◆ DrawSetup()

void HexagonEnvironment::DrawSetup ( Graphics::Display display) const

Draws available pieces and constraints.

Definition at line 901 of file Hexagon.cpp.

References Hexagon::DrawSetup(), and hex.

◆ Flip() [1/2]

HexagonAction HexagonEnvironment::Flip ( HexagonAction  a) const

Definition at line 706 of file Hexagon.cpp.

References flipMap, HexagonAction::location, and HexagonAction::piece.

◆ Flip() [2/2]

void HexagonEnvironment::Flip ( HexagonSearchState s) const

Definition at line 696 of file Hexagon.cpp.

References ApplyAction(), HexagonSearchState::cnt, and HexagonSearchState::state.

◆ GCost() [1/2]

double HexagonEnvironment::GCost ( const HexagonSearchState node,
const HexagonAction act 
) const
inlinevirtual

Implements SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 203 of file Hexagon.h.

◆ GCost() [2/2]

double HexagonEnvironment::GCost ( const HexagonSearchState node1,
const HexagonSearchState node2 
) const
inlinevirtual

Implements SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 202 of file Hexagon.h.

◆ GenerateBoardBorder()

void HexagonEnvironment::GenerateBoardBorder ( )

Prints out the outer coorsinates of the board.

Definition at line 870 of file Hexagon.cpp.

References GetCorners(), and IndexToXY().

◆ GeneratePieceCoordinates()

void HexagonEnvironment::GeneratePieceCoordinates ( tPieceName  p)

Prints out the triangles used for this piece in HOG2 coordinates.

Definition at line 819 of file Hexagon.cpp.

References HexagonSearchState::bits, HexagonSearchState::cnt, GetCorners(), GetSuccessors(), IndexToXY(), pieceNames, and SetPieces().

◆ GetAction()

HexagonAction HexagonEnvironment::GetAction ( const HexagonSearchState s1,
const HexagonSearchState s2 
) const
virtual

Reimplemented from SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 768 of file Hexagon.cpp.

◆ GetActionHash()

uint64_t HexagonEnvironment::GetActionHash ( HexagonAction  act) const
virtual

◆ GetActions()

void HexagonEnvironment::GetActions ( const HexagonSearchState nodeID,
std::vector< HexagonAction > &  actions 
) const
virtual

◆ GetBorder()

bool HexagonEnvironment::GetBorder ( int  x,
int  y,
int  xoff,
int  yoff,
Graphics::point p1,
Graphics::point p2 
) const
private

Definition at line 1013 of file Hexagon.cpp.

References Hexagon::GetBorder(), and hex.

◆ GetCorners()

void HexagonEnvironment::GetCorners ( int  x,
int  y,
Graphics::point p1,
Graphics::point p2,
Graphics::point p3 
) const
private

Definition at line 1008 of file Hexagon.cpp.

References Hexagon::GetCorners(), and hex.

Referenced by Draw(), GenerateBoardBorder(), and GeneratePieceCoordinates().

◆ GetNextState()

void HexagonEnvironment::GetNextState ( const HexagonSearchState s1,
HexagonAction  a,
HexagonSearchState s2 
) const
virtual

Reimplemented from SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 788 of file Hexagon.cpp.

References ApplyAction().

Referenced by GetSuccessors().

◆ GetStateHash()

uint64_t HexagonEnvironment::GetStateHash ( const HexagonSearchState node) const
virtual

◆ GetSuccessors()

void HexagonEnvironment::GetSuccessors ( const HexagonSearchState nodeID,
std::vector< HexagonSearchState > &  neighbors 
) const
virtual

◆ GoalTest() [1/2]

bool HexagonEnvironment::GoalTest ( const HexagonSearchState node) const
virtual

Goal Test if the goal is stored.

Reimplemented from SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 801 of file Hexagon.cpp.

Referenced by GoalTest().

◆ GoalTest() [2/2]

bool HexagonEnvironment::GoalTest ( const HexagonSearchState node,
const HexagonSearchState goal 
) const
inlinevirtual

Implements SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 204 of file Hexagon.h.

References GoalTest().

◆ HCost()

double HexagonEnvironment::HCost ( const HexagonSearchState node1,
const HexagonSearchState node2 
) const
inlinevirtual

Heuristic value between two arbitrary nodes.

Implements SearchEnvironment< HexagonSearchState, HexagonAction >.

Definition at line 201 of file Hexagon.h.

◆ IndexToXY()

void HexagonEnvironment::IndexToXY ( int  index,
int &  x,
int &  y 
) const
private

Definition at line 940 of file Hexagon.cpp.

Referenced by Draw(), GenerateBoardBorder(), and GeneratePieceCoordinates().

◆ InvertAction()

bool HexagonEnvironment::InvertAction ( HexagonAction a) const
virtual

◆ RotateCW() [1/2]

HexagonAction HexagonEnvironment::RotateCW ( HexagonAction  a) const

Definition at line 690 of file Hexagon.cpp.

References HexagonAction::location, HexagonAction::piece, and rotate30Map.

◆ RotateCW() [2/2]

void HexagonEnvironment::RotateCW ( HexagonSearchState s) const

Definition at line 680 of file Hexagon.cpp.

References ApplyAction(), HexagonSearchState::cnt, and HexagonSearchState::state.

◆ SetFlippable()

void HexagonEnvironment::SetFlippable ( const std::array< tFlipType, numPieces > &  flips)

Definition at line 591 of file Hexagon.cpp.

References flippable.

◆ SetPieces()

void HexagonEnvironment::SetPieces ( const std::vector< tPieceName > &  pieces)

Definition at line 584 of file Hexagon.cpp.

References pieces.

Referenced by GeneratePieceCoordinates().

◆ UndoAction()

void HexagonEnvironment::UndoAction ( HexagonSearchState s,
HexagonAction  a 
) const
virtual

◆ Valid()

bool HexagonEnvironment::Valid ( int  x,
int  y 
) const
private

Definition at line 1018 of file Hexagon.cpp.

References hex, and Hexagon::Valid().

Member Data Documentation

◆ flipMap

int HexagonEnvironment::flipMap[numPieces][14 *6 *2+1]
private

Definition at line 231 of file Hexagon.h.

Referenced by BuildFlipTable(), and Flip().

◆ flippable

std::array<tFlipType, numPieces> HexagonEnvironment::flippable
private

Definition at line 228 of file Hexagon.h.

Referenced by GetActions(), HexagonEnvironment(), and SetFlippable().

◆ hex

Hexagon HexagonEnvironment::hex
private

Definition at line 229 of file Hexagon.h.

Referenced by DrawSetup(), GetBorder(), GetCorners(), and Valid().

◆ pieceColors

std::vector<rgbColor> HexagonEnvironment::pieceColors
private

Definition at line 226 of file Hexagon.h.

◆ pieces

std::vector<int> HexagonEnvironment::pieces
private

Definition at line 227 of file Hexagon.h.

Referenced by GetActions(), HexagonEnvironment(), and SetPieces().

◆ rotate30Map

int HexagonEnvironment::rotate30Map[numPieces][14 *6 *2+1]
private

Definition at line 230 of file Hexagon.h.

Referenced by BuildRotationTable(), and RotateCW().


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