Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

MoHexPlayer Class Reference

Player using UCT to generate moves. More...

#include <MoHexPlayer.hpp>

Inheritance diagram for MoHexPlayer:
BenzenePlayer HexPlayer

List of all members.

Public Member Functions

 MoHexPlayer ()
 Constructor.
virtual ~MoHexPlayer ()
 Destructor.
std::string Name () const
 Returns "mohex".
HexUctSearchSearch ()
 Returns the search.
const HexUctSearchSearch () const
 Returns the search.
HexUctSharedPolicySharedPolicy ()
 Returns the shared policy.
const HexUctSharedPolicySharedPolicy () const
 Returns the shared policy.
void CopySettingsFrom (const MoHexPlayer &other)
 Copy settings from other player.
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().
Parameters

bool BackupIceInfo () const
void SetBackupIceInfo (bool enable)
int MaxGames () const
 Max number of games to play.
void SetMaxGames (int games)
 See MaxGames().
double MaxTime () const
 Maximum time to spend on search (in seconds).
void SetMaxTime (double time)
 See MaxTime().
bool UseTimeManagement () const
 Use time control to determine how much time to use per move.
void SetUseTimeManagement (bool flag)
 See UseTimeManagement().
bool ReuseSubtree () const
 Search is initialized using the subttree of the last search tree rooted at the current position.
void SetReuseSubtree (bool reuse)
 See ReuseSubtree().
bool Ponder () const
 Searches while waiting for a command.
void SetPonder (bool flag)
 See Ponder().
bool PerformPreSearch () const
 Searches 1ply for easy wins before the search.
void SetPerformPreSearch (bool flag)
 See PerformPreSearch().

Protected Member Functions

HexPoint Search (const HexState &state, const Game &game, HexBoard &brd, const bitset_t &consider, double maxTime, double &score)
 Generates a move in the given gamestate using uct.
HexPoint LastMoveFromHistory (const MoveSequence &history)
 Returns INVALID_POINT if history is empty, otherwise last move played to the board, ie, skips swap move.
bool PerformPreSearch (HexBoard &brd, HexColor color, bitset_t &consider, float maxTime, PointSequence &winningSequence)
 Does a 1-ply search.
void PrintParameters (HexColor color, double remaining)
SgUctTree * TryReuseSubtree (const HexUctSharedData &oldData, HexUctSharedData &newData)
 Extracts relevant portion of old tree for use in upcoming search.
void CopyKnowledgeData (const SgUctTree &tree, const SgUctNode &node, HexColor color, MoveSequence &sequence, const HexUctSharedData &oldData, HexUctSharedData &newData) const
bool FillinCausedWin () const

Protected Attributes

HexUctSharedPolicy m_shared_policy
HexUctSearch m_search
bool m_backup_ice_info
int m_max_games
 See MaxGames().
double m_max_time
 See MaxTime().
bool m_useTimeManagement
 See UseTimeManagement().
bool m_reuse_subtree
 See ReuseSubtree().
bool m_ponder
 See Ponder().
bool m_performPreSearch
bool m_fillinCausedWin
HexColor m_fillinWinner

Detailed Description

Player using UCT to generate moves.

Definition at line 18 of file MoHexPlayer.hpp.


Constructor & Destructor Documentation

MoHexPlayer::MoHexPlayer (  ) 

Constructor.

Definition at line 59 of file MoHexPlayer.cpp.

MoHexPlayer::~MoHexPlayer (  )  [virtual]

Destructor.

Definition at line 74 of file MoHexPlayer.cpp.


Member Function Documentation

bool MoHexPlayer::BackupIceInfo (  )  const [inline]

Definition at line 165 of file MoHexPlayer.hpp.

References m_backup_ice_info.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

void MoHexPlayer::CopyKnowledgeData ( const SgUctTree &  tree,
const SgUctNode &  node,
HexColor  color,
MoveSequence sequence,
const HexUctSharedData oldData,
HexUctSharedData newData 
) const [protected]
void MoHexPlayer::CopySettingsFrom ( const MoHexPlayer other  ) 
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().

