Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexPointUtil Namespace Reference

Utilities on HexPoints: converting to/from strings, testing for edges, converting to/from x/y coordinates, etc. More...

Functions

std::string ToString (HexPoint p)
 Converts a HexPoint to a string.
std::string ToString (const HexPointPair &p)
 Converts a pair of HexPoints to a string.
std::string ToString (const PointSequence &lst)
 Returns a space separated output of points in lst.
std::string ToString (const bitset_t &b)
 Returns a string representation of the bitset's set bits.
HexPoint FromString (const std::string &name)
 Returns the HexPoint with the given name; INVALID_POINT otherwise.
void FromString (const std::string &str, PointSequence &pts)
 Reads a PointSequence from a string of space separated points.
bool isSwap (HexPoint c)
 Returns true if this point is a swap move.
bool isEdge (HexPoint c)
 Returns true if this point is an edge point.
bool isInteriorCell (HexPoint c)
 Returns true if this point is an interior cell.
HexPoint oppositeEdge (HexPoint edge)
 Returns the edge opposite the given edge.
HexPoint leftEdge (HexPoint edge)
 Returns the edge to the left of the given edge.
HexPoint rightEdge (HexPoint edge)
 Returns the edge to the right of the given edge.
HexPoint colorEdge1 (HexColor color)
 Returns a color's first edge.
HexPoint colorEdge2 (HexColor color)
 Returns a color's second edge.
bool isColorEdge (HexPoint cell, HexColor color)
 Returns true if cell is one of color's edges.
void pointToCoords (HexPoint cell, int &x, int &y)
 Converts cell into its x and y components, where.
HexPoint coordsToPoint (int x, int y)
 Returns the HexPoint corresponding to the given x and y coords.
int DeltaX (int dir)
 Returns the change in the x-coordinate when travelling in the given direction.
int DeltaY (int dir)
 Returns the change in the y-coordinate when travelling in the given direction.

Detailed Description

Utilities on HexPoints: converting to/from strings, testing for edges, converting to/from x/y coordinates, etc.


Function Documentation

HexPoint HexPointUtil::colorEdge1 ( HexColor  color  )  [inline]
HexPoint HexPointUtil::colorEdge2 ( HexColor  color  )  [inline]
HexPoint HexPointUtil::coordsToPoint ( int  x,
int  y 
) [inline]
int HexPointUtil::DeltaX ( int  dir  )  [inline]

Returns the change in the x-coordinate when travelling in the given direction.

Definition at line 345 of file HexPoint.hpp.

References DIR_EAST, HexAssert, and NUM_DIRECTIONS.

Referenced by BenzeneHtpEngine::CmdEncodePattern(), ConstBoard::ComputeNeighbours(), PatternMatcherData::Initialize(), Pattern::mirror(), and BoardUtils::PointInDir().

int HexPointUtil::DeltaY ( int  dir  )  [inline]

Returns the change in the y-coordinate when travelling in the given direction.

Definition at line 352 of file HexPoint.hpp.

References DIR_EAST, HexAssert, and NUM_DIRECTIONS.

Referenced by BenzeneHtpEngine::CmdEncodePattern(), ConstBoard::ComputeNeighbours(), PatternMatcherData::Initialize(), Pattern::mirror(), and BoardUtils::PointInDir().

void HexPointUtil::FromString ( const std::string &  str,
PointSequence pts 
)

Reads a PointSequence from a string of space separated points.

Definition at line 82 of file HexPoint.cpp.

References FromString().

HexPoint HexPointUtil::FromString ( const std::string &  name  ) 

Returns the HexPoint with the given name; INVALID_POINT otherwise.

Definition at line 73 of file HexPoint.cpp.

References FIRST_INVALID, and INVALID_POINT.

Referenced by BookCommands::CmdBookDumpPolarizedLeafs(), FromString(), BookUtil::ImportSolvedStates(), HtpUtil::MoveArg(), and CacheBook::ReadPoints().

bool HexPointUtil::isColorEdge ( HexPoint  cell,
HexColor  color 
) [inline]

Returns true if cell is one of color's edges.

Definition at line 325 of file HexPoint.hpp.

References colorEdge1(), colorEdge2(), HexAssert, and HexColorUtil::isBlackWhite().

Referenced by BoardUtils::Mirror().

bool HexPointUtil::isEdge ( HexPoint  c  )  [inline]
bool HexPointUtil::isInteriorCell ( HexPoint  c  )  [inline]

Returns true if this point is an interior cell.

Definition at line 278 of file HexPoint.hpp.

References FIRST_CELL, and FIRST_INVALID.

Referenced by BoardUtils::PointInDir().

bool HexPointUtil::isSwap ( HexPoint  c  )  [inline]

Returns true if this point is a swap move.

Definition at line 268 of file HexPoint.hpp.

References SWAP_PIECES.

Referenced by Game::PlayMove(), and PatternState::Update().

HexPoint HexPointUtil::leftEdge ( HexPoint  edge  )  [inline]

Returns the edge to the left of the given edge.

Definition at line 293 of file HexPoint.hpp.

References EAST, HexAssert, isEdge(), NORTH, SOUTH, and WEST.

Referenced by ConstBoard::ComputeNeighbours(), and BoardUtils::Mirror().

HexPoint HexPointUtil::oppositeEdge ( HexPoint  edge  )  [inline]

Returns the edge opposite the given edge.

Definition at line 283 of file HexPoint.hpp.

References EAST, HexAssert, isEdge(), NORTH, SOUTH, and WEST.

Referenced by BoardUtils::Rotate().

void HexPointUtil::pointToCoords ( HexPoint  cell,
int &  x,
int &  y 
) [inline]

Converts cell into its x and y components, where.

        x = (cell-FIRST_CELL) % MAX_WIDTH;
        y = (cell-FIRST_CELL) / MAX_WIDTH;

Does not handle cases where cell is an edge. ConstBoard has a method for that.

Definition at line 331 of file HexPoint.hpp.

References FIRST_CELL, FIRST_INVALID, HexAssert, and MAX_WIDTH.

Referenced by HandicapPlayer::buildResponseMap(), BenzeneHtpEngine::CmdEncodePattern(), ConstBoard::ComputeNeighbours(), ConstBoard::Distance(), HexSgUtil::HexPointToSgPoint(), PatternMatcherData::Initialize(), BoardUtils::Mirror(), BoardUtils::PointInDir(), and BoardUtils::Rotate().

HexPoint HexPointUtil::rightEdge ( HexPoint  edge  )  [inline]

Returns the edge to the right of the given edge.

Definition at line 303 of file HexPoint.hpp.

References EAST, HexAssert, isEdge(), NORTH, SOUTH, and WEST.

Referenced by ConstBoard::ComputeNeighbours(), and BoardUtils::Mirror().

std::string HexPointUtil::ToString ( const bitset_t b  ) 

Returns a string representation of the bitset's set bits.

std::string HexPointUtil::ToString ( const PointSequence lst  ) 

Returns a space separated output of points in lst.

Definition at line 100 of file HexPoint.cpp.

References ToString().

std::string HexPointUtil::ToString ( const HexPointPair p  ) 

Converts a pair of HexPoints to a string.

Definition at line 93 of file HexPoint.cpp.

References ToString().

std::string HexPointUtil::ToString ( HexPoint  p  ) 


6 Jan 2011 Doxygen 1.6.3