All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | List of all members
osl::search::AlphaBeta2< EvalT > Class Template Reference

AlphaBeta の書き直し版 More...

#include <alphaBeta2.h>

Inheritance diagram for osl::search::AlphaBeta2< EvalT >:
Inheritance graph
[legend]
Collaboration diagram for osl::search::AlphaBeta2< EvalT >:
Collaboration graph
[legend]

Public Types

typedef AlphaBeta2Tree< EvalT > base_t
 
typedef base_t::checkmate_t checkmate_t
 
typedef base_t::Window Window
 
- Public Types inherited from osl::search::AlphaBeta2Tree< EvalT >
enum  { MaxDepth = SearchState2Core::MaxDepth }
 
typedef EvalT eval_t
 
typedef AlphaBeta2Common< EvalT > common_t
 
typedef AlphaBeta2Window Window
 
- Public Types inherited from osl::search::SearchBase< EvalT, SimpleHashTable, CountRecorder, RealizationProbability >
typedef EvalT eval_t
 
typedef RealizationProbability Probabilities_t
 

Public Member Functions

 AlphaBeta2 (const NumEffectState &s, checkmate_t &checker, SimpleHashTable *t, CountRecorder &)
 
 ~AlphaBeta2 ()
 
template<Player P>
int alphaBetaSearchRoot (Window window, MoveLogProb &best_move, int limit)
 entrance of alpha beta window search. More...
 
int alphaBetaSearchRoot (Window window, MoveLogProb &best_move, int limit)
 
int alphaBetaSearchRoot (MoveLogProb &best_move, int limit)
 
Move computeBestMoveIteratively (int limit, const int step=100, int initialLimit=600, size_t nodeLimit=1600000, const TimeAssigned &assign=TimeAssigned(MilliSeconds::Interval(60 *1000)), MoveWithComment *additional_info=0)
 entrance of alpha beta iterative search. More...
 
bool isReasonableMove (Move move, int pawn_sacrifice=1)
 
void setRootIgnoreMoves (const MoveVector *rim, bool prediction)
 
void enableMultiPV (unsigned int width)
 
const AlphaBeta2SharedRoot sharedRootInfo () const
 
void setRoot (int limit)
 
void makeMove (Move)
 
- Public Member Functions inherited from osl::search::AlphaBeta2Tree< EvalT >
bool stopping () const
 
void testStop ()
 
size_t nodeCount () const
 
template<Player P>
const MoveLogProb nextMove ()
 
template<osl::Player P>
const osl::MoveLogProb nextMove ()
 
- Public Member Functions inherited from osl::search::SearchBase< EvalT, SimpleHashTable, CountRecorder, RealizationProbability >
 SearchBase (CountRecorder &r, SimpleHashTable *t)
 
virtual ~SearchBase ()
 
virtual bool abort (Move) const
 
bool validTableMove (const NumEffectState &state, const MoveLogProb &move, int limit) const
 テーブルの指手の正しさを確かめる More...
 
void recordWinByCheckmate (Player P, SimpleHashRecord *record, Move check_move) const
 詰将棋の見つけた勝 More...
 
void recordLoseByCheckmate (Player P, SimpleHashRecord *record) const
 詰将棋の見つけた敗 More...
 
- Public Member Functions inherited from osl::search::SearchState2
 SearchState2 (const NumEffectState &s, checkmate_t &checker)
 
virtual ~SearchState2 ()
 
void setState (const NumEffectState &s)
 state のコピーを行う. More...
 
void setKillerMove (Move best_move)
 
int curLimit () const
 
bool abort (Move) const
 
- Public Member Functions inherited from osl::search::SearchState2Core
 SearchState2Core (const NumEffectState &s, checkmate_t &checker)
 
virtual ~SearchState2Core ()
 
int curDepth () const
 
void setHistory (const MoveStack &h)
 
bool hasLastRecord (unsigned int n=0) const
 
SimpleHashRecordlastRecord (unsigned int n=0)
 
const SimpleHashRecordlastRecord (unsigned int n=0) const
 
SimpleHashRecordrootRecord ()
 
void setCurrentRecord (SimpleHashRecord *r)
 
void setRootRecord (SimpleHashRecord *root)
 
void setKillerMove (Move best_move)
 
void getBigramKillerMoves (MoveVector &moves) const
 
void getKillerMoves (MoveVector &moves) const
 
const BigramKillerMovebigramKillerMove () const
 
void setBigramKillerMove (const BigramKillerMove &killers)
 
HistoryTablehistoryTable ()
 
const HistoryTablehistoryTable () const
 
void pushPass ()
 
void popPass ()
 
template<Player P, class Function >
void doUndoMoveOrPass (const HashKey &new_hash, Move move, Function &f)
 まともなdoUndo More...
 
