]> git.sesse.net Git - stockfish/commitdiff
Small simplication of see_ge()
authorsyzygy <syzygy@server.fake>
Sun, 3 Sep 2017 20:02:49 +0000 (22:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 5 Sep 2017 08:57:10 +0000 (10:57 +0200)
Two simplifications:

- Remove the initialisation to 0 of occupied, which is now unnecessary.
- Remove the initial check for nextVictim == KING

If nextVictim == KING, then PieceValue[MG][nextVictim] will be 0, so that
balance >= threshold is true. So see_ge() returns true anyway.

No functional change.

src/position.cpp

index bda83d7a138f8a6dc8c80b7b99a8bb75382e9d36..b6dc31b4ed0cfa6271d719da333f3c4d94a4ad05 100644 (file)
@@ -1004,21 +1004,17 @@ bool Position::see_ge(Move m, Value threshold) const {
   Bitboard occupied, stmAttackers;
 
   balance = PieceValue[MG][piece_on(to)];
-  occupied = 0;
 
   if (balance < threshold)
       return false;
 
-  if (nextVictim == KING)
-      return true;
-
   balance -= PieceValue[MG][nextVictim];
 
-  if (balance >= threshold)
+  if (balance >= threshold) // Always true if nextVictim == KING
       return true;
 
   bool relativeStm = true; // True if the opponent is to move
-  occupied ^= pieces() ^ from ^ to;
+  occupied = pieces() ^ from ^ to;
 
   // Find all attackers to the destination square, with the moving piece removed,
   // but possibly an X-ray attacker added behind it.