X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=3baf4f700b59cd52ab30c5a13d625bdbecd2027e;hp=b3f413bf1ffa0bd20255ccd5f25893839dfd1e45;hb=6c4257520847f7bb0f4008dedb65159cbacce106;hpb=0da7295795448fc826cb5b2613ac64a6e0c4adcd diff --git a/src/movepick.cpp b/src/movepick.cpp index b3f413bf..3baf4f70 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -67,14 +67,13 @@ namespace { /// 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, Search::Stack* s) : pos(p), history(h), counterMovesHistory(cmh), depth(d) { assert(d > DEPTH_ZERO); endBadCaptures = moves + MAX_MOVES - 1; countermoves = cm; - followupmoves = fm; ss = s; if (pos.checkers()) @@ -87,8 +86,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& 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); @@ -112,8 +111,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& 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()); @@ -162,8 +161,13 @@ void MovePicker::score() { template<> void MovePicker::score() { + + 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<> @@ -206,9 +210,8 @@ void MovePicker::generate_next_stage() { killers[0] = ss->killers[0]; killers[1] = ss->killers[1]; killers[2].move = killers[3].move = MOVE_NONE; - killers[4].move = killers[5].move = MOVE_NONE; - // In SMP case countermoves[] and followupmoves[] could have duplicated entries + // In SMP case countermoves[] could have duplicated entries // in rare cases (less than 1 out of a million). This is harmless. // Be sure countermoves and followupmoves are different from killers @@ -216,13 +219,6 @@ void MovePicker::generate_next_stage() { if ( countermoves[i] != killers[0] && countermoves[i] != killers[1]) *endMoves++ = countermoves[i]; - - for (int i = 0; i < 2; ++i) - if ( followupmoves[i] != killers[0] - && followupmoves[i] != killers[1] - && followupmoves[i] != killers[2] - && followupmoves[i] != killers[3]) - *endMoves++ = followupmoves[i]; break; case QUIETS_1_S1: @@ -316,9 +312,7 @@ Move MovePicker::next_move() { && move != killers[0] && move != killers[1] && move != killers[2] - && move != killers[3] - && move != killers[4] - && move != killers[5]) + && move != killers[3]) return move; break;