]> git.sesse.net Git - stockfish/commitdiff
Use a more standard perft UCI interface
authorMarco Costalba <mcostalba@gmail.com>
Fri, 13 Nov 2009 09:27:14 +0000 (10:27 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 13 Nov 2009 09:35:56 +0000 (10:35 +0100)
Call directly 'perft 6' to search up to depth 6*OnePly
instead of the old 'perft depth 6'.

It is more in line to what other engines do. Also a bit
of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp
src/uci.cpp

index 1786a6fdc60ebb235e708a7d7cfedaa63479987e..d654fec9c414a75be3fd6d406fdaf8fc24053613 100644 (file)
@@ -333,14 +333,14 @@ namespace {
 int perft(Position& pos, Depth depth)
 {
     Move move;
 int perft(Position& pos, Depth depth)
 {
     Move move;
-    MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
     int sum = 0;
     int sum = 0;
+    MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
 
     // If we are at the last ply we don't need to do and undo
     // the moves, just to count them.
     if (depth <= OnePly) // Replace with '<' to test also qsearch
     {
 
     // If we are at the last ply we don't need to do and undo
     // the moves, just to count them.
     if (depth <= OnePly) // Replace with '<' to test also qsearch
     {
-        while ((move = mp.get_next_move()) != MOVE_NONE) sum++;
+        while (mp.get_next_move()) sum++;
         return sum;
     }
 
         return sum;
     }
 
@@ -348,10 +348,10 @@ int perft(Position& pos, Depth depth)
     CheckInfo ci(pos);
     while ((move = mp.get_next_move()) != MOVE_NONE)
     {
     CheckInfo ci(pos);
     while ((move = mp.get_next_move()) != MOVE_NONE)
     {
-      StateInfo st;
-      pos.do_move(move, st, ci, pos.move_is_check(move, ci));
-      sum += perft(pos, depth - OnePly);
-      pos.undo_move(move);
+        StateInfo st;
+        pos.do_move(move, st, ci, pos.move_is_check(move, ci));
+        sum += perft(pos, depth - OnePly);
+        pos.undo_move(move);
     }
     return sum;
 }
     }
     return sum;
 }
index f6b27114b13d64f60fafbd24c74c9550b7053afe..69de2fb1fe4daa5bf43bbd1dc4136c05c6ebda22 100644 (file)
@@ -324,18 +324,17 @@ namespace {
   void perft(UCIInputParser& uip) {
 
     string token;
   void perft(UCIInputParser& uip) {
 
     string token;
-    int depth = 0;
+    int depth, tm, n;
+    Position pos = RootPosition;
 
 
-    while (!uip.eof())
-    {
-        uip >> token;
+    if (uip.eof())
+        return;
+
+    uip >> depth;
+    tm = get_system_time();
+
+    n = perft(pos, depth * OnePly);
 
 
-        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
     tm = get_system_time() - tm;
     std::cout << "\nNodes " << n
               << "\nTime (ms) " << tm