Abstract base class for all players using the Benzene systems. More...
#include <BenzenePlayer.hpp>
Public Member Functions | |
BenzenePlayer () | |
virtual | ~BenzenePlayer () |
HexPoint | GenMove (const HexState &state, const Game &game, HexBoard &brd, double maxTime, double &score) |
Generates a move from this board position. | |
bool | SearchSingleton () const |
Search states with only a single move? | |
void | SetSearchSingleton (bool flag) |
See SetSearchSingleton(). | |
virtual std::string | Name () const =0 |
Returns a unique identifier for this player. | |
Protected Member Functions | |
bool | FillinCausedWin () const |
virtual HexPoint | Search (const HexState &state, const Game &game, HexBoard &brd, const bitset_t &consider, double maxTime, double &score)=0 |
Generates a move in the given gamestate. | |
Protected Attributes | |
bool | m_fillinCausedWin |
HexColor | m_fillinWinner |
Private Member Functions | |
HexPoint | InitSearch (HexBoard &brd, HexColor color, bitset_t &consider, double &score) |
Finds inferior cells, builds vcs. | |
HexPoint | CheckEndgame (HexBoard &brd, HexColor color, bitset_t &consider, double &score) |
Private Attributes | |
bool | m_search_singleton |
Abstract base class for all players using the Benzene systems.
Definition at line 19 of file BenzenePlayer.hpp.
BenzenePlayer::BenzenePlayer | ( | ) | [explicit] |
Definition at line 14 of file BenzenePlayer.cpp.
BenzenePlayer::~BenzenePlayer | ( | ) | [virtual] |
Definition at line 20 of file BenzenePlayer.cpp.
HexPoint BenzenePlayer::CheckEndgame | ( | HexBoard & | brd, | |
HexColor | color, | |||
bitset_t & | consider, | |||
double & | score | |||
) | [private] |
Definition at line 85 of file BenzenePlayer.cpp.
References benzene_bitset< _Nb >::any(), benzene_bitset< _Nb >::count(), BitsetUtil::FindSetBit(), HexAssert, INVALID_POINT, EndgameUtils::IsDeterminedState(), LogInfo(), m_search_singleton, EndgameUtils::MovesToConsider(), and EndgameUtils::PlayDeterminedState().
Referenced by GenMove().
bool BenzenePlayer::FillinCausedWin | ( | ) | const [inline, protected] |
Definition at line 86 of file BenzenePlayer.hpp.
References m_fillinCausedWin.
Referenced by PerfectPlayer::Search().
HexPoint BenzenePlayer::GenMove | ( | const HexState & | state, | |
const Game & | game, | |||
HexBoard & | brd, | |||
double | maxTime, | |||
double & | score | |||
) | [virtual] |
Generates a move from this board position.
If the game is already over (somebody has won), returns RESIGN.
Derived Benzene players that use different search algorithms should not extend this method, but the protected virtual method Search() below.
If state is terminal (game over, vc/fill-in win/loss), returns "appropriate" move. Otherwise, calls Search().
Implements HexPlayer.
Definition at line 27 of file BenzenePlayer.cpp.
References CheckEndgame(), InitSearch(), INVALID_POINT, LogInfo(), Search(), and HexState::ToPlay().
Referenced by MoHexEngine::DoSearch(), WolveEngine::GenMove(), PlayAndSolve::PlayerThread::operator()(), and BookBuilder< PLAYER >::Worker::operator()().
HexPoint BenzenePlayer::InitSearch | ( | HexBoard & | brd, | |
HexColor | color, | |||
bitset_t & | consider, | |||
double & | score | |||
) | [private] |
Finds inferior cells, builds vcs.
Sets moves to consider to all empty cells. If fillin causes terminal state, sets m_fillinCausedWin to true and recomputes fillin/vcs with ice temporarily turned off (so it can pass the players a non-empty consider set).
Definition at line 52 of file BenzenePlayer.cpp.
References GroupBuilder::Build(), HexBoard::ComputeAll(), EMPTY, StoneBoard::GetEmpty(), HexBoard::GetGroups(), HexBoard::GetPosition(), Groups::GetWinner(), HexAssert, IMMEDIATE_LOSS, INVALID_POINT, Groups::IsGameOver(), LogInfo(), m_fillinCausedWin, m_fillinWinner, RESIGN, StoneBoard::SetPosition(), HexBoard::SetUseICE(), and HexBoard::UseICE().
Referenced by GenMove().
virtual std::string HexPlayer::Name | ( | ) | const [pure virtual, inherited] |
Returns a unique identifier for this player.
Implemented in MoHexPlayer, HandicapPlayer, PerfectPlayer, and WolvePlayer.
virtual HexPoint BenzenePlayer::Search | ( | const HexState & | state, | |
const Game & | game, | |||
HexBoard & | brd, | |||
const bitset_t & | consider, | |||
double | maxTime, | |||
double & | score | |||
) | [protected, pure virtual] |
Generates a move in the given gamestate.
Derived players must implement this method. Score can be stored in score.
state | Position and color to play. | |
game | Game history up to this point. | |
brd | Board to use for work. | |
consider | Moves to consider in this state. | |
maxTime | Max time available for move. | |
score | Score of the move to play. |
Implemented in MoHexPlayer, PerfectPlayer, and WolvePlayer.
Referenced by GenMove().
bool BenzenePlayer::SearchSingleton | ( | ) | const [inline] |
Search states with only a single move?
Definition at line 76 of file BenzenePlayer.hpp.
References m_search_singleton.
Referenced by MoHexEngine::MoHexParam(), and WolveEngine::WolveParam().
void BenzenePlayer::SetSearchSingleton | ( | bool | flag | ) | [inline] |
See SetSearchSingleton().
Definition at line 81 of file BenzenePlayer.hpp.
References m_search_singleton.
Referenced by MoHexEngine::MoHexParam(), and WolveEngine::WolveParam().
bool BenzenePlayer::m_fillinCausedWin [protected] |
Definition at line 46 of file BenzenePlayer.hpp.
Referenced by FillinCausedWin(), and InitSearch().
HexColor BenzenePlayer::m_fillinWinner [protected] |
Definition at line 48 of file BenzenePlayer.hpp.
Referenced by InitSearch(), and PerfectPlayer::Search().
bool BenzenePlayer::m_search_singleton [private] |
Definition at line 67 of file BenzenePlayer.hpp.
Referenced by CheckEndgame(), SearchSingleton(), and SetSearchSingleton().