Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

DfpnSolver Class Reference
[Depth-First Proof Number Search]

Hex solver using DFPN search. More...

#include <DfpnSolver.hpp>

List of all members.

Classes

class  GuiFx
 Handles guifx output. More...

Public Member Functions

 DfpnSolver ()
 ~DfpnSolver ()
HexColor StartSearch (const HexState &state, HexBoard &brd, DfpnStates &positions, PointSequence &pv)
 Solves the given state using the given hashtable.
HexColor StartSearch (const HexState &state, HexBoard &brd, DfpnStates &positions, PointSequence &pv, const DfpnBounds &maxBounds)
void AddListener (DfpnListener &listener)
std::string EvaluationInfo () const
 Returns various histograms pertaining to the evaluation function from the last search.
void PropagateBackwards (const Game &game, DfpnStates &pos)
 Updates bounds from this state to start of game or a state is not in position set.
Parameters

bool UseGuiFx () const
 Dumps output about root state what gui can display.
void SetUseGuiFx (bool enable)
 See UseGuiFx().
double Timelimit () const
 Maximum time search is allowed to run before aborting.
void SetTimelimit (double timelimit)
 See Timelimit().
int WideningBase () const
 Widening base affects what number of the moves to consider are always looked at by the dfpn search (omitting losing moves), regardless of branching factor.
void SetWideningBase (int wideningBase)
 See WideningBase().
float WideningFactor () const
 Widening factor affects what fraction of the moves to consider are looked at by the dfpn search (omitting losing moves).
void SetWideningFactor (float wideningFactor)
 See WideningFactor().

Private Member Functions

size_t MID (const DfpnBounds &n, DfpnHistory &history)
void SelectChild (int &bestMove, DfpnBoundType &delta2, const std::vector< DfpnData > &childrenDfpnBounds, size_t maxChildIndex) const
void UpdateBounds (DfpnBounds &bounds, const std::vector< DfpnData > &childBounds, size_t maxChildIndex) const
bool CheckAbort ()
void LookupData (DfpnData &data, const DfpnChildren &children, int childIndex, HexState &state)
bool TTRead (const HexState &state, DfpnData &data)
void TTWrite (const HexState &state, const DfpnData &data)
void DumpGuiFx (const std::vector< HexPoint > &children, const std::vector< DfpnBounds > &childBounds) const
void PrintStatistics (HexColor winner, const PointSequence &p) const
size_t ComputeMaxChildIndex (const std::vector< DfpnData > &childrenData) const
void DeleteChildren (DfpnChildren &children, std::vector< DfpnData > &childrenData, bitset_t deleteChildren) const
void NotifyListeners (const DfpnHistory &history, const DfpnData &data)

Private Attributes

boost::scoped_ptr< HexStatem_state
HexBoardm_workBoard
DfpnStatesm_positions
std::vector< DfpnListener * > m_listener
SgTimer m_timer
bool m_useGuiFx
 See UseGuiFx().
double m_timelimit
 See TimeLimit().
int m_wideningBase
 See WideningBase().
float m_wideningFactor
 See WideningFactor().
size_t m_checkTimerAbortCalls
 Number of calls to CheckAbort() before we check the timer.
bool m_aborted
GuiFx m_guiFx
size_t m_numTerminal
size_t m_numMIDcalls
size_t m_numVCbuilds
SgStatisticsExt< float,
std::size_t > 
m_prunedSiblingStats
SgStatisticsExt< float,
std::size_t > 
m_moveOrderingPercent
SgStatisticsExt< float,
std::size_t > 
m_moveOrderingIndex
SgStatisticsExt< float,
std::size_t > 
m_considerSetSize
SgStatisticsExt< float,
std::size_t > 
m_deltaIncrease
size_t m_totalWastedWork
SgHistogram< float, std::size_t > m_allEvaluation
SgHistogram< float, std::size_t > m_allSolvedEvaluation
SgHistogram< float, std::size_t > m_winningEvaluation
SgHistogram< float, std::size_t > m_losingEvaluation

Detailed Description

Hex solver using DFPN search.

Definition at line 420 of file DfpnSolver.hpp.


Constructor & Destructor Documentation

DfpnSolver::DfpnSolver (  ) 

Definition at line 246 of file DfpnSolver.cpp.

