]> git.sesse.net Git - stockfish/blobdiff - src/movepick.h
Remove Stack/thread dependence in movepick
[stockfish] / src / movepick.h
index a7cac4ba85ba64c03ceb29f64a0aa2eca7d5a939..afd573ea459badabd1aa208b5d6dd498d49d455b 100644 (file)
@@ -49,14 +49,14 @@ typedef StatBoards<PIECE_NB, SQUARE_NB> PieceToBoards;
 /// ordering decisions. It uses ButterflyBoards as backing store.
 struct ButterflyHistory : public ButterflyBoards {
 
-  void update(Color c, Move m, int v) {
+  void update(Color c, Move m, int bonus) {
 
     const int D = 324;
     auto& entry = (*this)[c][from_to(m)];
 
-    assert(abs(v) <= D); // Consistency check for below formula
+    assert(abs(bonus) <= D); // Consistency check for below formula
 
-    entry += v * 32 - entry * abs(v) / D;
+    entry += bonus * 32 - entry * abs(bonus) / D;
 
     assert(abs(entry) <= 32 * D);
   }
@@ -65,26 +65,27 @@ struct ButterflyHistory : public ButterflyBoards {
 /// PieceToHistory is like ButterflyHistory, but is based on PieceToBoards
 struct PieceToHistory : public PieceToBoards {
 
-  void update(Piece pc, Square to, int v) {
+  void update(Piece pc, Square to, int bonus) {
 
     const int D = 936;
     auto& entry = (*this)[pc][to];
 
-    assert(abs(v) <= D); // Consistency check for below formula
+    assert(abs(bonus) <= D); // Consistency check for below formula
 
-    entry += v * 32 - entry * abs(v) / D;
+    entry += bonus * 32 - entry * abs(bonus) / D;
 
     assert(abs(entry) <= 32 * D);
   }
 };
 
-/// CounterMoveStat stores counter moves indexed by [piece][to] of the previous
+/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
 /// move, see chessprogramming.wikispaces.com/Countermove+Heuristic
-typedef StatBoards<PIECE_NB, SQUARE_NB, Move> CounterMoveStat;
+typedef StatBoards<PIECE_NB, SQUARE_NB, Move> CounterMoveHistory;
 
-/// CounterMoveHistoryStat is like CounterMoveStat but instead of a move it
-/// stores a full history (based on PieceTo boards instead of ButterflyBoards).
-typedef StatBoards<PIECE_NB, SQUARE_NB, PieceToHistory> CounterMoveHistoryStat;
+/// ContinuationHistory is the history of a given pair of moves, usually the
+/// current one given a previous one. History table is based on PieceToBoards
+/// instead of ButterflyBoards.
+typedef StatBoards<PIECE_NB, SQUARE_NB, PieceToHistory> ContinuationHistory;
 
 
 /// MovePicker class is used to pick one pseudo legal move at a time from the
@@ -93,17 +94,14 @@ typedef StatBoards<PIECE_NB, SQUARE_NB, PieceToHistory> CounterMoveHistoryStat;
 /// when MOVE_NONE is returned. In order to improve the efficiency of the alpha
 /// beta algorithm, MovePicker attempts to return the moves which are most likely
 /// to get a cut-off first.
-namespace Search { struct Stack; }
 
 class MovePicker {
 public:
   MovePicker(const MovePicker&) = delete;
   MovePicker& operator=(const MovePicker&) = delete;
-
   MovePicker(const Position&, Move, Value);
-  MovePicker(const Position&, Move, Depth, Square);
-  MovePicker(const Position&, Move, Depth, Search::Stack*);
-
+  MovePicker(const Position&, Move, Depth, const ButterflyHistory*, const PieceToHistory**, Square);
+  MovePicker(const Position&, Move, Depth, const ButterflyHistory*, const PieceToHistory**, Move, Move*);
   Move next_move(bool skipQuiets = false);
 
 private:
@@ -112,15 +110,14 @@ private:
   ExtMove* end() { return endMoves; }
 
   const Position& pos;
-  const Search::Stack* ss;
-  Move killers[2];
-  Move countermove;
-  Depth depth;
-  Move ttMove;
+  const ButterflyHistory* mainHistory;
+  const PieceToHistory** contHistory;
+  Move ttMove, countermove, killers[2];
+  ExtMove *cur, *endMoves, *endBadCaptures;
+  int stage;
   Square recaptureSquare;
   Value threshold;
-  int stage;
-  ExtMove *cur, *endMoves, *endBadCaptures;
+  Depth depth;
   ExtMove moves[MAX_MOVES];
 };