Utilities on endgames: detecting, playing, etc. More...
Functions | |
bool | IsWonGame (const HexBoard &brd, HexColor color, bitset_t &proof) |
Returns true if color wins in this state. | |
bool | IsWonGame (const HexBoard &brd, HexColor color) |
bool | IsLostGame (const HexBoard &brd, HexColor color, bitset_t &proof) |
Returns true if color loses in this state. | |
bool | IsLostGame (const HexBoard &brd, HexColor color) |
bool | IsDeterminedState (const HexBoard &brd, HexColor color, HexEval &score, bitset_t &proof) |
Returns true if this is a winning/losing state for color (as defined by IsWonGame() and IsLostGame()), score is set to IMMEDIATE_WIN on win, IMMEDIATE_LOSS on a loss, or 0 otherwise. | |
bool | IsDeterminedState (const HexBoard &brd, HexColor color, HexEval &score) |
bool | IsDeterminedState (const HexBoard &brd, HexColor color) |
HexPoint | PlayDeterminedState (const HexBoard &brd, HexColor color) |
Plays the "best" move in a determined state. | |
bitset_t | MovesToConsider (const HexBoard &brd, HexColor color) |
Returns the set of moves that need to be considered from the given boardstate; that is, without the moves that we can provably ignore. |
Utilities on endgames: detecting, playing, etc.
Definition at line 77 of file EndgameUtils.hpp.
References HexEval, and IsDeterminedState().
bool EndgameUtils::IsDeterminedState | ( | const HexBoard & | brd, | |
HexColor | color, | |||
HexEval & | score | |||
) | [inline] |
Definition at line 69 of file EndgameUtils.hpp.
References IsDeterminedState().
bool EndgameUtils::IsDeterminedState | ( | const HexBoard & | brd, | |
HexColor | color, | |||
HexEval & | score, | |||
bitset_t & | proof | |||
) |
Returns true if this is a winning/losing state for color (as defined by IsWonGame() and IsLostGame()), score is set to IMMEDIATE_WIN on win, IMMEDIATE_LOSS on a loss, or 0 otherwise.
Definition at line 287 of file EndgameUtils.cpp.
References IMMEDIATE_LOSS, IMMEDIATE_WIN, IsLostGame(), and IsWonGame().
Referenced by BenzenePlayer::CheckEndgame(), VCCommands::CmdBuildIncremental(), VCCommands::CmdBuildStatic(), DfpnCommands::CmdFindWinning(), VCCommands::CmdGetMustPlay(), DfsCommands::CmdSolverFindWinning(), HexUctState::ComputeKnowledge(), BookBuilder< PLAYER >::GenerateMoves(), IsDeterminedState(), DfpnSolver::MID(), MovesToConsider(), MoHexPlayer::PerformPreSearch(), and PlayDeterminedState().
Definition at line 84 of file EndgameUtils.hpp.
References IsLostGame().
Returns true if color loses in this state.
This checks for solid chains and for winning scs/vcs.
Definition at line 263 of file EndgameUtils.cpp.
References VC::carrier(), HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), HexBoard::Cons(), VC::FULL, StoneBoard::GetEmpty(), HexBoard::GetGroups(), HexBoard::GetPosition(), Groups::GetWinner(), and VCSet::SmallestVC().
Referenced by HexAbSearch::CheckTerminalState(), HexUctState::ComputeKnowledge(), DfsSolver::HandleTerminalNode(), IsDeterminedState(), IsLostGame(), MoHexPlayer::PerformPreSearch(), and PlayDeterminedState().
Definition at line 90 of file EndgameUtils.hpp.
References IsWonGame().
Returns true if color wins in this state.
This checks for solid chains and for winning scs/vcs.
Definition at line 239 of file EndgameUtils.cpp.
References VC::carrier(), HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), HexBoard::Cons(), VC::FULL, HexBoard::GetGroups(), Groups::GetWinner(), VC::SEMI, and VCSet::SmallestVC().
Referenced by HexAbSearch::CheckTerminalState(), DfsSolver::HandleTerminalNode(), IsDeterminedState(), IsWonGame(), DfpnSolver::MID(), MoHexPlayer::PerformPreSearch(), and PlayDeterminedState().
Returns the set of moves that need to be considered from the given boardstate; that is, without the moves that we can provably ignore.
Returned set of moves to consider is guaranteed to be non-empty. This assumes IsDeterminedState() returns false.
Definition at line 318 of file EndgameUtils.cpp.
References benzene_bitset< _Nb >::any(), HexAssert, HexColorUtil::isBlackWhite(), IsDeterminedState(), LogFine(), and HexBoard::Write().
Referenced by WolveSearch::AfterStateSearched(), BenzenePlayer::CheckEndgame(), VCCommands::CmdBuildIncremental(), VCCommands::CmdBuildStatic(), DfpnCommands::CmdFindWinning(), VCCommands::CmdGetMustPlay(), DfsCommands::CmdSolverFindWinning(), HexUctState::ComputeKnowledge(), WolveSearch::GenerateMoves(), BookBuilder< PLAYER >::GenerateMoves(), DfpnSolver::MID(), DfsSolver::OrderMoves(), MoHexPlayer::PerformPreSearch(), and DfsSolver::SolveInteriorState().
Plays the "best" move in a determined state.
Assumes IsDetermined() returns true, but requires that brd.isGameOver() is false. That is, is, it cannot play a move if a solid chain exists on this board.
Definition at line 304 of file EndgameUtils.cpp.
References HexBoard::GetGroups(), HexAssert, HexColorUtil::isBlackWhite(), IsDeterminedState(), Groups::IsGameOver(), IsLostGame(), and IsWonGame().
Referenced by BenzenePlayer::CheckEndgame().