]> git.sesse.net Git - stockfish/blobdiff - src/movepick.cpp
Retire history.h
[stockfish] / src / movepick.cpp
index ba99df0d1262fd7edffe0f03d0f68240d47c03bc..e2bb974170a00afc11a10a1a625166f591dae4a7 100644 (file)
@@ -52,6 +52,23 @@ namespace {
 }
 
 
+/// History class method definitions
+
+void History::clear() {
+  memset(history, 0, sizeof(history));
+  memset(gains, 0, sizeof(gains));
+}
+
+void History::update(Piece p, Square to, Value bonus) {
+  if (abs(history[p][to] + bonus) < History::Max)
+      history[p][to] += bonus;
+}
+
+void History::update_gain(Piece p, Square to, Value gain) {
+  gains[p][to] = std::max(gain, gains[p][to] - 1);
+}
+
+
 /// Constructors of the MovePicker class. As arguments we pass information
 /// to help it to return the presumably good moves first, to decide which
 /// moves to return (in the quiescence search, for instance, we only want to
@@ -68,7 +85,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
@@ -96,7 +113,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 
   assert(d <= DEPTH_ZERO);
 
-  if (p.in_check())
+  if (p.checkers())
       phase = EVASION;
 
   else if (d > DEPTH_QS_NO_CHECKS)
@@ -126,7 +143,7 @@ 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) {
 
-  assert(!pos.in_check());
+  assert(!pos.checkers());
 
   phase = PROBCUT;
 
@@ -180,7 +197,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 = H[pos.piece_moved(m)][to_sq(m)];
   }
 }
 
@@ -198,12 +215,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 = H[pos.piece_moved(m)][to_sq(m)];
   }
 }