void makeMove (Move move)
 
const Move lastMove (int i=1) const
 
const MoveStack & history () const
 
const RecordStack2recordHistory () const
 
const PathEncodingpath () const
 
const NumEffectState & state () const
 
const NumEffectState & rootState () const
 
void restoreRootState ()
 
const checkmate_tcheckmateSearcher () const
 
const RepetitionCounterrepetitionCounter () const
 
const HashKey & currentHash () const
 
template<Player P, class Function >
void doUndoMoveLight (Move move, Function &f)
 軽量化版 doUndo 千日手情報や, hash を更新しない More...
 
template<Player P>
bool isLosingState (int node_limit)
 
template<Player P>
bool isWinningState (int node_limit, Move &checkmate_move, bool parallel=false)
 
template<Player P>
bool isWinningStateShort (int depth, Move &checkmate_move)
 FixedDepthSearcher を呼ぶ More...
 
template<Player P>
bool isThreatmateState (int node_limit, Move &threatmate_move, bool=false)
 P の手番でPの玉に詰めろがかかっているかどうか More...
 
template<Player P>
bool isThreatmateStateShort (int depth, Move &threatmate_move)
 
bool abort () const
 
bool tryThreatmate () const
 
void makePV (Move m)
 
void initPV ()
 
void makePV (PVVector &parent, Move m, PVVector &pv) const
 
int countCheckAfterThreatmate (Player turn, int depth=1) const
 turn の側が連続王手で詰ろを逃れている回数 More...
 
int countCheckAfterThreatmateSacrifice (Player turn, int depth=1) const
 
- Public Member Functions inherited from osl::search::SearchTimer
 SearchTimer ()
 
 SearchTimer (const SearchTimer &src)
 
virtual ~SearchTimer ()
 
void setTimeAssign (const TimeAssigned &a)
 
void setStartTime (MilliSeconds start)
 
void setStable (bool new_stable)
 
bool isStableNow () const
 
bool hasSchedule () const
 
const TimeAssignedtimeAssigned () const
 
const MilliSeconds startTime () const
 
double elapsed (MilliSeconds now) const
 
double elapsed () const
 
void setNextIterationCoefficient (double new_value)
 
void setNodeCountHardLimit (uint64_t new_value)
 
double nextIterationCoefficient () const
 
bool stopping () const
 
void stopNow ()
 
SearchTimerCommon::StopReason stopReason ()
 
void throwIfNoMoreTime (uint64_t node_count)
 
int nodeAffordable () const
 
void addMonitor (const boost::shared_ptr< SearchMonitor > &)
 
bool hasMonitor () const
 
const vector
< boost::shared_ptr
< SearchMonitor > > & 
monitors () const
 
int lastMemoryUseRatio1000 () const
 

Static Public Member Functions

static const Window fullWindow (Player P)
 
static void showNodeDepth (std::ostream &)
 
static void clearNodeDepth ()
 
- Static Public Member Functions inherited from osl::search::AlphaBeta2Tree< EvalT >
static int rootAlpha (Player P, int last_value, Progress16 progress)
 
static int stableThreshold (Player P, int last_value)
 
- Static Public Member Functions inherited from osl::search::SearchTimer
static void adjustMemoryUseLimit (double scale=0.9)
 メモリとノード数の関係を調整. More...
 

Private Types

enum  PVCheckmateStatus { PVStable, PVThreatmateNotRecord, PVThreatmate, PVCheckmate }
 

Private Member Functions

PVCheckmateStatus findCheckmateInPV (int verify_node, CArray< bool, 2 > &king_in_threat)
 

Additional Inherited Members

- Public Attributes inherited from osl::search::SearchState2Core
volatile bool stop_tree
 beta cut in parallel search More...
 
- Static Public Attributes inherited from osl::search::SearchState2
static const int ReSearchLimitMargin = 80
 再探索や,指手生成でより確率の高い手があったときに無視する範囲 More...
 
- Protected Types inherited from osl::search::SearchState2Core
enum  NodeType { PvNode = 0, AllNode = 1, CutNode = -1 }
 
- Protected Types inherited from osl::search::AlphaBeta2Common< EvalT >
enum  { MaxDepth = SearchState2Core::MaxDepth }
 
enum  MoveType {
  INITIAL, HASH =INITIAL, TACTICAL, KILLER,
  PASS, ALL, FINISH
}
 
typedef FixedCapacityVector
< Move, 4 > 
killer_t
 
- Protected Member Functions inherited from osl::search::AlphaBeta2Tree< EvalT >
 AlphaBeta2Tree (const NumEffectState &s, checkmate_t &checker, SimpleHashTable *t, CountRecorder &)
 
 AlphaBeta2Tree (const AlphaBeta2Tree &src, AlphaBeta2Parallel< EvalT > *)
 
 ~AlphaBeta2Tree ()
 
