+ // ok_to_history() returns true if a move m can be stored
+ // in history. Should be a non capturing move.
+
+ bool ok_to_history(const Position& pos, Move m) {
+
+ return pos.square_is_empty(move_to(m))
+ && !move_promotion(m)
+ && !move_is_ep(m);
+ }
+
+
+ // update_history() registers a good move that produced a beta-cutoff
+ // in history and marks as failures all the other moves of that ply.
+
+ void update_history(const Position& pos, Move m, Depth depth,
+ Move movesSearched[], int moveCount) {
+
+ H.success(pos.piece_on(move_from(m)), m, depth);
+
+ for (int i = 0; i < moveCount - 1; i++)
+ if (ok_to_history(pos, movesSearched[i]) && m != movesSearched[i])
+ H.failure(pos.piece_on(move_from(movesSearched[i])), movesSearched[i]);
+ }
+