X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=6bb5c315554abab89fe17896af79e7427af2e980;hp=650218f48f468f4d36bbae33a6167c219c890d70;hb=e6f2d43b8a02aeb0180466d75be425800ec7c24d;hpb=6fe36d13de0ec25a8d35ca256dacee8b854856be diff --git a/src/movepick.cpp b/src/movepick.cpp index 650218f4..6bb5c315 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -136,7 +136,7 @@ void MovePicker::go_next_phase() { case PH_NONCAPTURES: lastMove = generate_noncaptures(pos, moves); score_noncaptures(); - sort_moves(moves, lastMove); + sort_moves(moves, lastMove, &lastGoodNonCapture); return; case PH_BAD_CAPTURES: @@ -213,6 +213,7 @@ void MovePicker::score_noncaptures() { Move m; Piece piece; Square from, to; + int hs; for (MoveStack* cur = moves; cur != lastMove; cur++) { @@ -220,7 +221,14 @@ void MovePicker::score_noncaptures() { from = move_from(m); to = move_to(m); piece = pos.piece_on(from); - cur->score = H.move_ordering_score(piece, to); + hs = H.move_ordering_score(piece, to); + + // Ensure history has always highest priority + if (hs > 0) + hs += 10000; + + // Gain table based scoring + cur->score = hs + 16 * H.gain(piece, to); } } @@ -305,6 +313,11 @@ Move MovePicker::get_next_move() { break; case PH_NONCAPTURES: + + // Sort negative scored moves only when we get there + if (curMove == lastGoodNonCapture) + insertion_sort(lastGoodNonCapture, lastMove); + move = (curMove++)->move; if ( move != ttMoves[0].move && move != ttMoves[1].move