]> git.sesse.net Git - stockfish/blobdiff - src/movepick.cpp
Unify History and Gains under a single Stats class
[stockfish] / src / movepick.cpp
index 005f85203e6a493f6540d2281b0c78a667bedf4b..e6b16cc495d238ff078324bf9057e85ca09aa6df 100644 (file)
@@ -18,7 +18,6 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <algorithm>
 #include <cassert>
 
 #include "movegen.h"
@@ -59,7 +58,7 @@ namespace {
 /// move ordering is at the current node.
 
 MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
-                       Search::Stack* s, Value beta) : pos(p), H(h), depth(d) {
+                       Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
 
   assert(d > DEPTH_ZERO);
 
@@ -68,7 +67,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
   endBadCaptures = moves + MAX_MOVES - 1;
   ss = s;
 
-  if (p.in_check())
+  if (p.checkers())
       phase = EVASION;
 
   else
@@ -79,12 +78,12 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
       killers[1].move = ss->killers[1];
 
       // Consider sligtly negative captures as good if at low depth and far from beta
-      if (ss && ss->eval < beta - PawnValueMg && d < 3 * ONE_PLY)
+      if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
           captureThreshold = -PawnValueMg;
 
       // Consider negative captures as good if still enough to reach beta
-      else if (ss && ss->eval > beta)
-          captureThreshold = beta - ss->eval;
+      else if (ss && ss->staticEval > beta)
+          captureThreshold = beta - ss->staticEval;
   }
 
   ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
@@ -92,11 +91,11 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 }
 
 MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
-                       Square sq) : pos(p), H(h), cur(moves), end(moves) {
+                       Square sq) : pos(p), Hist(h), cur(moves), end(moves) {
 
   assert(d <= DEPTH_ZERO);
 
-  if (p.in_check())
+  if (p.checkers())
       phase = EVASION;
 
   else if (d > DEPTH_QS_NO_CHECKS)
@@ -124,9 +123,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 }
 
 MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
-                       : pos(p), H(h), cur(moves), end(moves) {
+                       : pos(p), Hist(h), cur(moves), end(moves) {
 
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   phase = PROBCUT;
 
@@ -180,7 +179,7 @@ void MovePicker::score_noncaptures() {
   for (MoveStack* it = moves; it != end; ++it)
   {
       m = it->move;
-      it->score = H.value(pos.piece_moved(m), to_sq(m));
+      it->score = Hist[pos.piece_moved(m)][to_sq(m)];
   }
 }
 
@@ -198,12 +197,12 @@ void MovePicker::score_evasions() {
   {
       m = it->move;
       if ((seeScore = pos.see_sign(m)) < 0)
-          it->score = seeScore - History::MaxValue; // Be sure we are at the bottom
+          it->score = seeScore - History::Max; // Be sure we are at the bottom
       else if (pos.is_capture(m))
           it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
-                     - type_of(pos.piece_moved(m)) + History::MaxValue;
+                     - type_of(pos.piece_moved(m)) + History::Max;
       else
-          it->score = H.value(pos.piece_moved(m), to_sq(m));
+          it->score = Hist[pos.piece_moved(m)][to_sq(m)];
   }
 }