diff --git a/src/movepick.cpp b/src/movepick.cpp index 22845ba2..25cbdefd 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -244,7 +244,7 @@ void MovePicker::score_captures() { for (int i = 0; i < numOfMoves; i++) { m = moves[i].move; - seeValue = pos.see(m); + seeValue = pos.see_sign(m); if (seeValue >= 0) { if (move_is_promotion(m)) diff --git a/src/position.cpp b/src/position.cpp index 1179f6f9..8099764c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1474,6 +1474,22 @@ int Position::see(Move m) const { return see(move_from(m), move_to(m)); } +int Position::see_sign(Move m) const { + + assert(move_is_ok(m)); + + Square from = move_from(m); + Square to = move_to(m); + + // Early return if SEE cannot be negative because capturing piece value + // is not bigger then captured one. + if ( midgame_value_of_piece_on(from) <= midgame_value_of_piece_on(to) + && type_of_piece_on(from) != KING) + return 1; + + return see(from, to); +} + int Position::see(Square from, Square to) const { // Material values diff --git a/src/position.h b/src/position.h index 5fe1a8fd..97166360 100644 --- a/src/position.h +++ b/src/position.h @@ -267,6 +267,7 @@ public: int see(Square from, Square to) const; int see(Move m) const; int see(Square to) const; + int see_sign(Move m) const; // Accessing hash keys Key get_key() const; diff --git a/src/search.cpp b/src/search.cpp index 7e2f9727..e6495028 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1561,9 +1561,7 @@ namespace { // Don't search captures and checks with negative SEE values if ( !isCheck && !move_is_promotion(move) - && (pos.midgame_value_of_piece_on(move_from(move)) > - pos.midgame_value_of_piece_on(move_to(move))) - && pos.see(move) < 0) + && pos.see_sign(move) < 0) continue; // Make and search the move. @@ -2240,7 +2238,7 @@ namespace { if ( pvNode && capture && pos.type_of_piece_on(move_to(m)) != PAWN - && pos.see(m) >= 0) + && pos.see_sign(m) >= 0) { result += OnePly/2; *dangerous = true; @@ -2313,7 +2311,7 @@ namespace { && threat != MOVE_NONE && piece_is_slider(pos.piece_on(tfrom)) && bit_is_set(squares_between(tfrom, tto), mto) - && pos.see(m) >= 0) + && pos.see_sign(m) >= 0) return false; return true;