Bug:
Subtract time spent to here from max_time after each step.

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()().

HexPoint MoHexPlayer::LastMoveFromHistory ( const MoveSequence history  )  [protected]

Returns INVALID_POINT if history is empty, otherwise last move played to the board, ie, skips swap move.

Definition at line 210 of file MoHexPlayer.cpp.

References HexAssert, INVALID_POINT, and SWAP_PIECES.

Referenced by Search().

int MoHexPlayer::MaxGames (  )  const [inline]

Max number of games to play.

Definition at line 175 of file MoHexPlayer.hpp.

References m_max_games.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

double MoHexPlayer::MaxTime (  )  const [inline]

Maximum time to spend on search (in seconds).

Definition at line 185 of file MoHexPlayer.hpp.

References m_max_time.

Referenced by CopySettingsFrom(), MoHexEngine::MoHexParam(), and MoHexEngine::TimeForMove().

std::string MoHexPlayer::Name (  )  const [inline, virtual]

Returns "mohex".

Implements HexPlayer.

Definition at line 140 of file MoHexPlayer.hpp.

bool MoHexPlayer::PerformPreSearch ( HexBoard brd,
HexColor  color,
bitset_t consider,
float  maxTime,
PointSequence winningSequence 
) [protected]

Does a 1-ply search.

For each move in the consider set, if the move is a win, returns true and the move. If the move is a loss, prune it out of the consider set if there are non-losing moves in the consider set. If all moves are losing, perform no pruning, search will resist.

Returns true if there is a win, false otherwise.

Todo:
Is it true that MoHex will resist in the strongest way possible?

Definition at line 237 of file MoHexPlayer.cpp.

References benzene_bitset< _Nb >::any(), benzene_bitset< _Nb >::count(), Resistance::Evaluate(), HexAssert, EndgameUtils::IsDeterminedState(), EndgameUtils::IsLostGame(), BitsetUtil::IsSubsetOf(), EndgameUtils::IsWonGame(), LogFine(), LogInfo(), m_backup_ice_info, EndgameUtils::MovesToConsider(), HexBoard::PlayMove(), benzene_bitset< _Nb >::set(), HexBoard::UndoMove(), and HexBoard::Write().

bool MoHexPlayer::PerformPreSearch (  )  const [inline]

Searches 1ply for easy wins before the search.

Definition at line 225 of file MoHexPlayer.hpp.

References m_performPreSearch.

Referenced by CopySettingsFrom(), MoHexEngine::MoHexParam(), and Search().

bool MoHexPlayer::Ponder (  )  const [inline]

Searches while waiting for a command.

Definition at line 215 of file MoHexPlayer.hpp.

References m_ponder.

Referenced by MoHexEngine::MoHexParam().

void MoHexPlayer::PrintParameters ( HexColor  color,
double  remaining 
) [protected]

Definition at line 314 of file MoHexPlayer.cpp.

References LogInfo(), m_max_games, and m_search.

Referenced by Search().

bool MoHexPlayer::ReuseSubtree (  )  const [inline]

Search is initialized using the subttree of the last search tree rooted at the current position.

Definition at line 205 of file MoHexPlayer.hpp.

References m_reuse_subtree.

Referenced by MoHexEngine::MoHexParam().

HexPoint MoHexPlayer::Search ( const HexState state,
const Game game,
HexBoard brd,
const bitset_t consider,
double  maxTime,
double &  score 
) [protected, virtual]
const HexUctSearch & MoHexPlayer::Search (  )  const [inline]

Returns the search.

Definition at line 150 of file MoHexPlayer.hpp.

References m_search.

HexUctSearch & MoHexPlayer::Search (  )  [inline]
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 MoHexPlayer::SetBackupIceInfo ( bool  enable  )  [inline]

Definition at line 170 of file MoHexPlayer.hpp.

References m_backup_ice_info.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

void MoHexPlayer::SetMaxGames ( int  games  )  [inline]

