ntesukiSearcher.cc
Go to the documentation of this file.
00001 #include "osl/ntesuki/ntesukiSearcher.tcc"
00002 #include <climits>
00003 
00004 bool osl::ntesuki::NtesukiSearcher::
00005 delay_non_pass = false;
00006 
00007 bool osl::ntesuki::NtesukiSearcher::
00008 ptt_invalid_defense = false;
00009 
00010 bool osl::ntesuki::NtesukiSearcher::
00011 delay_interpose = false;
00012 
00013 bool osl::ntesuki::NtesukiSearcher::
00014 delay_nopromote = false;
00015 
00016 bool osl::ntesuki::NtesukiSearcher::
00017 delay_non_attack = false;
00018 
00019 bool osl::ntesuki::NtesukiSearcher::
00020 read_attack_only = false;
00021 
00022 bool osl::ntesuki::NtesukiSearcher::
00023 ptt_non_attack = false;
00024 
00025 bool osl::ntesuki::NtesukiSearcher::
00026 ptt_siblings_fail = false;
00027 
00028 bool osl::ntesuki::NtesukiSearcher::
00029 ptt_siblings_success = false;
00030 
00031 bool osl::ntesuki::NtesukiSearcher::
00032 ptt_uncle = false;
00033 
00034 bool osl::ntesuki::NtesukiSearcher::
00035 ptt_aunt = false;
00036 
00037 unsigned int osl::ntesuki::NtesukiSearcher::
00038 dynamic_widening_width = 0;
00039 
00040 /* ===================
00041  * Constructor / Destructor
00042  */
00043 osl::ntesuki::NtesukiSearcher::
00044 NtesukiSearcher(State& state,
00045                 NtesukiMoveGenerator *mg,
00046                 unsigned int table_limit,
00047                 volatile int *stop_flag,
00048                 bool verbose,
00049                 int max_pass,
00050                 NtesukiRecord::IWScheme iwscheme,
00051                 NtesukiRecord::PSScheme psscheme,
00052                 NtesukiRecord::ISScheme isscheme,
00053                 int tsumero_cost,
00054                 int tsumero_estimate,
00055                 double gc_ratio)
00056   : state(state),
00057     mg(mg),
00058     table(table_limit,
00059           static_cast<unsigned int>(table_limit * gc_ratio),
00060           verbose),
00061     simulator(state, mg, path, table, isscheme, verbose),
00062     node_count(0),
00063     verbose(verbose),
00064     stop_flag(stop_flag),
00065     path(state.turn()),
00066     /* control on search */
00067     max_pass(max_pass),
00068     iwscheme(iwscheme),
00069     psscheme(psscheme),
00070     isscheme(isscheme),
00071     tsumero_cost(tsumero_cost),
00072     tsumero_estimate(tsumero_estimate),
00073     gc_ratio(gc_ratio),
00074     /* statistical information */
00075     blockByAttackBack(0), blockByPass(0),
00076     attack_node_count(0),
00077     attack_node_under_attack_count(0),
00078     attack_node_moves_count(0),
00079     defense_node_count(0),
00080     defense_node_under_attack_count(0),
00081     defense_node_moves_count(0),
00082     pass_count(0), pass_success_count(0),
00083     pass_attack_count(0), pass_attack_success_count(0),
00084     sibling_defense_count(0), sibling_defense_success_count(0),
00085     sibling_attack_count(0), sibling_attack_success_count(0),
00086     isshogi_defense_count(0), isshogi_defense_success_count(0),
00087     isshogi_attack_count(0), isshogi_attack_success_count(0),
00088     immediate_win(0), immediate_lose(0),
00089     attack_back_count(0),
00090     proof_without_inversion_count(0), proof_AND_count(0), disproof_by_inversion_count(0)
00091 {
00092   NtesukiRecord::table = &table;
00093   NtesukiRecord::state = &state;
00094   NtesukiRecord::mg = mg;
00095   NtesukiRecord::split_count = 0;
00096   NtesukiRecord::confluence_count = 0;
00097   
00098   if (this->max_pass > (int)NtesukiRecord::SIZE)
00099     this->max_pass = NtesukiRecord::SIZE;
00100 
00101   if (verbose)
00102   {
00103     std::cerr << "NtesukiSearcher \n"
00104               << "IWScheme:\t" << iwscheme << "\n"
00105               << "PSScheme:\t" << psscheme << "\n"
00106               << "ISScheme:\t" << isscheme << "\n"
00107               << "Fixed:\t" << NtesukiRecord::fixed_search_depth<< "\n"
00108               << "Tsumero cost:\t" << tsumero_cost << "\n"
00109               << "Tsumero estimate:\t" << tsumero_estimate << "\n"
00110               << "Inversion cost:\t" << NtesukiRecord::inversion_cost << "\n"
00111       ;
00112     std::cerr << "enhancements: ";
00113     if(NtesukiSearcher::ptt_uncle)
00114       std::cerr << " PTT_UNCLE";
00115     if(NtesukiSearcher::ptt_siblings_fail)
00116       std::cerr << " PTT_SIBLINGS_FAIL";
00117     if(NtesukiSearcher::ptt_siblings_success)
00118       std::cerr << " PTT_SIBLINGS_SUCCESS";
00119     if(NtesukiSearcher::delay_non_pass)
00120       std::cerr << " DELAY_NON_PASS";
00121     if (NtesukiSearcher::ptt_invalid_defense)
00122       std::cerr << " PASS_SIMULATION";
00123     if (NtesukiSearcher::delay_interpose)
00124       std::cerr << " DELAY_INTERPOSE";
00125     if(NtesukiSearcher::delay_nopromote)
00126       std::cerr << " DELAY_NOPROMOTE";
00127     if(NtesukiSearcher::delay_non_attack)
00128       std::cerr << " DELAY_NON_ATTACK";
00129     if(NtesukiSearcher::read_attack_only)
00130       std::cerr << " READ_ATTACK_ONLY";
00131     if(NtesukiSearcher::ptt_non_attack)
00132       std::cerr << " PTT_NON_ATTACK";
00133     if (NtesukiRecord::use_dominance)
00134       std::cerr << " USE_DOMINANCE";
00135     std::cerr << "\n";
00136   }
00137 }
00138 
00139 osl::ntesuki::NtesukiSearcher::
00140 ~NtesukiSearcher()
00141 {
00142   if (verbose)
00143   {
00144     std::cerr << "~NtesukiSearcher "
00145               << table.size()
00146               << "/" << node_count
00147               << "/" << read_node_limit << "\t"
00148               << "pass(" << pass_success_count << "/" << pass_count << ")\n"
00149 
00150               << "attack_node\t"
00151               << attack_node_under_attack_count << "/"
00152               << attack_node_count << "\t"
00153               << attack_node_moves_count << "moves\n"
00154 
00155               << "defense_node\t"
00156               << defense_node_under_attack_count << "/"
00157               << defense_node_count << "\t"
00158               << defense_node_moves_count << "moves\n"
00159             
00160               << "immidate(" << immediate_win << ", "
00161               << immediate_lose << ")\n"
00162       
00163               << "attack_back(" << attack_back_count << ")\n"
00164 
00165               << "sibling_success(" << sibling_defense_success_count
00166               << "/" << sibling_defense_count << ")\n"
00167               << "sibling_fail(" << sibling_attack_success_count
00168               << "/" << sibling_attack_count << ")\n"
00169       
00170               << "is_att(" << isshogi_attack_success_count
00171               << "/" << isshogi_attack_count << ")\t"
00172               << "is_def(" << isshogi_defense_success_count
00173               << "/" << isshogi_defense_count << ")\n"
00174 
00175               << "inversion_win(" << disproof_by_inversion_count
00176               << "/" << proof_AND_count
00177               << "/" << proof_without_inversion_count << ")\n"
00178 
00179               << "DAG\t"
00180               << NtesukiRecord::split_count << "/"
00181               << NtesukiRecord::confluence_count << "\n"
00182       ;
00183   }
00184 }
00185 
00186 NtesukiTable& 
00187 osl::ntesuki::NtesukiSearcher::
00188 getTable()
00189 {
00190   return table;
00191 }
00192 
00193 /* explicit instantiation
00194  */
00195 namespace osl
00196 {
00197   namespace ntesuki
00198   {
00199     template int NtesukiSearcher::search<BLACK>();
00200     template int NtesukiSearcher::search<WHITE>();
00201   }
00202 }
00203 
00204 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines