Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexAbSearch Class Reference

Base Alpha-Beta search class. More...

#include <HexAbSearch.hpp>

Inheritance diagram for HexAbSearch:
WolveSearch

List of all members.

Classes

struct  Statistics
 Search statistics. More...

Public Member Functions

 HexAbSearch ()
 Constructor.
virtual ~HexAbSearch ()
 Destructor.
void SetTT (SearchTT *tt)
 Sets the transposition table to be used during search.
bool GuiFx () const
 Writes progress of search in guifx format after each root move completes.
void SetGuiFx (bool flag)
 Sets whether guifx output should be dumped.
HexEval Search (HexBoard &brd, HexColor color, const std::vector< int > &plywidth, const std::vector< int > &depths_to_search, int timelimit, std::vector< HexPoint > &PV)
 Runs the AlphaBeta search.
virtual HexEval Evaluate ()=0
 Evaluates leaf position.
virtual void GenerateMoves (std::vector< HexPoint > &moves)=0
 Generates moves for this position.
virtual void ExecuteMove (HexPoint move)=0
 Plays the given move.
virtual void UndoMove (HexPoint move)=0
 Undoes the given move.
virtual void EnteredNewState ()
 Hook function called upon entering new position.
virtual void OnStartSearch ()
 Hook function called at the very start of the search.
virtual void OnSearchComplete ()
 Hook function called after the search has completed.
virtual void AfterStateSearched ()
 Hook function called after a states moves have been searched.
std::string DumpStats ()
 Output stats from search.

Protected Attributes

HexBoardm_brd
 The board we are playing on.
HexColor m_toplay
 Color of player to move next.
SearchTTm_tt
 Transposition table to use during search, if any.
bool m_use_guifx
int m_current_depth
 Number of moves from the root.
PointSequence m_sequence
 Sequences of moves to the current state.
HexPoint m_tt_bestmove
 If current state exists in TT, but TT state was not deep enough, this will hold the best move for that state; otherwise it will be INVALID_MOVE.
bool m_tt_info_available

Private Member Functions

void ClearStats ()
void UpdatePV (int current_depth, HexEval value, std::vector< HexPoint > &cv)
HexEval CheckTerminalState ()
bool CheckAbort ()
 Checks SgUserAbort() and sets m_aborted if true.
HexEval SearchState (const std::vector< int > &plywidth, int depth, HexEval alpha, HexEval beta, std::vector< HexPoint > &cv)

Private Attributes

Statistics m_statistics
std::vector< HexMoveValuem_eval
 Evaluations for each move from the root state.
bool m_aborted
 True if the search was aborted due to timelimit or user intervention.

Detailed Description

Base Alpha-Beta search class.

Definition at line 25 of file HexAbSearch.hpp.


Constructor & Destructor Documentation

HexAbSearch::HexAbSearch (  )  [explicit]

Constructor.

Definition at line 74 of file HexAbSearch.cpp.

HexAbSearch::~HexAbSearch (  )  [virtual]

Destructor.

Definition at line 81 of file HexAbSearch.cpp.


Member Function Documentation

void HexAbSearch::AfterStateSearched (  )  [virtual]

Hook function called after a states moves have been searched.

Default implementation does nothing.

Reimplemented in WolveSearch.

Definition at line 93 of file HexAbSearch.cpp.

Referenced by SearchState().

bool HexAbSearch::CheckAbort (  )  [private]

Checks SgUserAbort() and sets m_aborted if true.

Definition at line 181 of file HexAbSearch.cpp.

References LogInfo(), and m_aborted.

Referenced by SearchState().

HexEval HexAbSearch::CheckTerminalState (  )  [private]
void HexAbSearch::ClearStats (  )  [private]
std::string HexAbSearch::DumpStats (  ) 

Output stats from search.

Definition at line 379 of file HexAbSearch.cpp.

References HexAbSearch::Statistics::Dump(), m_eval, and m_statistics.

Referenced by WolvePlayer::Search().

void HexAbSearch::EnteredNewState (  )  [virtual]

Hook function called upon entering new position.

Default implementation does nothing.

Reimplemented in WolveSearch.

Definition at line 87 of file HexAbSearch.cpp.

Referenced by SearchState().

virtual HexEval HexAbSearch::Evaluate (  )  [pure virtual]

Evaluates leaf position.

Implemented in WolveSearch.

Referenced by SearchState().

virtual void HexAbSearch::ExecuteMove ( HexPoint  move  )  [pure virtual]

Plays the given move.

Implemented in WolveSearch.

Referenced by SearchState().

virtual void HexAbSearch::GenerateMoves ( std::vector< HexPoint > &  moves  )  [pure virtual]

Generates moves for this position.

Moves will be played in the returned order.

Implemented in WolveSearch.

Referenced by SearchState().

bool HexAbSearch::GuiFx (  )  const [inline]

Writes progress of search in guifx format after each root move completes.

