mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 23:56:23 +08:00
Introduce see_sign() and use it to shortcut full see()
Mostly of times we are interested only in the sign of SEE, namely if a capture is negative or not. If the capturing piece is smaller then the captured one we already know SEE cannot be negative and this information is enough most of the times. And of course it is much faster to detect then a full SEE. Note that in case see_sign() is negative then the returned value is exactly the see() value, this is very important, especially for ordering capturing moves. With this patch the calls to the costly see() are reduced of almost 30%. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user