]> git.sesse.net Git - stockfish/blobdiff - src/benchmark.cpp
Retire RootMove::nodes
[stockfish] / src / benchmark.cpp
index 551c341b1043df21dfc56d0a0c0cdecdae42a589..c186436e960dbbc08fc5daad5311eafa2786e867 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
@@ -28,7 +28,7 @@
 
 using namespace std;
 
-static const string Defaults[] = {
+static const char* Defaults[] = {
   "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
   "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 10",
   "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 11",
@@ -60,6 +60,7 @@ static const string Defaults[] = {
 void benchmark(int argc, char* argv[]) {
 
   vector<string> fenList;
+  Search::LimitsType limits;
   int64_t totalNodes;
   int time;
 
@@ -70,20 +71,23 @@ void benchmark(int argc, char* argv[]) {
   string fenFile = argc > 5 ? argv[5] : "default";
   string valType = argc > 6 ? argv[6] : "depth";
 
-  Options["Hash"].set_value(ttSize);
-  Options["Threads"].set_value(threads);
-  Options["OwnBook"].set_value("false");
+  Options["Hash"] = ttSize;
+  Options["Threads"] = threads;
+  Options["OwnBook"] = false;
 
   // Search should be limited by nodes, time or depth ?
   if (valType == "nodes")
-      Limits.maxNodes = atoi(valStr.c_str());
+      limits.maxNodes = atoi(valStr.c_str());
   else if (valType == "time")
-      Limits.maxTime = 1000 * atoi(valStr.c_str()); // maxTime is in ms
+      limits.maxTime = 1000 * atoi(valStr.c_str()); // maxTime is in ms
   else
-      Limits.maxDepth = atoi(valStr.c_str());
+      limits.maxDepth = atoi(valStr.c_str());
 
   // Do we need to load positions from a given FEN file?
-  if (fenFile != "default")
+  if (fenFile == "default")
+      for (int i = 0; *Defaults[i]; i++)
+          fenList.push_back(Defaults[i]);
+  else
   {
       string fen;
       ifstream f(fenFile.c_str());
@@ -100,39 +104,34 @@ void benchmark(int argc, char* argv[]) {
 
       f.close();
   }
-  else // Load default positions
-      for (int i = 0; !Defaults[i].empty(); i++)
-          fenList.push_back(Defaults[i]);
 
   // Ok, let's start the benchmark !
   totalNodes = 0;
-  time = get_system_time();
-  SearchMoves.push_back(MOVE_NONE);
+  time = system_time();
 
   for (size_t i = 0; i < fenList.size(); i++)
   {
       Position pos(fenList[i], false, 0);
-      RootPosition = &pos;
 
       cerr << "\nBench position: " << i + 1 << '/' << fenList.size() << endl;
 
       if (valType == "perft")
       {
-          int64_t cnt = perft(pos, Limits.maxDepth * ONE_PLY);
+          int64_t cnt = Search::perft(pos, limits.maxDepth * ONE_PLY);
 
-          cerr << "\nPerft " << Limits.maxDepth
+          cerr << "\nPerft " << limits.maxDepth
                << " nodes counted: " << cnt << endl;
 
           totalNodes += cnt;
       }
       else
       {
-          Threads.start_thinking(false);
-          totalNodes += pos.nodes_searched();
+          Threads.start_thinking(pos, limits, vector<Move>(), false);
+          totalNodes += Search::RootPosition.nodes_searched();
       }
   }
 
-  time = get_system_time() - time;
+  time = system_time() - time;
 
   cerr << "\n==============================="
        << "\nTotal time (ms) : " << time