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. |
Utilities on HexPoints: converting to/from strings, testing for edges, converting to/from x/y coordinates, etc.
Returns a color's first edge.
NORTH for VERTICAL_COLOR and EAST for !VERTICAL_COLOR.
Definition at line 313 of file HexPoint.hpp.
References EAST, HexAssert, HexColorUtil::isBlackWhite(), NORTH, and VERTICAL_COLOR.
Referenced by TwoDistance::ComputeScores(), Resistance::ComputeScores(), VCBuilder::DoSearch(), BoardUtils::FindSplittingDecomposition(), VCUtils::GetMustplay(), Groups::GetWinner(), DfsSolver::HandleProof(), ProofUtil::InitialProofForOpponent(), isColorEdge(), EndgameUtils::IsLostGame(), EndgameUtils::IsWonGame(), DfsSolver::OrderMoves(), ResistanceUtil::SimulateAndOverEdge(), VCSet::SoftLimit(), DfsSolver::SolveDecomposition(), and StoneBoard::StartNewGame().
Returns a color's second edge.
SOUTH for VERTICAL_COLOR and WEST for !VERTICAL_COLOR.
Definition at line 319 of file HexPoint.hpp.
References HexAssert, HexColorUtil::isBlackWhite(), SOUTH, VERTICAL_COLOR, and WEST.
Referenced by TwoDistance::ComputeScores(), Resistance::ComputeScores(), VCBuilder::DoSearch(), BoardUtils::FindSplittingDecomposition(), VCUtils::GetMustplay(), Groups::GetWinner(), DfsSolver::HandleProof(), ProofUtil::InitialProofForOpponent(), isColorEdge(), EndgameUtils::IsLostGame(), EndgameUtils::IsWonGame(), DfsSolver::OrderMoves(), ResistanceUtil::SimulateAndOverEdge(), VCSet::SoftLimit(), DfsSolver::SolveDecomposition(), and StoneBoard::StartNewGame().
HexPoint HexPointUtil::coordsToPoint | ( | int | x, | |
int | y | |||
) | [inline] |
Returns the HexPoint corresponding to the given x and y coords.
point = FIRST_CELL + (y*MAX_WIDTH) + x;
Definition at line 338 of file HexPoint.hpp.
References FIRST_CELL, HexAssert, MAX_HEIGHT, and MAX_WIDTH.
Referenced by HandicapPlayer::buildResponseMap(), BoardUtils::CenterPointLeft(), BoardUtils::CenterPointRight(), ConstBoard::ComputePointList(), BoardUtils::CoordsToPoint(), VCPattern::CreatePatterns(), BoardUtils::Mirror(), BoardUtils::Rotate(), StoneBoard::SetPosition(), HexSgUtil::SgPointToHexPoint(), and StoneBoard::Write().
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().
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] |
Returns true if this point is an edge point.
Definition at line 273 of file HexPoint.hpp.
References EAST, NORTH, SOUTH, and WEST.
Referenced by VCBuilder::AddPatternVCs(), VCBuilder::andClosure(), ConstBoard::ComputeNeighbours(), ConstBoard::Distance(), PatternMatcherData::Initialize(), leftEdge(), BoardUtils::Mirror(), oppositeEdge(), BoardUtils::PointInDir(), rightEdge(), BoardUtils::Rotate(), PatternState::Update(), and VCUtils::ValidEdgeBridge().
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().
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().
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().
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 | ) |
Converts a HexPoint to a string.
Definition at line 67 of file HexPoint.cpp.
References FIRST_INVALID, and HexAssert.
Referenced by HexBoard::AddStones(), BenzeneHtpEngine::CmdFindCombDecomp(), DfpnCommands::CmdFindWinning(), VCCommands::CmdGetCellsConnectedTo(), DfsCommands::CmdGetPV(), DfpnCommands::CmdGetPV(), DfsCommands::CmdSolverFindWinning(), VCCommands::CmdVCIntersection(), VCCommands::CmdVCUnion(), DfsSolver::DumpStats(), WolveSearch::GenerateMoves(), DfsSolver::HandleProof(), StoneBoard::IsBlackWhiteDisjoint(), HexUctUtil::MoveString(), HexUctSearch::MoveString(), BookBuilder< PLAYER >::MoveString(), PlayAndSolve::SolverThread::operator()(), operator<<(), HexBoard::PlayStones(), DfpnSolver::PrintStatistics(), HexAbSearch::SearchState(), DfpnSolver::StartSearch(), VC::toString(), and ToString().