]> git.sesse.net Git - stockfish/commitdiff
Small trivial clean-ups, February 2021
authorLolligerhans <lolligerhans@gmx.de>
Sun, 31 Jan 2021 12:46:05 +0000 (13:46 +0100)
committerStéphane Nicolet <cassio@free.fr>
Tue, 16 Feb 2021 00:31:42 +0000 (01:31 +0100)
Closes https://github.com/official-stockfish/Stockfish/pull/3329

No functional change

src/Makefile
src/evaluate.cpp
src/movepick.cpp
src/position.cpp
src/search.cpp

index 1ff03f8391acca25bc4e3c5af9938d3408aa062d..eb32758f98de016e6fa795ade98f47103646558d 100644 (file)
@@ -1,7 +1,5 @@
 # Stockfish, a UCI chess playing engine derived from Glaurung 2.1
 # Stockfish, a UCI chess playing engine derived from Glaurung 2.1
-# Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-# Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
-# Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
+# Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
 #
 # Stockfish is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 #
 # Stockfish is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
index 0b2112612a77449947690c0495be3ad13f5e8659..d55ef695b75f45e51f91eeed22990adecbd2d669 100644 (file)
@@ -423,7 +423,6 @@ namespace {
             score += BishopOnKingRing;
 
         int mob = popcount(b & mobilityArea[Us]);
             score += BishopOnKingRing;
 
         int mob = popcount(b & mobilityArea[Us]);
-
         mobility[Us] += MobilityBonus[Pt - 2][mob];
 
         if (Pt == BISHOP || Pt == KNIGHT)
         mobility[Us] += MobilityBonus[Pt - 2][mob];
 
         if (Pt == BISHOP || Pt == KNIGHT)
index f5b274966dae68bb8bcc52142d183ecad219e91d..0ceeb8eaf60794bfc2df804468955131ef2a9a76 100644 (file)
@@ -99,11 +99,11 @@ void MovePicker::score() {
   static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
 
   for (auto& m : *this)
   static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
 
   for (auto& m : *this)
-      if (Type == CAPTURES)
+      if constexpr (Type == CAPTURES)
           m.value =  int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
                    + (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];
 
           m.value =  int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
                    + (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];
 
-      else if (Type == QUIETS)
+      else if constexpr (Type == QUIETS)
           m.value =      (*mainHistory)[pos.side_to_move()][from_to(m)]
                    + 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
                    +     (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
           m.value =      (*mainHistory)[pos.side_to_move()][from_to(m)]
                    + 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
                    +     (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
index 35e307efcbce58e2581cc0ccb37baea5e0e47d1a..2eb30ca0d2a6d5536f3f4dc6d315bb9cd6d0de66 100644 (file)
@@ -268,8 +268,8 @@ Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Th
       enpassant = pawn_attacks_bb(~sideToMove, st->epSquare) & pieces(sideToMove, PAWN)
                && (pieces(~sideToMove, PAWN) & (st->epSquare + pawn_push(~sideToMove)))
                && !(pieces() & (st->epSquare | (st->epSquare + pawn_push(sideToMove))))
       enpassant = pawn_attacks_bb(~sideToMove, st->epSquare) & pieces(sideToMove, PAWN)
                && (pieces(~sideToMove, PAWN) & (st->epSquare + pawn_push(~sideToMove)))
                && !(pieces() & (st->epSquare | (st->epSquare + pawn_push(sideToMove))))
-               && (file_of(square<KING>(sideToMove)) == file_of(st->epSquare)
-               || !(blockers_for_king(sideToMove) & (st->epSquare + pawn_push(~sideToMove))));
+               && (   file_of(square<KING>(sideToMove)) == file_of(st->epSquare)
+                   || !(blockers_for_king(sideToMove) & (st->epSquare + pawn_push(~sideToMove))));
   }
 
   // It's necessary for st->previous to be intialized in this way because legality check relies on its existence
   }
 
   // It's necessary for st->previous to be intialized in this way because legality check relies on its existence
@@ -518,8 +518,8 @@ bool Position::legal(Move m) const {
   // st->previous->blockersForKing consider capsq as empty.
   // If pinned, it has to move along the king ray.
   if (type_of(m) == EN_PASSANT)
   // st->previous->blockersForKing consider capsq as empty.
   // If pinned, it has to move along the king ray.
   if (type_of(m) == EN_PASSANT)
-      return !(st->previous->blockersForKing[sideToMove] & from) ||
-               aligned(from, to, square<KING>(us));
+      return   !(st->previous->blockersForKing[sideToMove] & from)
+            || aligned(from, to, square<KING>(us));
 
   // Castling moves generation does not check if the castling path is clear of
   // enemy attacks, it is delayed at a later time: now!
 
   // Castling moves generation does not check if the castling path is clear of
   // enemy attacks, it is delayed at a later time: now!
@@ -546,8 +546,8 @@ bool Position::legal(Move m) const {
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
-  return   !(blockers_for_king(us) & from)
-        ||  aligned(from, to, square<KING>(us));
+  return !(blockers_for_king(us) & from)
+      || aligned(from, to, square<KING>(us));
 }
 
 
 }
 
 
@@ -657,8 +657,9 @@ bool Position::gives_check(Move m) const {
   // So the King must be in the same rank as fromsq to consider this possibility.
   // st->previous->blockersForKing consider capsq as empty.
   case EN_PASSANT:
   // So the King must be in the same rank as fromsq to consider this possibility.
   // st->previous->blockersForKing consider capsq as empty.
   case EN_PASSANT:
-      return st->previous->checkersBB || (rank_of(square<KING>(~sideToMove)) == rank_of(from)
-          && st->previous->blockersForKing[~sideToMove] & from);
+      return st->previous->checkersBB
+          || (   rank_of(square<KING>(~sideToMove)) == rank_of(from)
+              && st->previous->blockersForKing[~sideToMove] & from);
 
   default: //CASTLING
   {
 
   default: //CASTLING
   {
index d77ab691d62b34d68e678801c120ae4d607fbbf5..b5d21b9d5585c2cfbeed24a6470f9df69c8aa907 100644 (file)
@@ -1025,12 +1025,12 @@ moves_loop: // When in check, search starts from here
       movedPiece = pos.moved_piece(move);
       givesCheck = pos.gives_check(move);
 
       movedPiece = pos.moved_piece(move);
       givesCheck = pos.gives_check(move);
 
-      // Indicate PvNodes that will probably fail low if node was searched with non-PV search 
+      // Indicate PvNodes that will probably fail low if node was searched with non-PV search
       // at depth equal or greater to current depth and result of this search was far below alpha
       // at depth equal or greater to current depth and result of this search was far below alpha
-      bool likelyFailLow =    PvNode 
-                           && ttMove 
-                           && (tte->bound() & BOUND_UPPER) 
-                           && ttValue < alpha + 200 + 100 * depth 
+      bool likelyFailLow =    PvNode
+                           && ttMove
+                           && (tte->bound() & BOUND_UPPER)
+                           && ttValue < alpha + 200 + 100 * depth
                            && tte->depth() >= depth;
 
       // Calculate new depth for this move
                            && tte->depth() >= depth;
 
       // Calculate new depth for this move
@@ -1180,8 +1180,8 @@ moves_loop: // When in check, search starts from here
           if (th.marked())
               r++;
 
           if (th.marked())
               r++;
 
-          // Decrease reduction if position is or has been on the PV 
-          // and node is not likely to fail low (~10 Elo)
+          // Decrease reduction if position is or has been on the PV
+          // and node is not likely to fail low. (~10 Elo)
           if (ss->ttPv && !likelyFailLow)
               r -= 2;
 
           if (ss->ttPv && !likelyFailLow)
               r -= 2;