void updateRootPV (Player P, std::ostream &, int, Move)
 
void addMultiPV (Player P, int, Move)
 
bool isStable (Player P, int new_value) const
 
void showFailLow (int result, Move m) const
 
template<Player P>
int alphaBetaSearch (const MoveLogProb &move, Window window, bool in_pv)
 alphaBetaSearch (move) More...
 
template<Player P>
int alphaBetaSearchAfterMove (const MoveLogProb &move, Window window, bool in_pv)
 
template<Player P>
int quiesce (Window)
 
template<Player P>
int quiesceStable (Window)
 
template<Player P>
int quiesceExp (Window)
 
template<Player P>
int searchAllMoves (SimpleHashRecord *, Window w)
 
template<Player P>
int searchAllMoves (Move m, int limit_consumption, SimpleHashRecord *, Window w)
 
template<Player P>
bool tryCheckmate (SimpleHashRecord *record, bool in_pv, Move &checkmate_move)
 初めの方で詰みを読む More...
 
template<Player P>
bool tryCheckmateAgain (SimpleHashRecord *record, Move &checkmate_move, int node_count, int best_value)
 負けそうな時にさらに詰みを読む More...
 
template<Player P>
void testThreatmate (SimpleHashRecord *record, bool in_pv)
 詰めろの有無を確認 More...
 
template<Player P>
void examineMovesRoot (const MoveLogProbVector &, size_t, Window, MoveLogProb &, int &)
 alpha値が求まった後で他の手を調べる More...
 
template<Player P>
int quiesceRoot (Window, int depth_left, Move &best_move, DualThreatmateState)
 
template<Player P>
int quiesce (Window, int depth_left, DualThreatmateState)
 
template<Player P>
bool quiesceWithMove (Move, Window &, int, Move &, int &, const DualThreatmateState &)
 
void updateCheckmateCount ()
 
bool tryPass (SimpleHashRecord *record, Player P) const
 
MoveGeneratormakeGenerator ()
 
- Static Protected Member Functions inherited from osl::search::AlphaBeta2Tree< EvalT >
static MoveGeneratoralloc ()
 
static void dealloc (MoveGenerator *)
 
- Protected Attributes inherited from osl::search::AlphaBeta2Tree< EvalT >
size_t node_count
 静止探索も含めたノード数 More...
 
FixedCapacityVector
< MoveGenerator *, MaxDepth
generators
 
stat::Average mpn
 
stat::Average mpn_cut
 
stat::Average alpha_update
 
stat::Average last_alpha_update
 
stat::Average ext
 
stat::Average ext_limit
 
boost::shared_ptr
< AlphaBeta2Parallel< EvalT > > 
shared
 
boost::shared_ptr
< AlphaBeta2SharedRoot
shared_root
 
- Static Protected Attributes inherited from osl::search::AlphaBeta2Tree< EvalT >
static CArray< int,
SearchState2Core::MaxDepth
depth_node_count
 

Detailed Description

template<class EvalT>
class osl::search::AlphaBeta2< EvalT >

AlphaBeta の書き直し版

Definition at line 284 of file alphaBeta2.h.

Member Typedef Documentation

template<class EvalT >
typedef AlphaBeta2Tree<EvalT> osl::search::AlphaBeta2< EvalT >::base_t

Definition at line 288 of file alphaBeta2.h.

template<class EvalT >
typedef base_t::checkmate_t osl::search::AlphaBeta2< EvalT >::checkmate_t

Definition at line 289 of file alphaBeta2.h.

template<class EvalT >
typedef base_t::Window osl::search::AlphaBeta2< EvalT >::Window

Definition at line 290 of file alphaBeta2.h.

Member Enumeration Documentation

template<class EvalT >
enum osl::search::AlphaBeta2::PVCheckmateStatus
private
Enumerator
PVStable 
PVThreatmateNotRecord 
PVThreatmate 
PVCheckmate 

Definition at line 344 of file alphaBeta2.h.

Constructor & Destructor Documentation

template<class EvalT >
osl::search::AlphaBeta2< EvalT >::AlphaBeta2 ( const NumEffectState &  s,
checkmate_t checker,
SimpleHashTable t,
CountRecorder r 
)

Definition at line 1650 of file alphaBeta2.cc.

References osl::search::MoveGenerator::initOnce().

template<class EvalT >
osl::search::AlphaBeta2< EvalT >::~AlphaBeta2 ( )

Definition at line 1659 of file alphaBeta2.cc.

Member Function Documentation

template<class EvalT >
template<osl::Player P>
int osl::search::AlphaBeta2< EvalT >::alphaBetaSearchRoot ( Window  window,
MoveLogProb best_move,
int  limit 
)