DfpnSolver::~DfpnSolver (  ) 

Definition at line 260 of file DfpnSolver.cpp.


Member Function Documentation

void DfpnSolver::AddListener ( DfpnListener listener  )  [inline]

Definition at line 618 of file DfpnSolver.hpp.

References m_listener.

bool DfpnSolver::CheckAbort (  )  [private]

Definition at line 379 of file DfpnSolver.cpp.

References LogInfo(), m_aborted, m_checkTimerAbortCalls, m_numMIDcalls, m_timelimit, and m_timer.

Referenced by MID().

size_t DfpnSolver::ComputeMaxChildIndex ( const std::vector< DfpnData > &  childrenData  )  const [private]

Definition at line 652 of file DfpnSolver.cpp.

References HexAssert, WideningBase(), and WideningFactor().

Referenced by MID(), and PropagateBackwards().

void DfpnSolver::DeleteChildren ( DfpnChildren children,
std::vector< DfpnData > &  childrenData,
bitset_t  deleteChildren 
) const [private]

Definition at line 681 of file DfpnSolver.cpp.

References HexAssert, DfpnChildren::m_children, DfpnChildren::Size(), and benzene_bitset< _Nb >::test().

Referenced by MID().

void DfpnSolver::DumpGuiFx ( const std::vector< HexPoint > &  children,
const std::vector< DfpnBounds > &  childBounds 
) const [private]
std::string DfpnSolver::EvaluationInfo (  )  const

Returns various histograms pertaining to the evaluation function from the last search.

Definition at line 304 of file DfpnSolver.cpp.

References m_allEvaluation, m_allSolvedEvaluation, m_losingEvaluation, and m_winningEvaluation.

Referenced by DfpnCommands::CmdEvaluationInfo().

void DfpnSolver::LookupData ( DfpnData data,
const DfpnChildren children,
int  childIndex,
HexState state 
) [private]
size_t DfpnSolver::MID ( const DfpnBounds n,
DfpnHistory history 
) [private]

Definition at line 418 of file DfpnSolver.cpp.

References BLACK, CheckAbort(), DfpnBounds::CheckConsistency(), HexBoard::ComputeAll(), ComputeMaxChildIndex(), benzene_bitset< _Nb >::count(), DeleteChildren(), DfpnBounds::delta, DfpnHistory::Depth(), Resistance::Evaluate(), DfpnChildren::FirstMove(), HexBoard::GetPosition(), DfpnBounds::GreaterThan(), hash_t, HexAssert, HexEval, DfpnBounds::INFTY, INVALID_POINT, EndgameUtils::IsDeterminedState(), DfpnBounds::IsLosing(), DfpnBounds::IsSolved(), EndgameUtils::IsWonGame(), LookupData(), m_allEvaluation, m_allSolvedEvaluation, DfpnData::m_bounds, DfpnChildren::m_children, DfpnData::m_children, m_considerSetSize, m_deltaIncrease, DfpnData::m_evaluationScore, m_guiFx, m_losingEvaluation, DfpnData::m_maxProofSet, m_moveOrderingIndex, m_moveOrderingPercent, m_numMIDcalls, m_numTerminal, m_numVCbuilds, m_prunedSiblingStats, m_state, m_totalWastedWork, m_useGuiFx, m_winningEvaluation, DfpnData::m_work, m_workBoard, ProofUtil::MaximumProofSet(), EndgameUtils::MovesToConsider(), NotifyListeners(), DfpnBounds::phi, DfpnChildren::PlayMove(), DfpnSolver::GuiFx::PlayMove(), DfpnHistory::Pop(), DfpnHistory::Push(), benzene_bitset< _Nb >::reset(), Resistance::Score(), SelectChild(), benzene_bitset< _Nb >::set(), DfpnSolver::GuiFx::SetChildren(), DfpnChildren::SetChildren(), StoneBoard::SetPosition(), DfpnBounds::SetToLosing(), DfpnBounds::SetToWinning(), DfpnChildren::Size(), TTRead(), TTWrite(), DfpnSolver::GuiFx::UndoMove(), DfpnChildren::UndoMove(), UpdateBounds(), DfpnSolver::GuiFx::UpdateCurrentBounds(), DfpnSolver::GuiFx::Write(), and DfpnSolver::GuiFx::WriteForced().

