mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 08:37:44 +00:00
apply if constexpr to additional instances
as a form of documentation, and a hint to the compiler. closes https://github.com/official-stockfish/Stockfish/pull/4345 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
734315ff30
commit
a2038c1a01
@@ -101,6 +101,7 @@ Jerry Donald Watson (jerrydonaldwatson)
|
|||||||
jjoshua2
|
jjoshua2
|
||||||
Jonathan Calovski (Mysseno)
|
Jonathan Calovski (Mysseno)
|
||||||
Jonathan Buladas Dumale (SFisGOD)
|
Jonathan Buladas Dumale (SFisGOD)
|
||||||
|
Jonathan McDermid (jonathanmcdermid)
|
||||||
Joost VandeVondele (vondele)
|
Joost VandeVondele (vondele)
|
||||||
Jörg Oster (joergoster)
|
Jörg Oster (joergoster)
|
||||||
Joseph Ellis (jhellis3)
|
Joseph Ellis (jhellis3)
|
||||||
|
|||||||
+5
-5
@@ -388,10 +388,10 @@ namespace {
|
|||||||
template<Tracing T> template<Color Us, PieceType Pt>
|
template<Tracing T> template<Color Us, PieceType Pt>
|
||||||
Score Evaluation<T>::pieces() {
|
Score Evaluation<T>::pieces() {
|
||||||
|
|
||||||
constexpr Color Them = ~Us;
|
constexpr Color Them = ~Us;
|
||||||
constexpr Direction Down = -pawn_push(Us);
|
[[maybe_unused]] constexpr Direction Down = -pawn_push(Us);
|
||||||
constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
|
[[maybe_unused]] constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
|
||||||
: Rank5BB | Rank4BB | Rank3BB);
|
: Rank5BB | Rank4BB | Rank3BB);
|
||||||
Bitboard b1 = pos.pieces(Us, Pt);
|
Bitboard b1 = pos.pieces(Us, Pt);
|
||||||
Bitboard b, bb;
|
Bitboard b, bb;
|
||||||
Score score = SCORE_ZERO;
|
Score score = SCORE_ZERO;
|
||||||
@@ -430,7 +430,7 @@ namespace {
|
|||||||
int mob = popcount(b & mobilityArea[Us]);
|
int mob = popcount(b & mobilityArea[Us]);
|
||||||
mobility[Us] += MobilityBonus[Pt - 2][mob];
|
mobility[Us] += MobilityBonus[Pt - 2][mob];
|
||||||
|
|
||||||
if (Pt == BISHOP || Pt == KNIGHT)
|
if constexpr (Pt == BISHOP || Pt == KNIGHT)
|
||||||
{
|
{
|
||||||
// Bonus if the piece is on an outpost square or can reach one
|
// Bonus if the piece is on an outpost square or can reach one
|
||||||
// Bonus for knights (UncontestedOutpost) if few relevant targets
|
// Bonus for knights (UncontestedOutpost) if few relevant targets
|
||||||
|
|||||||
+8
-8
@@ -26,12 +26,12 @@ namespace Stockfish {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<GenType Type, Direction D>
|
template<GenType Type, Direction D>
|
||||||
ExtMove* make_promotions(ExtMove* moveList, Square to) {
|
ExtMove* make_promotions(ExtMove* moveList, [[maybe_unused]] Square to) {
|
||||||
|
|
||||||
if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
if constexpr (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
||||||
*moveList++ = make<PROMOTION>(to - D, to, QUEEN);
|
*moveList++ = make<PROMOTION>(to - D, to, QUEEN);
|
||||||
|
|
||||||
if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
|
if constexpr (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
|
||||||
{
|
{
|
||||||
*moveList++ = make<PROMOTION>(to - D, to, ROOK);
|
*moveList++ = make<PROMOTION>(to - D, to, ROOK);
|
||||||
*moveList++ = make<PROMOTION>(to - D, to, BISHOP);
|
*moveList++ = make<PROMOTION>(to - D, to, BISHOP);
|
||||||
@@ -60,18 +60,18 @@ namespace {
|
|||||||
Bitboard pawnsNotOn7 = pos.pieces(Us, PAWN) & ~TRank7BB;
|
Bitboard pawnsNotOn7 = pos.pieces(Us, PAWN) & ~TRank7BB;
|
||||||
|
|
||||||
// Single and double pawn pushes, no promotions
|
// Single and double pawn pushes, no promotions
|
||||||
if (Type != CAPTURES)
|
if constexpr (Type != CAPTURES)
|
||||||
{
|
{
|
||||||
Bitboard b1 = shift<Up>(pawnsNotOn7) & emptySquares;
|
Bitboard b1 = shift<Up>(pawnsNotOn7) & emptySquares;
|
||||||
Bitboard b2 = shift<Up>(b1 & TRank3BB) & emptySquares;
|
Bitboard b2 = shift<Up>(b1 & TRank3BB) & emptySquares;
|
||||||
|
|
||||||
if (Type == EVASIONS) // Consider only blocking squares
|
if constexpr (Type == EVASIONS) // Consider only blocking squares
|
||||||
{
|
{
|
||||||
b1 &= target;
|
b1 &= target;
|
||||||
b2 &= target;
|
b2 &= target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Type == QUIET_CHECKS)
|
if constexpr (Type == QUIET_CHECKS)
|
||||||
{
|
{
|
||||||
// To make a quiet check, you either make a direct check by pushing a pawn
|
// To make a quiet check, you either make a direct check by pushing a pawn
|
||||||
// or push a blocker pawn that is not on the same file as the enemy king.
|
// or push a blocker pawn that is not on the same file as the enemy king.
|
||||||
@@ -102,7 +102,7 @@ namespace {
|
|||||||
Bitboard b2 = shift<UpLeft >(pawnsOn7) & enemies;
|
Bitboard b2 = shift<UpLeft >(pawnsOn7) & enemies;
|
||||||
Bitboard b3 = shift<Up >(pawnsOn7) & emptySquares;
|
Bitboard b3 = shift<Up >(pawnsOn7) & emptySquares;
|
||||||
|
|
||||||
if (Type == EVASIONS)
|
if constexpr (Type == EVASIONS)
|
||||||
b3 &= target;
|
b3 &= target;
|
||||||
|
|
||||||
while (b1)
|
while (b1)
|
||||||
@@ -116,7 +116,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Standard and en passant captures
|
// Standard and en passant captures
|
||||||
if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
if constexpr (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
|
||||||
{
|
{
|
||||||
Bitboard b1 = shift<UpRight>(pawnsNotOn7) & enemies;
|
Bitboard b1 = shift<UpRight>(pawnsNotOn7) & enemies;
|
||||||
Bitboard b2 = shift<UpLeft >(pawnsNotOn7) & enemies;
|
Bitboard b2 = shift<UpLeft >(pawnsNotOn7) & enemies;
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ Move MovePicker::select(Pred filter) {
|
|||||||
|
|
||||||
while (cur < endMoves)
|
while (cur < endMoves)
|
||||||
{
|
{
|
||||||
if (T == Best)
|
if constexpr (T == Best)
|
||||||
std::swap(*cur, *std::max_element(cur, endMoves));
|
std::swap(*cur, *std::max_element(cur, endMoves));
|
||||||
|
|
||||||
if (*cur != ttMove && filter())
|
if (*cur != ttMove && filter())
|
||||||
|
|||||||
Reference in New Issue
Block a user