]> git.sesse.net Git - stockfish/commitdiff
Retire history.cpp
authorMarco Costalba <mcostalba@gmail.com>
Sat, 15 Jan 2011 08:49:03 +0000 (09:49 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 15 Jan 2011 09:02:45 +0000 (10:02 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/Makefile
src/history.cpp [deleted file]
src/history.h
src/search.cpp

index 513e3257573a363f32639409e6b5595eef5f3961..549b7867cbd8d53ab15f31f0400ce65198d2b8fd 100644 (file)
@@ -32,7 +32,7 @@ PGOBENCH = ./$(EXE) bench 32 1 10 default depth
 
 ### Object files
 OBJS = bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
 
 ### Object files
 OBJS = bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
-       misc.o move.o movegen.o history.o movepick.o search.o position.o \
+       misc.o move.o movegen.o movepick.o search.o position.o \
        tt.o uci.o ucioption.o book.o bitbase.o benchmark.o timeman.o
 
 
        tt.o uci.o ucioption.o book.o bitbase.o benchmark.o timeman.o
 
 
diff --git a/src/history.cpp b/src/history.cpp
deleted file mode 100644 (file)
index f10e761..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
-  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
-
-  Stockfish is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation, either version 3 of the License, or
-  (at your option) any later version.
-
-  Stockfish is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-////
-//// Includes
-////
-
-#include <cassert>
-#include <cstring>
-
-#include "history.h"
-
-
-////
-//// Functions
-////
-
-
-/// Constructor
-
-History::History() { clear(); }
-
-
-/// History::clear() clears the history tables
-
-void History::clear() {
-  memset(history, 0, 16 * 64 * sizeof(int));
-  memset(maxStaticValueDelta, 0, 16 * 64 * sizeof(int));
-}
-
-
-/// History::success() registers a move as being successful. This is done
-/// whenever a non-capturing move causes a beta cutoff in the main search.
-/// The three parameters are the moving piece, the destination square, and
-/// the search depth.
-
-void History::success(Piece p, Square to, Depth d) {
-
-  assert(piece_is_ok(p));
-  assert(square_is_ok(to));
-
-  history[p][to] += int(d) * int(d);
-}
-
-
-/// History::failure() registers a move as being unsuccessful. The function is
-/// called for each non-capturing move which failed to produce a beta cutoff
-/// at a node where a beta cutoff was finally found.
-
-void History::failure(Piece p, Square to, Depth d) {
-
-  assert(piece_is_ok(p));
-  assert(square_is_ok(to));
-
-  history[p][to] -= int(d) * int(d);
-}
-
-
-/// History::set_gain() and History::gain() store and retrieve the
-/// gain of a move given the delta of the static position evaluations
-/// before and after the move.
-
-void History::set_gain(Piece p, Square to, Value delta) {
-
-  if (delta >= maxStaticValueDelta[p][to])
-      maxStaticValueDelta[p][to] = delta;
-  else
-      maxStaticValueDelta[p][to]--;
-}
index bbe2aab3fffb8302d81f90afbda1c7eb71786814..9206cdf4bc7d8a45ad34612e12244ec23a55dcc2 100644 (file)
@@ -20,6 +20,8 @@
 #if !defined(HISTORY_H_INCLUDED)
 #define HISTORY_H_INCLUDED
 
 #if !defined(HISTORY_H_INCLUDED)
 #define HISTORY_H_INCLUDED
 
+#include <cstring>
+
 #include "depth.h"
 #include "move.h"
 #include "piece.h"
 #include "depth.h"
 #include "move.h"
 #include "piece.h"
 class History {
 
 public:
 class History {
 
 public:
-  History();
+  History() { clear(); }
   void clear();
   void clear();
-  void success(Piece p, Square to, Depth d);
-  void failure(Piece p, Square to, Depth d);
   int value(Piece p, Square to) const;
   int value(Piece p, Square to) const;
-  void set_gain(Piece p, Square to, Value delta);
+  void update(Piece p, Square to, Value delta);
   Value gain(Piece p, Square to) const;
   Value gain(Piece p, Square to) const;
+  void update_gain(Piece p, Square to, Value delta);
 
 private:
 
 private:
-  int history[16][64];  // [piece][square]
-  int maxStaticValueDelta[16][64];  // [piece][from_square][to_square]
+  Value history[16][64];  // [piece][to_square]
+  Value maxGains[16][64]; // [piece][to_square]
 };
 
 };
 
+inline void History::clear() {
+  memset(history,  0, 16 * 64 * sizeof(int));
+  memset(maxGains, 0, 16 * 64 * sizeof(int));
+}
+
 inline int History::value(Piece p, Square to) const {
   return history[p][to];
 }
 
 inline int History::value(Piece p, Square to) const {
   return history[p][to];
 }
 
+inline void History::update(Piece p, Square to, Value bonus) {
+  history[p][to] += bonus;
+}
+
 inline Value History::gain(Piece p, Square to) const {
 inline Value History::gain(Piece p, Square to) const {
-  return Value(maxStaticValueDelta[p][to]);
+  return maxGains[p][to];
+}
+
+inline void History::update_gain(Piece p, Square to, Value gain) {
+
+  if (gain >= maxGains[p][to])
+      maxGains[p][to] = gain;
+  else
+      maxGains[p][to]--;
 }
 
 #endif // !defined(HISTORY_H_INCLUDED)
 }
 
 #endif // !defined(HISTORY_H_INCLUDED)
index 1a8e9ea74156ec5a084a5b5d82dd8d953f4d34a8..370889cca3c2ecd6a3196a2374d3dd2854c1b258 100644 (file)
@@ -1909,8 +1909,9 @@ split_point_start: // At split points actual search starts from here
   void update_history(const Position& pos, Move move, Depth depth,
                       Move movesSearched[], int moveCount) {
     Move m;
   void update_history(const Position& pos, Move move, Depth depth,
                       Move movesSearched[], int moveCount) {
     Move m;
+    Value bonus = Value(int(depth) * int(depth));
 
 
-    H.success(pos.piece_on(move_from(move)), move_to(move), depth);
+    H.update(pos.piece_on(move_from(move)), move_to(move), bonus);
 
     for (int i = 0; i < moveCount - 1; i++)
     {
 
     for (int i = 0; i < moveCount - 1; i++)
     {
@@ -1919,7 +1920,7 @@ split_point_start: // At split points actual search starts from here
         assert(m != move);
 
         if (!pos.move_is_capture_or_promotion(m))
         assert(m != move);
 
         if (!pos.move_is_capture_or_promotion(m))
-            H.failure(pos.piece_on(move_from(m)), move_to(m), depth);
+            H.update(pos.piece_on(move_from(m)), move_to(m), -bonus);
     }
   }
 
     }
   }
 
@@ -1947,7 +1948,7 @@ split_point_start: // At split points actual search starts from here
         && after != VALUE_NONE
         && pos.captured_piece_type() == PIECE_TYPE_NONE
         && !move_is_special(m))
         && after != VALUE_NONE
         && pos.captured_piece_type() == PIECE_TYPE_NONE
         && !move_is_special(m))
-        H.set_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
+        H.update_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
   }
 
 
   }