See MaxGames().

Definition at line 180 of file MoHexPlayer.hpp.

References m_max_games.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

void MoHexPlayer::SetMaxTime ( double  time  )  [inline]

See MaxTime().

Definition at line 190 of file MoHexPlayer.hpp.

References m_max_time.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

void MoHexPlayer::SetPerformPreSearch ( bool  flag  )  [inline]

See PerformPreSearch().

Definition at line 230 of file MoHexPlayer.hpp.

References m_performPreSearch.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

void MoHexPlayer::SetPonder ( bool  flag  )  [inline]

See Ponder().

Definition at line 220 of file MoHexPlayer.hpp.

References m_ponder.

Referenced by MoHexEngine::MoHexParam().

void MoHexPlayer::SetReuseSubtree ( bool  reuse  )  [inline]

See ReuseSubtree().

Definition at line 210 of file MoHexPlayer.hpp.

References m_reuse_subtree.

Referenced by MoHexEngine::MoHexParam().

void BenzenePlayer::SetSearchSingleton ( bool  flag  )  [inline, inherited]
void MoHexPlayer::SetUseTimeManagement ( bool  flag  )  [inline]

See UseTimeManagement().

Definition at line 200 of file MoHexPlayer.hpp.

References m_useTimeManagement.

Referenced by CopySettingsFrom(), and MoHexEngine::MoHexParam().

const HexUctSharedPolicy & MoHexPlayer::SharedPolicy (  )  const [inline]

Returns the shared policy.

Definition at line 160 of file MoHexPlayer.hpp.

References m_shared_policy.

HexUctSharedPolicy & MoHexPlayer::SharedPolicy (  )  [inline]

Returns the shared policy.

Definition at line 155 of file MoHexPlayer.hpp.

References m_shared_policy.

Referenced by MoHexEngine::MoHexPolicyParam().

SgUctTree * MoHexPlayer::TryReuseSubtree ( const HexUctSharedData oldData,
HexUctSharedData newData 
) [protected]
bool MoHexPlayer::UseTimeManagement (  )  const [inline]

Use time control to determine how much time to use per move.

Definition at line 195 of file MoHexPlayer.hpp.

References m_useTimeManagement.

Referenced by CopySettingsFrom(), MoHexEngine::MoHexParam(), and MoHexEngine::TimeForMove().


Member Data Documentation

Definition at line 100 of file MoHexPlayer.hpp.

Referenced by BackupIceInfo(), PerformPreSearch(), and SetBackupIceInfo().

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().

int MoHexPlayer::m_max_games [protected]

See MaxGames().

Definition at line 103 of file MoHexPlayer.hpp.

Referenced by MaxGames(), PrintParameters(), Search(), and SetMaxGames().

double MoHexPlayer::m_max_time [protected]

See MaxTime().

Definition at line 106 of file MoHexPlayer.hpp.

Referenced by MaxTime(), and SetMaxTime().

Definition at line 117 of file MoHexPlayer.hpp.

Referenced by PerformPreSearch(), Search(), and SetPerformPreSearch().

bool MoHexPlayer::m_ponder [protected]

See Ponder().

Definition at line 115 of file MoHexPlayer.hpp.

Referenced by Ponder(), and SetPonder().

bool MoHexPlayer::m_reuse_subtree [protected]

See ReuseSubtree().

Definition at line 112 of file MoHexPlayer.hpp.

Referenced by ReuseSubtree(), Search(), and SetReuseSubtree().

Definition at line 98 of file MoHexPlayer.hpp.

Referenced by PrintParameters(), Search(), and TryReuseSubtree().

Definition at line 96 of file MoHexPlayer.hpp.

Referenced by Search(), and SharedPolicy().

See UseTimeManagement().

Definition at line 109 of file MoHexPlayer.hpp.

Referenced by SetUseTimeManagement(), and UseTimeManagement().


The documentation for this class was generated from the following files:


6 Jan 2011 Doxygen 1.6.3