Referenced by StartSearch().

void DfpnSolver::NotifyListeners ( const DfpnHistory history,
const DfpnData data 
) [private]

Definition at line 710 of file DfpnSolver.cpp.

References m_listener.

Referenced by MID().

void DfpnSolver::PrintStatistics ( HexColor  winner,
const PointSequence p 
) const [private]
void DfpnSolver::PropagateBackwards ( const Game game,
DfpnStates pos 
)
void DfpnSolver::SelectChild ( int &  bestMove,
DfpnBoundType delta2,
const std::vector< DfpnData > &  childrenDfpnBounds,
size_t  maxChildIndex 
) const [private]

Definition at line 717 of file DfpnSolver.cpp.

References DfpnBounds::delta, HexAssert, DfpnBounds::INFTY, and DfpnBounds::IsLosing().

Referenced by MID().

void DfpnSolver::SetTimelimit ( double  timelimit  )  [inline]

See Timelimit().

Definition at line 640 of file DfpnSolver.hpp.

References m_timelimit.

Referenced by DfpnCommands::CmdParam(), and PerfectPlayer::Search().

void DfpnSolver::SetUseGuiFx ( bool  enable  )  [inline]

See UseGuiFx().

Definition at line 630 of file DfpnSolver.hpp.

References m_useGuiFx.

Referenced by DfpnCommands::CmdParam().

void DfpnSolver::SetWideningBase ( int  wideningBase  )  [inline]

See WideningBase().

Definition at line 650 of file DfpnSolver.hpp.

References m_wideningBase.

Referenced by DfpnCommands::CmdParam().

void DfpnSolver::SetWideningFactor ( float  wideningFactor  )  [inline]

See WideningFactor().

Definition at line 660 of file DfpnSolver.hpp.

References m_wideningFactor.

Referenced by DfpnCommands::CmdParam().

HexColor DfpnSolver::StartSearch ( const HexState state,
HexBoard brd,
DfpnStates positions,
PointSequence pv,
const DfpnBounds maxBounds 
)
HexColor DfpnSolver::StartSearch ( const HexState state,
HexBoard brd,
DfpnStates positions,
PointSequence pv 
)

Solves the given state using the given hashtable.

Returns the color of the winning player (EMPTY if it could not determine a winner in time).

Definition at line 318 of file DfpnSolver.cpp.

References DfpnBounds::MAX_WORK.

Referenced by DfpnCommands::CmdFindWinning(), DfpnCommands::CmdSolveState(), PlayAndSolve::SolverThread::operator()(), and PerfectPlayer::Search().

double DfpnSolver::Timelimit (  )  const [inline]

Maximum time search is allowed to run before aborting.

Set to 0 for no timelimit.

Definition at line 635 of file DfpnSolver.hpp.

References m_timelimit.

Referenced by DfpnCommands::CmdParam(), and PerfectPlayer::Search().

bool DfpnSolver::TTRead ( const HexState state,
DfpnData data 
) [private]

Definition at line 782 of file DfpnSolver.cpp.

References SolverDB< HASH, DB, DATA >::Get(), and m_positions.

Referenced by LookupData(), MID(), and StartSearch().

void DfpnSolver::TTWrite ( const HexState state,
const DfpnData data 
) [private]
void DfpnSolver::UpdateBounds ( DfpnBounds bounds,
const std::vector< DfpnData > &  childBounds,
size_t  maxChildIndex 
) const [private]
bool DfpnSolver::UseGuiFx (  )  const [inline]

Dumps output about root state what gui can display.

Definition at line 625 of file DfpnSolver.hpp.

References m_useGuiFx.

Referenced by DfpnCommands::CmdParam().

int DfpnSolver::WideningBase (  )  const [inline]

Widening base affects what number of the moves to consider are always looked at by the dfpn search (omitting losing moves), regardless of branching factor.

This amount is added to the proportion computed by the WideningFactor (see below). The base must be set to at least 1.

Definition at line 645 of file DfpnSolver.hpp.

References m_wideningBase.

Referenced by DfpnCommands::CmdParam(), and ComputeMaxChildIndex().

float DfpnSolver::WideningFactor (  )  const [inline]

Widening factor affects what fraction of the moves to consider are looked at by the dfpn search (omitting losing moves).

