3 #ifndef GAMEPLAYING_SEARCHPLAYER_TCC 
    4 #define GAMEPLAYING_SEARCHPLAYER_TCC 
   17 #include <boost/scoped_ptr.hpp> 
   18 #include <boost/foreach.hpp> 
   22 osl::game_playing::SearchPlayer::NtesukiThread
 
   24   explicit NtesukiThread(Move& next_move,
 
   25                          volatile bool *thread_finished,
 
   26                          volatile bool *stop_flag,
 
   27                          NumEffectState state);
 
   32   volatile bool *thread_finished;
 
   33   volatile bool *stop_flag;
 
   38 template <
class Searcher>
 
   45 template <
class Searcher>
 
   52 template <
class Searcher>
 
   59 template <
class Searcher>
 
   64   searcher.setRootIgnoreMoves(root_ignore_moves, prediction_for_speculative_search);
 
   67   if (! eval_t::initialized())
 
   68     throw std::runtime_error(
"evaluation function not initialized");
 
   73   volatile bool ntesuki_thread_finished;
 
   74   volatile bool stop_ntesuki;
 
   75   Move ntesuki_next_move = Move::INVALID();
 
   77   NtesukiThread thread(ntesuki_next_move, &ntesuki_thread_finished,
 
   78                        &stop_ntesuki, state.
state());
 
   79   boost::thread ntesuki_thread(thread);
 
   81   searcher.setHistory(history);
 
   82   searcher.enableMultiPV(config.multi_pv_width);
 
   83   BOOST_FOREACH(
const boost::shared_ptr<search::SearchMonitor>& m,
 
   85     searcher.addMonitor(m);
 
   86   int deepening_step_for_this_move = config.deepening_step;
 
   89     if (msec.
standard.toSeconds() < 10.0)
 
   90       deepening_step_for_this_move = 
std::min(100, config.deepening_step);
 
   92   searcher.setNextIterationCoefficient(config.next_iteration_coefficient);
 
   93   searcher.setNodeCountHardLimit(config.node_count_hard_limit);
 
   95   MoveWithComment best_move;
 
   96   best_move.root = HashKey(state.
state());
 
  102     = searcher.computeBestMoveIteratively(config.limit, 
 
  103                                           deepening_step_for_this_move,
 
  104                                           config.initial_limit,
 
  110   if (ntesuki_thread_finished)
 
  114       return ntesuki_next_move;
 
  125     ntesuki_thread.join();
 
  128   saveSearchResult(state, best_move);
 
  129   static const int resign_value = OslConfig::resignThreshold();
 
  130   if (! state.
state().inCheck() && best_move.move.isNormal()
 
  133     ++almost_resign_count;
 
  134     if (almost_resign_count >= 3)
 
  135       best_move.move = 
Move();
 
  139     almost_resign_count = 0;
 
  144 template <
class Searcher>
 
  148   return searcher.isReasonableMove(move, pawn_sacrifice);