]> git.sesse.net Git - stockfish/commitdiff
Slightly change split() API
authorMarco Costalba <mcostalba@gmail.com>
Tue, 5 Feb 2013 05:30:05 +0000 (06:30 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 5 Feb 2013 05:35:38 +0000 (06:35 +0100)
This function "returns" two values: bestValue and bestMove

Instead of returning one and passing as pointer the other
be consistent and pass as pointers both.

No functional change.

src/search.cpp
src/thread.cpp
src/thread.h

index 84c62eec33081a422b10c66eb2462fff5b673b69..5e61b9e583318c99703229b81188c22e45e61c8b 100644 (file)
@@ -1030,8 +1030,8 @@ split_point_start: // At split points actual search starts from here
       {
           assert(bestValue < beta);
 
       {
           assert(bestValue < beta);
 
-          bestValue = thisThread->split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove,
-                                                   depth, threatMove, moveCount, mp, NT);
+          thisThread->split<FakeSplit>(pos, ss, alpha, beta, &bestValue, &bestMove,
+                                       depth, threatMove, moveCount, &mp, NT);
           if (bestValue >= beta)
               break;
       }
           if (bestValue >= beta)
               break;
       }
index 1c5c67bacfc2b587a5bac6f6f56fd84316aaa1bf..b04b8adbb1719e586e818e366b2077fdc01053ab 100644 (file)
@@ -249,15 +249,14 @@ bool ThreadPool::slave_available(Thread* master) const {
 // search() then split() returns.
 
 template <bool Fake>
 // search() then split() returns.
 
 template <bool Fake>
-Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta,
-                    Value bestValue, Move* bestMove, Depth depth, Move threatMove,
-                    int moveCount, MovePicker& mp, int nodeType) {
+void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bestValue,
+                   Move* bestMove, Depth depth, Move threatMove, int moveCount,
+                   MovePicker* movePicker, int nodeType) {
 
   assert(pos.pos_is_ok());
 
   assert(pos.pos_is_ok());
-  assert(bestValue <= alpha && alpha < beta && beta <= VALUE_INFINITE);
-  assert(bestValue > -VALUE_INFINITE);
+  assert(*bestValue <= alpha && alpha < beta && beta <= VALUE_INFINITE);
+  assert(*bestValue > -VALUE_INFINITE);
   assert(depth >= Threads.minimumSplitDepth);
   assert(depth >= Threads.minimumSplitDepth);
-
   assert(searching);
   assert(splitPointsSize < MAX_SPLITPOINTS_PER_THREAD);
 
   assert(searching);
   assert(splitPointsSize < MAX_SPLITPOINTS_PER_THREAD);
 
@@ -268,13 +267,13 @@ Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta,
   sp.parentSplitPoint = activeSplitPoint;
   sp.slavesMask = 1ULL << idx;
   sp.depth = depth;
   sp.parentSplitPoint = activeSplitPoint;
   sp.slavesMask = 1ULL << idx;
   sp.depth = depth;
+  sp.bestValue = *bestValue;
   sp.bestMove = *bestMove;
   sp.threatMove = threatMove;
   sp.alpha = alpha;
   sp.beta = beta;
   sp.nodeType = nodeType;
   sp.bestMove = *bestMove;
   sp.threatMove = threatMove;
   sp.alpha = alpha;
   sp.beta = beta;
   sp.nodeType = nodeType;
-  sp.bestValue = bestValue;
-  sp.movePicker = &mp;
+  sp.movePicker = movePicker;
   sp.moveCount = moveCount;
   sp.pos = &pos;
   sp.nodes = 0;
   sp.moveCount = moveCount;
   sp.pos = &pos;
   sp.nodes = 0;
@@ -332,16 +331,15 @@ Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta,
   activeSplitPoint = sp.parentSplitPoint;
   pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
   *bestMove = sp.bestMove;
   activeSplitPoint = sp.parentSplitPoint;
   pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
   *bestMove = sp.bestMove;
+  *bestValue = sp.bestValue;
 
   sp.mutex.unlock();
   Threads.mutex.unlock();
 
   sp.mutex.unlock();
   Threads.mutex.unlock();
-
-  return sp.bestValue;
 }
 
 // Explicit template instantiations
 }
 
 // Explicit template instantiations
-template Value Thread::split<false>(Position&, Stack*, Value, Value, Value, Move*, Depth, Move, int, MovePicker&, int);
-template Value Thread::split<true>(Position&, Stack*, Value, Value, Value, Move*, Depth, Move, int, MovePicker&, int);
+template void Thread::split<false>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int);
+template void Thread::split< true>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int);
 
 
 // wait_for_think_finished() waits for main thread to go to sleep then returns
 
 
 // wait_for_think_finished() waits for main thread to go to sleep then returns
index 786c5b677c1934a2dfd0c9aa6ab09870f87b052b..b18170dfcccfa9b29b1bf4f011747142e48e3166 100644 (file)
@@ -103,8 +103,8 @@ struct Thread {
   void wait_for(volatile const bool& b);
 
   template <bool Fake>
   void wait_for(volatile const bool& b);
 
   template <bool Fake>
-  Value split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value bestValue, Move* bestMove,
-              Depth depth, Move threatMove, int moveCount, MovePicker& mp, int nodeType);
+  void split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
+             Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType);
 
   SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
   Material::Table materialTable;
 
   SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
   Material::Table materialTable;