]> git.sesse.net Git - stockfish/blobdiff - src/movepick.h
Join common code in the stages of next_move()
[stockfish] / src / movepick.h
index f9403f0f63940f446d974434018c534c3a022c97..0ad72933001384edace7698fdd4bb3a7d65f0001 100644 (file)
@@ -49,7 +49,7 @@ public:
   void operator<<(int bonus) {
 
     assert(abs(bonus) <= D); // Ensure range is [-W * D, W * D]
-    assert(abs(W * D) < std::numeric_limits<T>::max()); // Ensure we don't overflow
+    assert(W * D < std::numeric_limits<T>::max()); // Ensure we don't overflow
 
     entry += bonus * W - entry * abs(bonus) / D;
 
@@ -110,6 +110,8 @@ typedef Stats<PieceToHistory, W32, NOT_USED, PIECE_NB, SQUARE_NB> ContinuationHi
 /// beta algorithm, MovePicker attempts to return the moves which are most likely
 /// to get a cut-off first.
 
+enum PickType { NEXT, BEST_SCORE };
+
 class MovePicker {
 public:
   MovePicker(const MovePicker&) = delete;
@@ -120,6 +122,7 @@ public:
   Move next_move(bool skipQuiets = false);
 
 private:
+  template<PickType T, typename Pred> Move select_move(Pred);
   template<GenType> void score();
   ExtMove* begin() { return cur; }
   ExtMove* end() { return endMoves; }
@@ -131,6 +134,7 @@ private:
   Move ttMove, refutations[3];
   ExtMove *cur, *endMoves, *endBadCaptures;
   int stage;
+  Move move;
   Square recaptureSquare;
   Value threshold;
   Depth depth;