/// search captures, promotions and some checks) and how important good move
/// ordering is at the current node.
-MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
- Move* cm, Move* fm, Search::Stack* s) : pos(p), history(h), depth(d) {
+MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, const CounterMovesHistoryStats& cmh,
+ Move* cm, Move* fm, Search::Stack* s) : pos(p), history(h), counterMovesHistory(cmh), depth(d) {
assert(d > DEPTH_ZERO);
endMoves += (ttMove != MOVE_NONE);
}
-MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
- Square s) : pos(p), history(h) {
+MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, const CounterMovesHistoryStats& cmh,
+ Square s) : pos(p), history(h), counterMovesHistory(cmh) {
assert(d <= DEPTH_ZERO);
endMoves += (ttMove != MOVE_NONE);
}
-MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, PieceType pt)
- : pos(p), history(h) {
+MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, const CounterMovesHistoryStats& cmh, PieceType pt)
+ : pos(p), history(h), counterMovesHistory(cmh) {
assert(!pos.checkers());
template<>
void MovePicker::score<QUIETS>() {
+
+ Square prevSq = to_sq((ss-1)->currentMove);
+ const HistoryStats& cmh = counterMovesHistory[pos.piece_on(prevSq)][prevSq];
+
for (auto& m : *this)
- m.value = history[pos.moved_piece(m)][to_sq(m)];
+ m.value = history[pos.moved_piece(m)][to_sq(m)]
+ + cmh[pos.moved_piece(m)][to_sq(m)];
}
template<>