]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Retire RootMove::nodes
[stockfish] / src / search.cpp
index 636ebd8ef6654b4a31f325b752ca5e1d0dceab53..baae494b9e6073f656a2ca715d7d91bf63cf843b 100644 (file)
@@ -1,7 +1,7 @@
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
   Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
+  Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad
 
   Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -67,7 +67,6 @@ namespace {
 
     RootMove(){}
     RootMove(Move m) {
-      nodes = 0;
       score = prevScore = -VALUE_INFINITE;
       pv.push_back(m);
       pv.push_back(MOVE_NONE);
@@ -79,7 +78,6 @@ namespace {
     void extract_pv_from_tt(Position& pos);
     void insert_pv_in_tt(Position& pos);
 
-    int64_t nodes;
     Value score;
     Value prevScore;
     std::vector<Move> pv;
@@ -296,12 +294,12 @@ void Search::think() {
           || count(SearchMoves.begin(), SearchMoves.end(), ml.move()))
           RootMoves.push_back(RootMove(ml.move()));
 
-  if (Options["OwnBook"].value<bool>())
+  if (Options["OwnBook"])
   {
-      if (Options["Book File"].value<string>() != book.name())
-          book.open(Options["Book File"].value<string>());
+      if (book.name() != (string)Options["Book File"])
+          book.open(Options["Book File"]);
 
-      Move bookMove = book.probe(pos, Options["Best Book Move"].value<bool>());
+      Move bookMove = book.probe(pos, Options["Best Book Move"]);
 
       if (   bookMove != MOVE_NONE
           && count(RootMoves.begin(), RootMoves.end(), bookMove))
@@ -315,24 +313,24 @@ void Search::think() {
   read_evaluation_uci_options(pos.side_to_move());
   Threads.read_uci_options();
 
-  TT.set_size(Options["Hash"].value<int>());
-  if (Options["Clear Hash"].value<bool>())
+  TT.set_size(Options["Hash"]);
+  if (Options["Clear Hash"])
   {
       Options["Clear Hash"] = false;
       TT.clear();
   }
 
-  UCIMultiPV = Options["MultiPV"].value<size_t>();
-  SkillLevel = Options["Skill Level"].value<int>();
+  UCIMultiPV = Options["MultiPV"];
+  SkillLevel = Options["Skill Level"];
 
   // Do we have to play with skill handicap? In this case enable MultiPV that
   // we will use behind the scenes to retrieve a set of possible moves.
   SkillLevelEnabled = (SkillLevel < 20);
   MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, (size_t)4) : UCIMultiPV);
 
-  if (Options["Use Search Log"].value<bool>())
+  if (Options["Use Search Log"])
   {
-      Log log(Options["Search Log Filename"].value<string>());
+      Log log(Options["Search Log Filename"]);
       log << "\nSearching: "  << pos.to_fen()
           << "\ninfinite: "   << Limits.infinite
           << " ponder: "      << Limits.ponder
@@ -362,11 +360,11 @@ void Search::think() {
   Threads.set_timer(0);
   Threads.set_size(1);
 
-  if (Options["Use Search Log"].value<bool>())
+  if (Options["Use Search Log"])
   {
       int e = elapsed_time();
 
-      Log log(Options["Search Log Filename"].value<string>());
+      Log log(Options["Search Log Filename"]);
       log << "Nodes: "          << pos.nodes_searched()
           << "\nNodes/second: " << (e > 0 ? pos.nodes_searched() * 1000 / e : 0)
           << "\nBest move: "    << move_to_san(pos, RootMoves[0].pv[0]);
@@ -512,7 +510,7 @@ namespace {
         if (SkillLevelEnabled && depth == 1 + SkillLevel)
             skillBest = do_skill_level();
 
-        if (Options["Use Search Log"].value<bool>())
+        if (Options["Use Search Log"])
              pv_info_to_log(pos, depth, bestValue, elapsed_time(), &RootMoves[0].pv[0]);
 
         // Filter out startup noise when monitoring best move stability
@@ -594,7 +592,6 @@ namespace {
     assert(pos.thread() >= 0 && pos.thread() < Threads.size());
 
     Move movesSearched[MAX_MOVES];
-    int64_t nodes;
     StateInfo st;
     const TTEntry *tte;
     Key posKey;
@@ -901,7 +898,6 @@ split_point_start: // At split points actual search starts from here
       if (RootNode)
       {
           Signals.firstRootMove = (moveCount == 1);
-          nodes = pos.nodes_searched();
 
           if (pos.thread() == 0 && elapsed_time() > 2000)
               cout << "info depth " << depth / ONE_PLY
@@ -1068,7 +1064,6 @@ split_point_start: // At split points actual search starts from here
       if (RootNode && !Signals.stop)
       {
           RootMove& rm = *find(RootMoves.begin(), RootMoves.end(), move);
-          rm.nodes += pos.nodes_searched() - nodes;
 
           // PV move or new best move ?
           if (isPvMove || value > alpha)
@@ -1758,7 +1753,7 @@ split_point_start: // At split points actual search starts from here
     while (m != pv)
         pos.undo_move(*--m);
 
-    Log l(Options["Search Log Filename"].value<string>());
+    Log l(Options["Search Log Filename"]);
     l << s.str() << endl;
   }