entrance of alpha beta window search.

see http://www.logos.t.u-tokyo.ac.jp/~gekisashi/algorithm/re_search.html. rootDepth, curLimit are initialized here.

Definition at line 2071 of file alphaBeta2.cc.

References osl::search::SimpleHashTable::allocate(), osl::search::AlphaBeta2Window::alpha(), osl::alt(), osl::search::SimpleHashRecord::bestMove(), osl::search::QuiescenceRecord::bestMove(), osl::search::AlphaBeta2Window::beta(), osl::eval::betterThan(), osl::search::QuiescenceRecord::checkmateNodesLeft(), count, osl::eval::delta(), osl::container::GeneralSimpleHashTable< Record >::find(), osl::Move::from(), osl::search::MoveGenerator::generateAll(), osl::search::SimpleHashRecord::hasGreaterLowerBound(), osl::search::SimpleHashRecord::hasUpperBound(), osl::search::SearchTable::HistorySpecialDepth, osl::search::MoveGenerator::init(), osl::Move::INVALID(), osl::Move::isDrop(), osl::move_classifier::KingOpenMove< P >::isMember(), osl::Move::isNormal(), osl::search::DualThreatmateState::isThreatmate(), osl::search::SimpleHashTable::isVerbose(), osl::KING, osl::OslConfig::lock_io, osl::eval::max(), osl::eval::min(), osl::MoveLogProb::move(), osl::Move::move, moves, osl::newPtypeO(), osl::PieceStand::order, osl::Move::PASS(), osl::PAWN, osl::Move::ptype(), osl::search::SimpleHashRecord::qrecord, osl::search::SimpleHashRecord::resetValue(), result, osl::OslConfig::searchExactValueInOneReply(), osl::search::SimpleHashRecord::setInCheck(), osl::search::SimpleHashRecord::setLowerBound(), osl::search::DualThreatmateState::setThreatmate(), osl::search::SimpleHashRecord::threatmate(), osl::Move::to(), osl::search::SimpleHashRecord::upperBound(), osl::OslConfig::usiOutputPawnValue(), osl::MoveLogProb::validMove(), and osl::search::SimpleHashTable::verboseLevel().

template<class EvalT >
int osl::search::AlphaBeta2< EvalT >::alphaBetaSearchRoot ( Window  window,
MoveLogProb best_move,
int  limit 
)
inline

Definition at line 309 of file alphaBeta2.h.

References osl::BLACK, limit, and osl::search::SearchState2Core::state().

template<class EvalT >
int osl::search::AlphaBeta2< EvalT >::alphaBetaSearchRoot ( MoveLogProb best_move,
int  limit 
)

Definition at line 1748 of file alphaBeta2.cc.

template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::clearNodeDepth ( )
static

Definition at line 2532 of file alphaBeta2.cc.

template<class EvalT >
osl::Move osl::search::AlphaBeta2< EvalT >::computeBestMoveIteratively ( int  limit,
const int  step = 100,
int  initialLimit = 600,
size_t  nodeLimit = 1600000,
const TimeAssigned assign = TimeAssigned(MilliSeconds::Interval(60*1000)),
MoveWithComment additional_info = 0 
)
template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::enableMultiPV ( unsigned int  width)
inline

Definition at line 338 of file alphaBeta2.h.

References osl::search::AlphaBeta2Common< EvalT >::multi_pv, and width.

template<class EvalT >
osl::search::AlphaBeta2< EvalT >::PVCheckmateStatus osl::search::AlphaBeta2< EvalT >::findCheckmateInPV ( int  verify_node,
CArray< bool, 2 > &  king_in_threat 
)
private
template<class EvalT >
static const Window osl::search::AlphaBeta2< EvalT >::fullWindow ( Player  P)
inlinestatic

Definition at line 305 of file alphaBeta2.h.

References osl::alt(), and osl::search::FixedEval::winThreshold().

template<class EvalT >
bool osl::search::AlphaBeta2< EvalT >::isReasonableMove ( Move  move,
int  pawn_sacrifice = 1 
)

Definition at line 2491 of file alphaBeta2.cc.

template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::makeMove ( Move  move)
template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::setRoot ( int  limit)
template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::setRootIgnoreMoves ( const MoveVector *  rim,
bool  prediction 
)
inline
template<class EvalT >
const AlphaBeta2SharedRoot osl::search::AlphaBeta2< EvalT >::sharedRootInfo ( ) const
inline
template<class EvalT >
void osl::search::AlphaBeta2< EvalT >::showNodeDepth ( std::ostream &  os)
static

Definition at line 2498 of file alphaBeta2.cc.

References osl::eval::max(), and max_depth.


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