Player using Handicap to generate moves. More...
#include <HandicapPlayer.hpp>
Public Member Functions | |
HandicapPlayer (ICEngine *ice) | |
virtual | ~HandicapPlayer () |
std::string | Name () const |
returns "handicap". | |
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(). | |
Protected Member Functions | |
virtual HexPoint | Search (HexBoard &brd, const Game &game_state, HexColor color, const bitset_t &consider, double max_time, double &score) |
Generates a move in the given gamestate using handicap strategy. | |
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 | |
void | buildResponseMap (const StoneBoard &brd) |
Build the mapping of what the mirror of each HexPoint is. | |
void | makeMiai (HexPoint p1, HexPoint p2) |
Takes two HexPoints and maps them to each other. | |
void | threeToOne (const StoneBoard &brd, HexPoint dest, HexPoint p1, HexPoint p2, HexPoint p3) |
Takes four HexPoints and maps p1, p2, and p3 to dest unless p1, p2, and/or p3 are already occupied, in which case there are a number of special cases. | |
Private Attributes | |
ICEngine * | m_ice |
bool | m_assume_added_stones |
PointToPoint | m_responseMap |
int | m_width |
Player using Handicap to generate moves.
Definition at line 21 of file HandicapPlayer.hpp.
HandicapPlayer::HandicapPlayer | ( | ICEngine * | ice | ) | [explicit] |
Definition at line 14 of file HandicapPlayer.cpp.
References LogFine().
HandicapPlayer::~HandicapPlayer | ( | ) | [virtual] |
Definition at line 22 of file HandicapPlayer.cpp.
void HandicapPlayer::buildResponseMap | ( | const StoneBoard & | brd | ) | [private] |
Build the mapping of what the mirror of each HexPoint is.
Definition at line 75 of file HandicapPlayer.cpp.
References StoneBoard::Const(), HexPointUtil::coordsToPoint(), StoneBoard::Height(), ConstBoard::Interior(), INVALID_POINT, StoneBoard::IsPlayed(), m_assume_added_stones, m_responseMap, m_width, makeMiai(), HexPointUtil::pointToCoords(), threeToOne(), and StoneBoard::Width().
Referenced by Search().
bool BenzenePlayer::FillinCausedWin | ( | ) | const [inline, protected, inherited] |
Definition at line 86 of file BenzenePlayer.hpp.
References BenzenePlayer::m_fillinCausedWin.
Referenced by PerfectPlayer::Search().
HexPoint BenzenePlayer::GenMove | ( | const HexState & | state, | |
const Game & | game, | |||
HexBoard & | brd, | |||
double | maxTime, | |||
double & | score | |||
) | [virtual, inherited] |
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 BenzenePlayer::CheckEndgame(), BenzenePlayer::InitSearch(), INVALID_POINT, LogInfo(), BenzenePlayer::Search(), and HexState::ToPlay().
Referenced by MoHexEngine::DoSearch(), WolveEngine::GenMove(), PlayAndSolve::PlayerThread::operator()(), and BookBuilder< PLAYER >::Worker::operator()().
Takes two HexPoints and maps them to each other.
Definition at line 146 of file HandicapPlayer.cpp.
References m_responseMap.
Referenced by buildResponseMap(), and threeToOne().
std::string HandicapPlayer::Name | ( | ) | const [inline, virtual] |
virtual HexPoint BenzenePlayer::Search | ( | const HexState & | state, | |
const Game & | game, | |||
HexBoard & | brd, | |||
const bitset_t & | consider, | |||
double | maxTime, | |||
double & | score | |||
) | [protected, pure virtual, inherited] |
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 BenzenePlayer::GenMove().
HexPoint HandicapPlayer::Search | ( | HexBoard & | brd, | |
const Game & | game_state, | |||
HexColor | color, | |||
const bitset_t & | consider, | |||
double | max_time, | |||
double & | score | |||
) | [protected, virtual] |
Generates a move in the given gamestate using handicap strategy.
The handicap player must always be WHITE.
Handicap player wins playing second, so in this case any random move will suffice.
For future implementation: discard the naive responseMap and just do it here. Only build the responseMap for the places on the very edge of the board. Possibly edge and second row from edge... Depends on whether the theory player will handle all the edge cases.
Definition at line 28 of file HandicapPlayer.cpp.
References buildResponseMap(), FIRST_TO_PLAY, HexBoard::GetPosition(), HexBoard::Height(), HexAssert, Game::History(), INVALID_POINT, StoneBoard::IsPlayed(), LogInfo(), m_assume_added_stones, m_responseMap, m_width, BoardUtils::RandomEmptyCell(), RESIGN, UNUSED(), VERTICAL_COLOR, and HexBoard::Width().
bool BenzenePlayer::SearchSingleton | ( | ) | const [inline, inherited] |
Search states with only a single move?
Definition at line 76 of file BenzenePlayer.hpp.
References BenzenePlayer::m_search_singleton.
Referenced by MoHexEngine::MoHexParam(), and WolveEngine::WolveParam().
void BenzenePlayer::SetSearchSingleton | ( | bool | flag | ) | [inline, inherited] |
See SetSearchSingleton().
Definition at line 81 of file BenzenePlayer.hpp.
References BenzenePlayer::m_search_singleton.
Referenced by MoHexEngine::MoHexParam(), and WolveEngine::WolveParam().
void HandicapPlayer::threeToOne | ( | const StoneBoard & | brd, | |
HexPoint | dest, | |||
HexPoint | p1, | |||
HexPoint | p2, | |||
HexPoint | p3 | |||
) | [private] |
Takes four HexPoints and maps p1, p2, and p3 to dest unless p1, p2, and/or p3 are already occupied, in which case there are a number of special cases.
Definition at line 152 of file HandicapPlayer.cpp.
References StoneBoard::IsBlack(), StoneBoard::IsPlayed(), StoneBoard::IsWhite(), m_responseMap, makeMiai(), and MAX_WIDTH.
Referenced by buildResponseMap().
bool HandicapPlayer::m_assume_added_stones [private] |
Definition at line 45 of file HandicapPlayer.hpp.
Referenced by buildResponseMap(), and Search().
bool BenzenePlayer::m_fillinCausedWin [protected, inherited] |
Definition at line 46 of file BenzenePlayer.hpp.
Referenced by BenzenePlayer::FillinCausedWin(), and BenzenePlayer::InitSearch().
HexColor BenzenePlayer::m_fillinWinner [protected, inherited] |
Definition at line 48 of file BenzenePlayer.hpp.
Referenced by BenzenePlayer::InitSearch(), and PerfectPlayer::Search().
ICEngine* HandicapPlayer::m_ice [private] |
Definition at line 43 of file HandicapPlayer.hpp.
PointToPoint HandicapPlayer::m_responseMap [private] |
Definition at line 47 of file HandicapPlayer.hpp.
Referenced by buildResponseMap(), makeMiai(), Search(), and threeToOne().
int HandicapPlayer::m_width [private] |
Definition at line 49 of file HandicapPlayer.hpp.
Referenced by buildResponseMap(), and Search().