]> git.sesse.net Git - stockfish/blobdiff - src/uci.cpp
Remove dcCandidates data member from SplitPoint
[stockfish] / src / uci.cpp
index a64520050f084e481cc2804aba1dec5406f21c66..f6b27114b13d64f60fafbd24c74c9550b7053afe 100644 (file)
@@ -61,6 +61,7 @@ namespace {
   void set_option(UCIInputParser& uip);
   void set_position(UCIInputParser& uip);
   bool go(UCIInputParser& uip);
+  void perft(UCIInputParser& uip);
 }
 
 
@@ -117,13 +118,13 @@ namespace {
     if (token == "uci")
     {
         cout << "id name " << engine_name()
-             << "\nid author Tord Romstad, Marco Costalba\n";
+             << "\nid author Tord Romstad, Marco Costalba, Joona Kiiski\n";
         print_uci_options();
         cout << "uciok" << endl;
     }
     else if (token == "ucinewgame")
     {
-        TT.clear();
+        push_button("Clear Hash");
         Position::init_piece_square_tables();
         RootPosition.from_fen(StartPosition);
     }
@@ -147,14 +148,16 @@ namespace {
     else if (token == "eval")
     {
         EvalInfo ei;
-        cout << "Incremental mg: " << RootPosition.mg_value()
-             << "\nIncremental eg: " << RootPosition.eg_value()
+        cout << "Incremental mg: " << mg_value(RootPosition.value())
+             << "\nIncremental eg: " << eg_value(RootPosition.value())
              << "\nFull eval: " << evaluate(RootPosition, ei, 0) << endl;
     }
     else if (token == "key")
         cout << "key: " << hex << RootPosition.get_key()
              << "\nmaterial key: " << RootPosition.get_material_key()
              << "\npawn key: " << RootPosition.get_pawn_key() << endl;
+    else if (token == "perft")
+        perft(uip);
     else
     {
         cout << "Unknown command: " << command << endl;
@@ -210,9 +213,9 @@ namespace {
                 if (RootPosition.rule_50_counter() == 0)
                     RootPosition.reset_game_ply();
             }
-            // Our StateInfo st is about going out of scope,
-            // so save its content before they disappear.
-            RootPosition.setStartState(st);
+            // Our StateInfo st is about going out of scope so copy
+            // its content inside RootPosition before they disappear.
+            RootPosition.saveState();
         }
     }
   }
@@ -242,7 +245,10 @@ namespace {
         }
         if (token == "value")
         {
-            getline(uip, token); // reads until end of line
+            // Reads until end of line and left trim white space
+            getline(uip, token);
+            token.erase(0, token.find_first_not_of(" \n\r\t"));
+
             set_option_value(name, token);
         } else
             push_button(name);
@@ -315,4 +321,24 @@ namespace {
                  time, inc, movesToGo, depth, nodes, moveTime, searchMoves);
   }
 
+  void perft(UCIInputParser& uip) {
+
+    string token;
+    int depth = 0;
+
+    while (!uip.eof())
+    {
+        uip >> token;
+
+        if (token == "depth")
+            uip >> depth;
+    }
+    Position pos = RootPosition;
+    int tm = get_system_time();
+    int n = perft(pos, depth * OnePly);
+    tm = get_system_time() - tm;
+    std::cout << "\nNodes " << n
+              << "\nTime (ms) " << tm
+              << "\nNodes/second " << (int)(n/(tm/1000.0)) << std::endl;
+  }
 }