Utilities to convert from/to Hex and Sg. More...
Functions | |
SgPoint | HexPointToSgPoint (HexPoint p, int height) |
Converts a HexPoint to a SgPoint. | |
HexPoint | SgPointToHexPoint (SgPoint p, int height) |
Converts from from a SgPoint to a HexPoint. | |
SgBlackWhite | HexColorToSgColor (HexColor color) |
Converts a HexColor to SgBlackWhite, color must not equal EMPTY. | |
HexColor | SgColorToHexColor (SgBlackWhite player) |
Converts a SgBlackWhite to a HexColor. | |
SgVector< SgPoint > | BitsetToSgVector (const bitset_t &b, int height) |
Convert a bitset to an SgList of points. | |
void | AddMoveToNode (SgNode *node, HexColor color, HexPoint cell, int height) |
Adds the move to the sg node; does proper conversions. | |
bool | NodeHasSetupInfo (SgNode *node) |
Returns true if node constains any of the following properties: propAddBlack, propAddWhite, propAddEmpty, propPlayer. | |
void | SetPositionInNode (SgNode *root, const StoneBoard &brd, HexColor color) |
Set the position setup properties of this node to encode the given board. | |
void | GetSetupPosition (const SgNode *node, int height, std::vector< HexPoint > &black, std::vector< HexPoint > &white, std::vector< HexPoint > &empty) |
Puts the position in the given vectors. | |
void | SetPositionInBoard (const SgNode *node, StoneBoard &brd) |
Sets node's position in the board. | |
bool | WriteSgf (SgNode *tree, const char *filename, int boardsize) |
Write the given tree to a sgf file. |
Utilities to convert from/to Hex and Sg.
Adds the move to the sg node; does proper conversions.
Definition at line 60 of file HexSgUtil.cpp.
References HexProp::AddMoveProp(), HexColorToSgColor(), and HexPointToSgPoint().
Referenced by HexUctSearch::AppendGame().
SgVector< SgPoint > HexSgUtil::BitsetToSgVector | ( | const bitset_t & | b, | |
int | height | |||
) |
Convert a bitset to an SgList of points.
Definition at line 51 of file HexSgUtil.cpp.
References HexPointToSgPoint().
Referenced by SetPositionInNode().
void HexSgUtil::GetSetupPosition | ( | const SgNode * | node, | |
int | height, | |||
std::vector< HexPoint > & | black, | |||
std::vector< HexPoint > & | white, | |||
std::vector< HexPoint > & | empty | |||
) |
Puts the position in the given vectors.
Definition at line 104 of file HexSgUtil.cpp.
References SgPointToHexPoint().
Referenced by HexHtpEngine::SetPosition(), and SetPositionInBoard().
SgBlackWhite HexSgUtil::HexColorToSgColor | ( | HexColor | color | ) |
Converts a HexColor to SgBlackWhite, color must not equal EMPTY.
Definition at line 36 of file HexSgUtil.cpp.
References BLACK, HexAssert, and HexColorUtil::isBlackWhite().
Referenced by AddMoveToNode(), and SetPositionInNode().
SgPoint HexSgUtil::HexPointToSgPoint | ( | HexPoint | p, | |
int | height | |||
) |
Converts a HexPoint to a SgPoint.
Definition at line 20 of file HexSgUtil.cpp.
References HexPointUtil::pointToCoords().
Referenced by AddMoveToNode(), and BitsetToSgVector().
bool HexSgUtil::NodeHasSetupInfo | ( | SgNode * | node | ) |
Returns true if node constains any of the following properties: propAddBlack, propAddWhite, propAddEmpty, propPlayer.
Definition at line 68 of file HexSgUtil.cpp.
Referenced by BenzeneHtpEngine::CmdHandbookAdd(), and HexHtpEngine::CmdLoadSgf().
void HexSgUtil::SetPositionInBoard | ( | const SgNode * | node, | |
StoneBoard & | brd | |||
) |
Sets node's position in the board.
Definition at line 135 of file HexSgUtil.cpp.
References BLACK, GetSetupPosition(), StoneBoard::Height(), StoneBoard::PlayMove(), StoneBoard::StartNewGame(), and WHITE.
void HexSgUtil::SetPositionInNode | ( | SgNode * | root, | |
const StoneBoard & | brd, | |||
HexColor | color | |||
) |
Set the position setup properties of this node to encode the given board.
Definition at line 77 of file HexSgUtil.cpp.
References BitsetToSgVector(), StoneBoard::Const(), StoneBoard::GetBlack(), ConstBoard::GetCells(), StoneBoard::GetEmpty(), StoneBoard::GetWhite(), StoneBoard::Height(), and HexColorToSgColor().
Referenced by HexUctSearch::OnStartSearch().
HexColor HexSgUtil::SgColorToHexColor | ( | SgBlackWhite | player | ) |
Converts a SgBlackWhite to a HexColor.
Definition at line 44 of file HexSgUtil.cpp.
References BLACK, HexAssert, and WHITE.
Referenced by BenzeneHtpEngine::CmdHandbookAdd(), and HexHtpEngine::CmdLoadSgf().
HexPoint HexSgUtil::SgPointToHexPoint | ( | SgPoint | p, | |
int | height | |||
) |
Converts from from a SgPoint to a HexPoint.
Definition at line 28 of file HexSgUtil.cpp.
References HexPointUtil::coordsToPoint().
Referenced by HexUctSearch::AppendGame(), BenzeneHtpEngine::CmdHandbookAdd(), HexHtpEngine::CmdLoadSgf(), and GetSetupPosition().
bool HexSgUtil::WriteSgf | ( | SgNode * | tree, | |
const char * | filename, | |||
int | boardsize | |||
) |
Write the given tree to a sgf file.
Returns true on success, false otherwise.
Definition at line 147 of file HexSgUtil.cpp.
References LogWarning().
Referenced by HexUctSearch::SaveGames().