Must be in the range (0, 1], where 1 ensures no pruning.

Definition at line 655 of file DfpnSolver.hpp.

References m_wideningFactor.

Referenced by DfpnCommands::CmdParam(), and ComputeMaxChildIndex().


Member Data Documentation

bool DfpnSolver::m_aborted [private]

Definition at line 554 of file DfpnSolver.hpp.

Referenced by CheckAbort(), and StartSearch().

SgHistogram<float, std::size_t> DfpnSolver::m_allEvaluation [private]

Definition at line 576 of file DfpnSolver.hpp.

Referenced by EvaluationInfo(), MID(), and StartSearch().

SgHistogram<float, std::size_t> DfpnSolver::m_allSolvedEvaluation [private]

Definition at line 578 of file DfpnSolver.hpp.

Referenced by EvaluationInfo(), MID(), and StartSearch().

Number of calls to CheckAbort() before we check the timer.

This is to avoid expensive calls to SgTime::Get(). Try to scale this so that it is checked twice a second.

Definition at line 552 of file DfpnSolver.hpp.

Referenced by CheckAbort(), and StartSearch().

SgStatisticsExt<float, std::size_t> DfpnSolver::m_considerSetSize [private]

Definition at line 570 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

SgStatisticsExt<float, std::size_t> DfpnSolver::m_deltaIncrease [private]

Definition at line 572 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

Definition at line 556 of file DfpnSolver.hpp.

Referenced by MID().

std::vector<DfpnListener*> DfpnSolver::m_listener [private]

Definition at line 533 of file DfpnSolver.hpp.

Referenced by AddListener(), and NotifyListeners().

SgHistogram<float, std::size_t> DfpnSolver::m_losingEvaluation [private]

Definition at line 582 of file DfpnSolver.hpp.

Referenced by EvaluationInfo(), MID(), and StartSearch().

SgStatisticsExt<float, std::size_t> DfpnSolver::m_moveOrderingIndex [private]

Definition at line 568 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

SgStatisticsExt<float, std::size_t> DfpnSolver::m_moveOrderingPercent [private]

Definition at line 566 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

size_t DfpnSolver::m_numMIDcalls [private]

Definition at line 560 of file DfpnSolver.hpp.

Referenced by CheckAbort(), MID(), PrintStatistics(), and StartSearch().

size_t DfpnSolver::m_numTerminal [private]

Definition at line 558 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

size_t DfpnSolver::m_numVCbuilds [private]

Definition at line 562 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

Definition at line 531 of file DfpnSolver.hpp.

Referenced by PrintStatistics(), StartSearch(), TTRead(), and TTWrite().

SgStatisticsExt<float, std::size_t> DfpnSolver::m_prunedSiblingStats [private]

Definition at line 564 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

boost::scoped_ptr<HexState> DfpnSolver::m_state [private]

Definition at line 527 of file DfpnSolver.hpp.

Referenced by MID(), and StartSearch().

double DfpnSolver::m_timelimit [private]

See TimeLimit().

Definition at line 541 of file DfpnSolver.hpp.

Referenced by CheckAbort(), SetTimelimit(), and Timelimit().

SgTimer DfpnSolver::m_timer [private]

Definition at line 535 of file DfpnSolver.hpp.

Referenced by CheckAbort(), PrintStatistics(), and StartSearch().

Definition at line 574 of file DfpnSolver.hpp.

Referenced by MID(), PrintStatistics(), and StartSearch().

bool DfpnSolver::m_useGuiFx [private]

See UseGuiFx().

Definition at line 538 of file DfpnSolver.hpp.

Referenced by MID(), SetUseGuiFx(), and UseGuiFx().

See WideningBase().

Definition at line 544 of file DfpnSolver.hpp.

Referenced by SetWideningBase(), and WideningBase().

See WideningFactor().

Definition at line 547 of file DfpnSolver.hpp.

Referenced by SetWideningFactor(), and WideningFactor().

SgHistogram<float, std::size_t> DfpnSolver::m_winningEvaluation [private]

Definition at line 580 of file DfpnSolver.hpp.

Referenced by EvaluationInfo(), MID(), and StartSearch().

Definition at line 529 of file DfpnSolver.hpp.

Referenced by MID(), and StartSearch().


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


6 Jan 2011 Doxygen 1.6.3