00001 #ifndef OSL_BRINKMATE_SEARCHER_H
00002 #define OSL_BRINKMATE_SEARCHER_H
00003
00004 #include "osl/brinkmate/brinkmateTable.h"
00005 #include "osl/brinkmate/brinkmateState.h"
00006 #include "osl/brinkmate/threatmatePool.h"
00007 #include "osl/search/bigramKillerMove.h"
00008
00009 namespace osl
00010 {
00011 namespace checkmate
00012 {
00013 class ProofDisproof;
00014 }
00015 namespace brinkmate
00016 {
00020 class Searcher
00021 {
00022 BrinkmateTable table;
00023 BrinkmateState state;
00024 BrinkmateState::checkmate_t checkmator;
00025 Configuration root_conf;
00026 ThreatmatePool pool;
00027 search::BigramKillerMove killer_moves;
00028 volatile int *stop_flag;
00029 int count;
00030 int max_depth;
00031 int verbose;
00032 public:
00033 Searcher(Player attack, size_t capacity, int verbose);
00034 ~Searcher();
00035
00039 const Move search(HashEffectState&, int max_depth);
00041 BrinkmateResult search(HashEffectState&,
00042 int depth, int tnode, int cnode,
00043 int dcm, int rnode);
00044
00045 BrinkmateResult attack();
00046 BrinkmateResult defense();
00047
00048 void setStopFlag(volatile int *flag)
00049 {
00050 stop_flag = flag;
00051 }
00052
00053 int depthLeft() const { return root_conf.depth - state.effectiveDepth(); }
00054 bool provedByRecord(const BrinkmateRecord&) const;
00055 bool disprovedByRecord(const BrinkmateRecord&) const;
00056 void showBestMoves() const;
00057 void showTree(const HashKey&, int depth=1) const;
00058 int getCount() const { return count; }
00059
00060 static bool threatmateCandidate(const BrinkmateState&, Move);
00061 static bool threatmateCandidate(const BrinkmateState&, Move,
00062 Position centered_king);
00063 private:
00065 bool attack(BrinkmateRecord *, Move);
00067 bool defense(BrinkmateRecord *, Move);
00068 void setUpAttack(BrinkmateRecord *record);
00069 void setUpDefense(BrinkmateRecord *record);
00070
00071 };
00072 }
00073 }
00074
00075 #endif
00076
00077
00078
00079