Off by default.

Definition at line 200 of file HexAbSearch.hpp.

References m_use_guifx.

Referenced by WolveEngine::WolveParam().

void HexAbSearch::OnSearchComplete (  )  [virtual]

Hook function called after the search has completed.

Default implementation does nothing.

Reimplemented in WolveSearch.

Definition at line 91 of file HexAbSearch.cpp.

Referenced by Search().

void HexAbSearch::OnStartSearch (  )  [virtual]

Hook function called at the very start of the search.

Default implementation does nothing.

Reimplemented in WolveSearch.

Definition at line 89 of file HexAbSearch.cpp.

Referenced by Search().

HexEval HexAbSearch::Search ( HexBoard brd,
HexColor  color,
const std::vector< int > &  plywidth,
const std::vector< int > &  depths_to_search,
int  timelimit,
std::vector< HexPoint > &  PV 
)

Runs the AlphaBeta search.

Parameters:
brd board to play one.
color color to play.
plywidth depth of the search set to plywidth.size() and plywidth[j] top moves are explored.
depths_to_search successive depths to search (like in ID).
timelimit amount of time in which to finish search.
PV the principal variation will be stored here.
Returns:
the evaluation of the PV.

If search is aborted by the user or the timelimit is reached, then the last valid result from interative deepening is returned. If the first iteration has not completed, then a score of -EVAL_INFINITY and a PV containing only INVALID_POINT are returned.

Definition at line 95 of file HexAbSearch.cpp.

References HexAbSearch::Statistics::elapsed_time, EVAL_INFINITY, Get(), IMMEDIATE_LOSS, IMMEDIATE_WIN, INVALID_POINT, LogInfo(), m_aborted, m_brd, m_current_depth, m_eval, m_sequence, m_statistics, m_toplay, OnSearchComplete(), OnStartSearch(), HexAbSearch::Statistics::pv, SearchState(), UNUSED(), and HexAbSearch::Statistics::value.

Referenced by WolvePlayer::Search().

HexEval HexAbSearch::SearchState ( const std::vector< int > &  plywidth,
int  depth,
HexEval  alpha,
HexEval  beta,
std::vector< HexPoint > &  cv 
) [private]
void HexAbSearch::SetGuiFx ( bool  flag  )  [inline]

Sets whether guifx output should be dumped.

See also:
GuiFX().

Definition at line 195 of file HexAbSearch.hpp.

References m_use_guifx.

Referenced by WolveEngine::WolveParam().

void HexAbSearch::SetTT ( SearchTT tt  )  [inline]

Sets the transposition table to be used during search.

Definition at line 190 of file HexAbSearch.hpp.

References m_tt.

Referenced by WolvePlayer::WolvePlayer().

virtual void HexAbSearch::UndoMove ( HexPoint  move  )  [pure virtual]

Undoes the given move.

Implemented in WolveSearch.

Referenced by SearchState().

void HexAbSearch::UpdatePV ( int  current_depth,
HexEval  value,
std::vector< HexPoint > &  cv 
) [private]

Member Data Documentation

bool HexAbSearch::m_aborted [private]

True if the search was aborted due to timelimit or user intervention.

Definition at line 187 of file HexAbSearch.hpp.

Referenced by CheckAbort(), Search(), and SearchState().

Number of moves from the root.

Definition at line 124 of file HexAbSearch.hpp.

Referenced by WolveSearch::AfterStateSearched(), CheckTerminalState(), WolveSearch::GenerateMoves(), Search(), and SearchState().

std::vector<HexMoveValue> HexAbSearch::m_eval [private]

Evaluations for each move from the root state.

Definition at line 183 of file HexAbSearch.hpp.

Referenced by DumpStats(), Search(), and SearchState().

Sequences of moves to the current state.

Definition at line 127 of file HexAbSearch.hpp.

Referenced by WolveSearch::AfterStateSearched(), WolveSearch::GenerateMoves(), Search(), and SearchState().

Definition at line 180 of file HexAbSearch.hpp.

Referenced by DumpStats(), Search(), and SearchState().

Transposition table to use during search, if any.

Definition at line 118 of file HexAbSearch.hpp.

Referenced by SearchState(), and SetTT().

If current state exists in TT, but TT state was not deep enough, this will hold the best move for that state; otherwise it will be INVALID_MOVE.

Could be used in GenerateMoves() to improve move ordering when using iterative deepening.

Definition at line 133 of file HexAbSearch.hpp.

Referenced by WolveSearch::GenerateMoves(), and SearchState().

Definition at line 134 of file HexAbSearch.hpp.

Referenced by SearchState().

bool HexAbSearch::m_use_guifx [protected]
See also:
GuiFx().

Definition at line 121 of file HexAbSearch.hpp.

Referenced by GuiFx(), SearchState(), and SetGuiFx().


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


6 Jan 2011 Doxygen 1.6.3