Tracks played stone information. More...
#include <StoneBoard.hpp>
Public Member Functions | |
StoneBoard () | |
Constructs an unusable board. | |
StoneBoard (unsigned size) | |
Constructs a square board. | |
StoneBoard (unsigned width, unsigned height) | |
Constructs a rectangular board. | |
StoneBoard (unsigned width, unsigned height, const std::string &str) | |
Contructs a rectangular board with given state. | |
~StoneBoard () | |
const ConstBoard & | Const () const |
Returns reference to ConstBoard. | |
int | Width () const |
Same as Const().width(). | |
int | Height () const |
Same as Const().height(). | |
hash_t | Hash () const |
Returns zobrist hash for the current position, which depends only on the played cells; unplayed cells do not contribute to the hash. | |
hash_t | Hash (HexColor toPlay) const |
Returns the hash of the position taking the color to play into account. | |
BoardID | GetBoardID () const |
Returns BoardID for the current board state, looking only at the played cells. | |
std::string | GetBoardIDString () const |
Returns BoardID as a string. | |
std::size_t | NumStones () const |
Number of played stones on the interior of the board. | |
HexColor | WhoseTurn () const |
Computes whose turn it is on the given board; IsStandardPosition() must be true to use this method. | |
bool | IsStandardPosition () const |
Returns true if position is attainable in a normal game. | |
std::string | Write () const |
Returns a string representation of the board. | |
std::string | Write (const bitset_t &b) const |
Returns a string representation of the board with the cells marked in the given bitset denoted by a '*'. | |
void | SetPosition (const BoardID &id) |
Sets the board to the state encoded by id. | |
void | SetPosition (const StoneBoard &brd) |
Copies state of brd into this board. | |
void | SetPositionOnlyPlayed (const StoneBoard &brd) |
Copies only the played state of brd. | |
void | SetPosition (const std::string &str) |
Sets state from string. | |
Methods defined on cells and edges. | |
All methods accept and return edge and interior cells only. Note that PlayMove() (which is not in this section) can play a move like (BLACK, RESIGN), but getBlack() (which is in this section) will not return a bitset with the RESIGN move set.
| |
bitset_t | GetBlack () const |
Returns the set of BLACK stones. | |
bitset_t | GetWhite () const |
Returns the set of WHITE stones. | |
bitset_t | GetColor (HexColor color) const |
Returns color's stones. | |
bitset_t | GetEmpty () const |
Returns all empty cells. | |
bitset_t | GetOccupied () const |
Returns all occupied (not empty) cells. | |
bool | IsColor (HexPoint cell, HexColor color) const |
Returns true if cell is of color. | |
bool | IsEmpty (HexPoint cell) const |
Returns true if cell is empty. | |
bool | IsOccupied (HexPoint cell) const |
Returns true if cell is occupied (not empty). | |
Methods defined on all valid moves. | |
bool | IsBlack (HexPoint cell) const |
Returns true if cell is BLACK. | |
bool | IsWhite (HexPoint cell) const |
Returns true if cell is WHITE. | |
HexColor | GetColor (HexPoint cell) const |
Retruns color of cell. | |
bitset_t | GetPlayed () const |
Returns the set of played cells. | |
bitset_t | GetPlayed (HexColor color) const |
bitset_t | GetLegal () const |
Returns the set of all legal moves; ie, moves that can be played from this state. | |
bool | IsPlayed (HexPoint cell) const |
Returns true if cell has been played. | |
bool | IsLegal (HexPoint cell) const |
Returns true if cell is a legal move. | |
Methods not modifying Hash() or BoardID() | |
void | AddColor (HexColor color, const bitset_t &b) |
Adds the cells in b as stones of color. | |
void | RemoveColor (HexColor color, const bitset_t &b) |
Sets cells in b to EMPTY. | |
void | SetColor (HexColor color, HexPoint cell) |
Sets color of cell. | |
void | SetColor (HexColor color, const bitset_t &bs) |
Sets color of cells in bitset. | |
bool | IsSelfRotation () const |
Returns true if rotating the board returns the same board. | |
Methods modifying Hash() and BoardID() | |
void | StartNewGame () |
Clears the board and plays the edge stones. | |
void | SetPlayed (const bitset_t &p) |
Sets the played stones. | |
void | PlayMove (HexColor color, HexPoint cell) |
Plays a move of the given color to the board. | |
void | UndoMove (HexPoint cell) |
Removes the move from the board, setting cell to EMPTY. | |
void | RotateBoard () |
Rotates the board by 180' about the center. | |
void | MirrorBoard () |
Mirrors the board in the diagonal joining acute corners. | |
Operators | |
bool | operator== (const StoneBoard &other) const |
Two boards are equal if their dimensions match and their sets of black, white, and played stones are all equal. | |
bool | operator!= (const StoneBoard &other) const |
Returns true if the boards differ. | |
Iterators | |
BoardIterator | Stones (HexColorSet colorset) const |
Returns iterator over all stones in colorset. | |
BoardIterator | Stones (HexColor color) const |
Returns iterator over all stones of color. | |
Private Member Functions | |
void | ComputeHash () |
void | MarkAsDirty () |
bool | IsBlackWhiteDisjoint () |
Private Attributes | |
ConstBoard * | m_const |
bitset_t | m_played |
bitset_t | m_stones [BLACK_AND_WHITE] |
ZobristHash | m_hash |
bool | m_stones_calculated |
std::vector< HexPoint > | m_stones_list [NUM_COLOR_SETS] |
Tracks played stone information.
Each cell on the board is assigned a HexColor, and so every cell is either EMPTY, BLACK, or WHITE.
Each cell is also marked as 'played' or 'unplayed'. A cell should be marked as played when it corresponds to an actual move played in a game; that is, not a fill-in move. This means it is possible for a cell to be BLACK or WHITE and not played. Played stones contribute to the board hash and id, unplayed stones do not.
Definition at line 35 of file StoneBoard.hpp.
StoneBoard::StoneBoard | ( | ) |
Constructs an unusable board.
This is to allow StoneBoard to appear in a stl container.
Definition at line 13 of file StoneBoard.cpp.
StoneBoard::StoneBoard | ( | unsigned | size | ) | [explicit] |
StoneBoard::StoneBoard | ( | unsigned | width, | |
unsigned | height | |||
) |
Constructs a rectangular board.
Definition at line 26 of file StoneBoard.cpp.
References StartNewGame().
StoneBoard::StoneBoard | ( | unsigned | width, | |
unsigned | height, | |||
const std::string & | str | |||
) |
Contructs a rectangular board with given state.
See SetPosition(std::string)
Definition at line 33 of file StoneBoard.cpp.
References SetPosition().
StoneBoard::~StoneBoard | ( | ) |
Definition at line 40 of file StoneBoard.cpp.
Adds the cells in b as stones of color.
Does not modify hash.
Definition at line 107 of file StoneBoard.cpp.
References benzene_bitset< _Nb >::any(), HexAssert, HexColorUtil::isBlackWhite(), IsBlackWhiteDisjoint(), m_stones, and MarkAsDirty().
Referenced by HexBoard::AddStones(), ICEngine::CliqueCutsetDead(), ICEngine::ComputeDeadCaptured(), ICEngine::FillInMutualFillin(), ICEngine::FillinPermanentlyInferior(), ICEngine::FillInVulnerable(), and HexBoard::PlayStones().
void StoneBoard::ComputeHash | ( | ) | [private] |
Definition at line 160 of file StoneBoard.cpp.
References BLACK, ZobristHash::Compute(), Const(), ConstBoard::GetLocations(), m_hash, m_played, m_stones, and WHITE.
Referenced by MirrorBoard(), RotateBoard(), SetPlayed(), SetPosition(), and StartNewGame().
const ConstBoard & StoneBoard::Const | ( | ) | const [inline] |
Returns reference to ConstBoard.
Definition at line 317 of file StoneBoard.hpp.
References m_const.
Referenced by GroupBuilder::Build(), HandicapPlayer::buildResponseMap(), Groups::CaptainizeBitset(), ICEngine::CheckHandCodedDominates(), PatternState::CheckRotatedPattern(), PatternState::ClearGodels(), BookCommands::CmdBookImportSolvedStates(), VCBuilder::ComputeCapturedSets(), ComputeHash(), HexBoard::Const(), PatternState::CopyState(), StateDB< T >::Get(), GetBlack(), GetBoardID(), GetColor(), GetEmpty(), GetLegal(), GetOccupied(), GetWhite(), IsBlack(), IsColor(), IsEmpty(), IsLegal(), IsOccupied(), IsPlayed(), IsSelfRotation(), IsWhite(), VCPattern::Matches(), PatternState::MatchOnBoard(), VCBuilder::Merge(), MirrorBoard(), NumStones(), PlayMove(), Game::PlayMove(), SwapCheck::PlaySwap(), StateDB< T >::Put(), BoardUtils::RandomEmptyCell(), RotateBoard(), GameUtil::SequenceFromPosition(), SetColor(), SetPosition(), HexSgUtil::SetPositionInNode(), VCPattern::ShiftPattern(), Stones(), UndoMove(), PatternState::Update(), PatternState::UpdateRingGodel(), VCUtils::ValidEdgeBridge(), and WhoseTurn().
bitset_t StoneBoard::GetBlack | ( | ) | const [inline] |
Returns the set of BLACK stones.
Definition at line 342 of file StoneBoard.hpp.
References BLACK, Const(), ConstBoard::GetLocations(), and m_stones.
Referenced by ICEngine::BackupOpponentDead(), GetOccupied(), SetPosition(), HexSgUtil::SetPositionInNode(), SetPositionOnlyPlayed(), and PatternState::Update().
BoardID StoneBoard::GetBoardID | ( | ) | const |
Returns BoardID for the current board state, looking only at the played cells.
Packs each interior cell into 2 bits.
Definition at line 238 of file StoneBoard.cpp.
References BoardID, Const(), EMPTY, GetColor(), GetPlayed(), Height(), benzene_bitset< _Nb >::test(), and Width().
Referenced by GetBoardIDString().
std::string StoneBoard::GetBoardIDString | ( | ) | const |
Returns BoardID as a string.
Definition at line 266 of file StoneBoard.cpp.
References BoardID, byte, and GetBoardID().
Referenced by HexHtpEngine::CmdBoardID().
Returns color's stones.
Definition at line 352 of file StoneBoard.hpp.
References Const(), EMPTY, GetEmpty(), ConstBoard::GetLocations(), HexAssert, HexColorUtil::isValidColor(), and m_stones.
Referenced by VCBuilder::AddPatternVCs(), HexBoard::AddStones(), VCBuilder::andClosure(), GroupBuilder::Build(), HandCodedPattern::check(), BenzeneHtpEngine::CmdComputeDominatedOnCell(), BenzeneHtpEngine::CmdGetAbsorbGroup(), VCBuilder::ComputeCapturedSets(), GetBoardID(), GetLegal(), GetPlayed(), DfsSolver::HandleProof(), VCPattern::Matches(), HexBoard::PlayMove(), HexBoard::PlayStones(), DfsSolver::SolveDecomposition(), Stones(), UndoMove(), PatternState::Update(), PatternState::UpdateRingGodel(), and WhoseTurn().
bitset_t StoneBoard::GetEmpty | ( | ) | const [inline] |
Returns all empty cells.
Definition at line 359 of file StoneBoard.hpp.
References Const(), ConstBoard::GetLocations(), and GetOccupied().
Referenced by VCBuilder::AddBaseVCs(), ICEngine::BackupOpponentDead(), BookUtil::BestMove(), BenzeneHtpEngine::CmdComputeDominated(), BenzeneHtpEngine::CmdComputeReversible(), BenzeneHtpEngine::CmdComputeVulnerable(), BenzeneHtpEngine::CmdEvalInfluence(), BenzeneHtpEngine::CmdEvalResistDelta(), DfpnCommands::CmdFindWinning(), DfsCommands::CmdSolverFindWinning(), ICEngine::ComputeDeadCaptured(), TwoDistance::ComputeDistanceToEdge(), ICEngine::ComputeInferiorCells(), BookUtil::DumpVisualizationData(), ICEngine::FillInMutualFillin(), ICEngine::FillinPermanentlyInferior(), ICEngine::FillInVulnerable(), TwoDistance::FindBest(), BookBuilder< PLAYER >::GetAllLegalMoves(), GetColor(), BookUtil::GetMainLineDepth(), VCUtils::GetMustplay(), HexUctPolicy::InitializeForRollout(), BenzenePlayer::InitSearch(), EndgameUtils::IsLostGame(), ProofUtil::MaximumProofSet(), HexBoard::PopHistory(), BoardUtils::RandomEmptyCell(), PerfectPlayer::Search(), and HexSgUtil::SetPositionInNode().
bitset_t StoneBoard::GetLegal | ( | ) | const |
Returns the set of all legal moves; ie, moves that can be played from this state.
Definition at line 54 of file StoneBoard.cpp.
References Const(), FIRST_TO_PLAY, ConstBoard::GetCells(), GetColor(), GetPlayed(), HexAssert, IsPlayed(), RESIGN, benzene_bitset< _Nb >::set(), and SWAP_PIECES.
Referenced by HexHtpEngine::CmdAllLegalMoves(), and IsLegal().
bitset_t StoneBoard::GetOccupied | ( | ) | const [inline] |
Returns all occupied (not empty) cells.
Definition at line 364 of file StoneBoard.hpp.
References Const(), GetBlack(), ConstBoard::GetLocations(), and GetWhite().
Referenced by GetEmpty(), NumStones(), and VCUtils::ValidEdgeBridge().
Definition at line 405 of file StoneBoard.hpp.
References GetColor(), HexAssert, HexColorUtil::isBlackWhite(), and m_played.
bitset_t StoneBoard::GetPlayed | ( | ) | const [inline] |
Returns the set of played cells.
Definition at line 400 of file StoneBoard.hpp.
References m_played.
Referenced by GetBoardID(), GetLegal(), ProofUtil::InitialProofForOpponent(), IsStandardPosition(), ProofUtil::MaximumProofSet(), NumStones(), SetPosition(), SetPositionOnlyPlayed(), and WhoseTurn().
bitset_t StoneBoard::GetWhite | ( | ) | const [inline] |
Returns the set of WHITE stones.
Definition at line 347 of file StoneBoard.hpp.
References Const(), ConstBoard::GetLocations(), m_stones, and WHITE.
Referenced by ICEngine::BackupOpponentDead(), GetOccupied(), SetPosition(), HexSgUtil::SetPositionInNode(), SetPositionOnlyPlayed(), and PatternState::Update().
Returns the hash of the position taking the color to play into account.
This will be different than the hash returned by Hash().
Definition at line 337 of file StoneBoard.hpp.
References ZobristHash::Hash(), and m_hash.
hash_t StoneBoard::Hash | ( | ) | const [inline] |
Returns zobrist hash for the current position, which depends only on the played cells; unplayed cells do not contribute to the hash.
Changing the color of an unplayed cell does not change the hash for the position. Methods that change the color of played cells internally will always compute a new hash automatically.
Definition at line 332 of file StoneBoard.hpp.
References EMPTY, ZobristHash::Hash(), and m_hash.
Referenced by ICEngine::ComputeInferiorCells(), HexState::Hash(), HexAbSearch::SearchState(), ProofUtil::StoreTranspositions(), and Write().
int StoneBoard::Height | ( | ) | const [inline] |
Same as Const().height().
Definition at line 327 of file StoneBoard.hpp.
References ConstBoard::Height(), and m_const.
Referenced by VCBuilder::AddPatternVCs(), HandicapPlayer::buildResponseMap(), ICEngine::CheckHandCodedDominates(), HexHtpEngine::CmdClearBoard(), BenzeneHtpEngine::CmdHandbookAdd(), HexHtpEngine::CmdLoadSgf(), ICEngine::FindHandCodedDominated(), GetBoardID(), HexBoard::Height(), HexHtpEngine::HexHtpEngine(), HexHtpEngine::NewGame(), SwapCheck::PlaySwap(), SetPosition(), HexHtpEngine::SetPosition(), HexSgUtil::SetPositionInBoard(), HexSgUtil::SetPositionInNode(), and Write().
bool StoneBoard::IsBlack | ( | HexPoint | cell | ) | const [inline] |
Returns true if cell is BLACK.
Definition at line 369 of file StoneBoard.hpp.
References BLACK, Const(), HexAssert, m_stones, and benzene_bitset< _Nb >::test().
Referenced by GetColor(), IsOccupied(), HandicapPlayer::threeToOne(), and Write().
bool StoneBoard::IsBlackWhiteDisjoint | ( | ) | [private] |
Definition at line 418 of file StoneBoard.cpp.
References BLACK, LogWarning(), m_stones, HexPointUtil::ToString(), and WHITE.
Referenced by AddColor(), RemoveColor(), and SetColor().
Returns true if cell is of color.
Definition at line 381 of file StoneBoard.hpp.
References Const(), HexAssert, HexColorUtil::isBlackWhite(), m_stones, and benzene_bitset< _Nb >::test().
bool StoneBoard::IsEmpty | ( | HexPoint | cell | ) | const [inline] |
Returns true if cell is empty.
Definition at line 388 of file StoneBoard.hpp.
References Const(), HexAssert, and IsOccupied().
Referenced by HexUctPolicy::GenerateMove(), HexUctPolicy::GenerateRandomMove(), and HexUctPolicy::GenerateResponseMove().
bool StoneBoard::IsLegal | ( | HexPoint | cell | ) | const |
Returns true if cell is a legal move.
Definition at line 77 of file StoneBoard.cpp.
References Const(), GetLegal(), HexAssert, and benzene_bitset< _Nb >::test().
Referenced by BookUtil::Value().
bool StoneBoard::IsOccupied | ( | HexPoint | cell | ) | const [inline] |
Returns true if cell is occupied (not empty).
Definition at line 394 of file StoneBoard.hpp.
References Const(), HexAssert, IsBlack(), and IsWhite().
Referenced by BenzeneHtpEngine::CmdEvalInfluence(), BenzeneHtpEngine::CmdEvalResist(), BenzeneHtpEngine::CmdEvalTwoDist(), TwoDistance::ComputeScores(), IsEmpty(), and PatternState::Update().
bool StoneBoard::IsPlayed | ( | HexPoint | cell | ) | const [inline] |
Returns true if cell has been played.
Definition at line 411 of file StoneBoard.hpp.
References Const(), HexAssert, m_played, and benzene_bitset< _Nb >::test().
Referenced by HandicapPlayer::buildResponseMap(), GetLegal(), Game::PlayMove(), HandicapPlayer::Search(), HandicapPlayer::threeToOne(), and Write().
bool StoneBoard::IsSelfRotation | ( | ) | const |
Returns true if rotating the board returns the same board.
Definition at line 218 of file StoneBoard.cpp.
References BLACK, Const(), m_stones, BoardUtils::Rotate(), and WHITE.
bool StoneBoard::IsStandardPosition | ( | ) | const [inline] |
Returns true if position is attainable in a normal game.
That is, FIRST_TO_PLAY went first, and the colors alternated afterwards.
Definition at line 444 of file StoneBoard.hpp.
References BLACK, benzene_bitset< _Nb >::count(), GetPlayed(), and WHITE.
Referenced by WhoseTurn().
bool StoneBoard::IsWhite | ( | HexPoint | cell | ) | const [inline] |
Returns true if cell is WHITE.
Definition at line 375 of file StoneBoard.hpp.
References Const(), HexAssert, m_stones, benzene_bitset< _Nb >::test(), and WHITE.
Referenced by GetColor(), IsOccupied(), HandicapPlayer::threeToOne(), and Write().
void StoneBoard::MarkAsDirty | ( | ) | [private] |
Definition at line 102 of file StoneBoard.cpp.
References m_stones_calculated.
Referenced by AddColor(), MirrorBoard(), PlayMove(), RemoveColor(), RotateBoard(), SetColor(), SetPlayed(), SetPosition(), StartNewGame(), and UndoMove().
void StoneBoard::MirrorBoard | ( | ) |
Mirrors the board in the diagonal joining acute corners.
Note that this method requires the board to be square. Hash is updated.
Definition at line 227 of file StoneBoard.cpp.
References ComputeHash(), Const(), m_played, m_stones, MarkAsDirty(), and BoardUtils::Mirror().
std::size_t StoneBoard::NumStones | ( | ) | const [inline] |
Number of played stones on the interior of the board.
Similar to:
num bits = (GetOccupied() & GetPlayed() & GetCells()).count();
Definition at line 417 of file StoneBoard.hpp.
References Const(), GetOccupied(), and GetPlayed().
Referenced by SolverDB< HASH, DB, DATA >::Get(), SwapCheck::PlaySwap(), and SolverDB< HASH, DB, DATA >::Put().
bool StoneBoard::operator!= | ( | const StoneBoard & | other | ) | const [inline] |
Returns true if the boards differ.
See operator==().
Definition at line 430 of file StoneBoard.hpp.
References operator==().
bool StoneBoard::operator== | ( | const StoneBoard & | other | ) | const [inline] |
Two boards are equal if their dimensions match and their sets of black, white, and played stones are all equal.
Definition at line 422 of file StoneBoard.hpp.
References BLACK, m_const, m_played, m_stones, and WHITE.
Referenced by operator!=().
Plays a move of the given color to the board.
Adds cell to the set of played stones. Updates the board hash.
color | must BLACK or WHITE | |
cell | Any valid move, include RESIGN and SWAP_PIECES. |
Definition at line 180 of file StoneBoard.cpp.
References Const(), HexAssert, HexColorUtil::isBlackWhite(), m_hash, m_played, MarkAsDirty(), benzene_bitset< _Nb >::set(), SetColor(), and ZobristHash::Update().
Referenced by ICEngine::BackupOpponentDead(), DfsSolver::OrderMoves(), HexState::PlayMove(), HexBoard::PlayMove(), Game::PlayMove(), GameUtil::SequenceFromPosition(), SetPosition(), HexSgUtil::SetPositionInBoard(), StartNewGame(), and ProofUtil::StoreTranspositions().
Sets cells in b to EMPTY.
Does not modify hash.
Definition at line 115 of file StoneBoard.cpp.
References HexAssert, HexColorUtil::isBlackWhite(), IsBlackWhiteDisjoint(), m_stones, and MarkAsDirty().
void StoneBoard::RotateBoard | ( | ) |
Rotates the board by 180' about the center.
Hash is updated.
Definition at line 209 of file StoneBoard.cpp.
References ComputeHash(), Const(), m_played, m_stones, MarkAsDirty(), and BoardUtils::Rotate().
Referenced by _BEGIN_BENZENE_NAMESPACE_::GetHash().
Sets color of cells in bitset.
Does not modify hash.
Definition at line 139 of file StoneBoard.cpp.
References Const(), HexAssert, HexColorUtil::isBlackWhite(), IsBlackWhiteDisjoint(), m_stones, and MarkAsDirty().
Sets color of cell.
Does not modify hash.
Definition at line 123 of file StoneBoard.cpp.
References Const(), EMPTY, HexAssert, IsBlackWhiteDisjoint(), HexColorUtil::isValidColor(), m_stones, MarkAsDirty(), and benzene_bitset< _Nb >::set().
Referenced by ICEngine::BackupOpponentDead(), PlayMove(), SetPosition(), SetPositionOnlyPlayed(), MoHexPlayer::TryReuseSubtree(), and UndoMove().
void StoneBoard::SetPlayed | ( | const bitset_t & | p | ) |
Sets the played stones.
These stones, and only these stones, will contribute to the board hash and board id. Hash is recomputed.
Definition at line 151 of file StoneBoard.cpp.
References ComputeHash(), m_played, and MarkAsDirty().
Referenced by SetPosition(), SetPositionOnlyPlayed(), and MoHexPlayer::TryReuseSubtree().
void StoneBoard::SetPosition | ( | const std::string & | str | ) |
Sets state from string.
String must contain wxh non space characters. Any spacing is allowed betwen such characters. A '.' is an empty cell, 'B' and 'W' are played black and white stones, 'b' and 'w' are filled-in black and white stones.
Definition at line 326 of file StoneBoard.cpp.
References BLACK, ComputeHash(), HexPointUtil::coordsToPoint(), Height(), MarkAsDirty(), PlayMove(), SetColor(), StartNewGame(), WHITE, and Width().
void StoneBoard::SetPosition | ( | const StoneBoard & | brd | ) |
Copies state of brd into this board.
Definition at line 280 of file StoneBoard.cpp.
References BLACK, GetBlack(), GetPlayed(), GetWhite(), SetColor(), SetPlayed(), StartNewGame(), and WHITE.
void StoneBoard::SetPosition | ( | const BoardID & | id | ) |
Sets the board to the state encoded by id.
Note this state will have no unplayed stones, so the code:
brd.SetPosition(brd.GetBoardID());
will remove all unplayed stones.
Definition at line 296 of file StoneBoard.cpp.
References BLACK, byte, ComputeHash(), Const(), Height(), HexAssert, MarkAsDirty(), PlayMove(), StartNewGame(), WHITE, and Width().
Referenced by BookBuilder< PLAYER >::GenerateMoves(), PlayAndSolve::GenMove(), BenzenePlayer::InitSearch(), DfpnSolver::MID(), PlayAndSolve::SolverThread::operator()(), PlayAndSolve::PlayerThread::operator()(), BookBuilder< PLAYER >::Worker::operator()(), HexBoard::PopHistory(), PerfectPlayer::Search(), and StoneBoard().
void StoneBoard::SetPositionOnlyPlayed | ( | const StoneBoard & | brd | ) |
Copies only the played state of brd.
Definition at line 288 of file StoneBoard.cpp.
References BLACK, GetBlack(), GetPlayed(), GetWhite(), SetColor(), SetPlayed(), StartNewGame(), and WHITE.
void StoneBoard::StartNewGame | ( | ) |
Clears the board and plays the edge stones.
Definition at line 167 of file StoneBoard.cpp.
References HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), ComputeHash(), m_played, m_stones, MarkAsDirty(), PlayMove(), and benzene_bitset< _Nb >::reset().
Referenced by ICEngine::BackupOpponentDead(), VCPattern::CreatePatterns(), Game::NewGame(), GameUtil::SequenceFromPosition(), SetPosition(), HexSgUtil::SetPositionInBoard(), SetPositionOnlyPlayed(), StoneBoard(), ProofUtil::StoreTranspositions(), and MoHexPlayer::TryReuseSubtree().
BoardIterator StoneBoard::Stones | ( | HexColor | color | ) | const [inline] |
Returns iterator over all stones of color.
Definition at line 450 of file StoneBoard.hpp.
References HexColorSetUtil::Only(), and Stones().
BoardIterator StoneBoard::Stones | ( | HexColorSet | colorset | ) | const |
Returns iterator over all stones in colorset.
Definition at line 83 of file StoneBoard.cpp.
References Const(), GetColor(), HexColorSetUtil::InSet(), INVALID_POINT, m_stones_calculated, m_stones_list, and NUM_COLOR_SETS.
Referenced by VCSetUtil::ConnectedTo(), VCBuilder::MergeAndShrink(), HexUctUtil::SaveTree(), and Stones().
void StoneBoard::UndoMove | ( | HexPoint | cell | ) |
Removes the move from the board, setting cell to EMPTY.
Hash is updated.
Definition at line 193 of file StoneBoard.cpp.
References Const(), EMPTY, GetColor(), HexAssert, m_hash, m_played, MarkAsDirty(), benzene_bitset< _Nb >::reset(), SetColor(), and ZobristHash::Update().
Referenced by DfsSolver::OrderMoves(), HexState::UndoMove(), and Game::UndoMove().
HexColor StoneBoard::WhoseTurn | ( | ) | const [inline] |
Computes whose turn it is on the given board; IsStandardPosition() must be true to use this method.
Definition at line 435 of file StoneBoard.hpp.
References Const(), FIRST_TO_PLAY, ConstBoard::GetCells(), GetColor(), GetPlayed(), HexAssert, and IsStandardPosition().
Referenced by BookCommands::CmdBookCounts(), BookCommands::CmdBookDumpPolarizedLeafs(), BookBuilderCommands< PLAYER >::CmdBookExpand(), BookBuilderCommands< PLAYER >::CmdBookIncreaseWidth(), BookCommands::CmdBookMainLineDepth(), BookBuilderCommands< PLAYER >::CmdBookPriorities(), BookBuilderCommands< PLAYER >::CmdBookRefresh(), BookCommands::CmdBookScores(), BookCommands::CmdBookSetValue(), BookCommands::CmdBookVisualize(), DfsCommands::CmdGetState(), and DfpnCommands::CmdSolveState().
int StoneBoard::Width | ( | ) | const [inline] |
Same as Const().width().
Definition at line 322 of file StoneBoard.hpp.
References m_const, and ConstBoard::Width().
Referenced by VCBuilder::AddPatternVCs(), HandicapPlayer::buildResponseMap(), ICEngine::CheckHandCodedDominates(), HexHtpEngine::CmdClearBoard(), BenzeneHtpEngine::CmdHandbookAdd(), ICEngine::FindHandCodedDominated(), GetBoardID(), HexHtpEngine::HexHtpEngine(), HexHtpEngine::NewGame(), SwapCheck::PlaySwap(), HexUctUtil::SaveTree(), SetPosition(), HexBoard::Width(), and Write().
std::string StoneBoard::Write | ( | const bitset_t & | b | ) | const |
Returns a string representation of the board with the cells marked in the given bitset denoted by a '*'.
Definition at line 372 of file StoneBoard.cpp.
References HexPointUtil::coordsToPoint(), Hash(), Height(), IsBlack(), IsPlayed(), IsWhite(), benzene_bitset< _Nb >::test(), HexColorUtil::toString(), and Width().
std::string StoneBoard::Write | ( | ) | const |
Returns a string representation of the board.
Definition at line 367 of file StoneBoard.cpp.
References EMPTY_BITSET.
Referenced by DfsCommands::CmdSolverFindWinning(), HexBoard::HandleVCDecomposition(), operator<<(), and HexBoard::Write().
ConstBoard* StoneBoard::m_const [private] |
Definition at line 297 of file StoneBoard.hpp.
Referenced by Const(), Height(), operator==(), and Width().
ZobristHash StoneBoard::m_hash [private] |
Definition at line 304 of file StoneBoard.hpp.
Referenced by ComputeHash(), Hash(), PlayMove(), and UndoMove().
bitset_t StoneBoard::m_played [private] |
Definition at line 299 of file StoneBoard.hpp.
Referenced by ComputeHash(), GetPlayed(), IsPlayed(), MirrorBoard(), operator==(), PlayMove(), RotateBoard(), SetPlayed(), StartNewGame(), and UndoMove().
bitset_t StoneBoard::m_stones[BLACK_AND_WHITE] [private] |
Definition at line 301 of file StoneBoard.hpp.
Referenced by AddColor(), ComputeHash(), GetBlack(), GetColor(), GetWhite(), IsBlack(), IsBlackWhiteDisjoint(), IsColor(), IsSelfRotation(), IsWhite(), MirrorBoard(), operator==(), RemoveColor(), RotateBoard(), SetColor(), and StartNewGame().
bool StoneBoard::m_stones_calculated [mutable, private] |
Definition at line 306 of file StoneBoard.hpp.
Referenced by MarkAsDirty(), and Stones().
std::vector<HexPoint> StoneBoard::m_stones_list[NUM_COLOR_SETS] [mutable, private] |
Definition at line 308 of file StoneBoard.hpp.
Referenced by Stones().