]> git.sesse.net Git - stockfish/commitdiff
Remove operators for color
authorprotonspring <mike@whiteley.org>
Tue, 16 Jul 2019 12:08:58 +0000 (06:08 -0600)
committerStéphane Nicolet <cassio@free.fr>
Fri, 26 Jul 2019 00:12:23 +0000 (02:12 +0200)
This is a non-functional and untested simplification. The increment operator
for color isn't really necessary and seems a bit unnatural to me.

Passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 47027 W: 10589 L: 10518 D: 25920
http://tests.stockfishchess.org/tests/view/5d3472d10ebc5925cf0e8d3e

Closes https://github.com/official-stockfish/Stockfish/pull/2247

No functional change

src/bitboard.cpp
src/material.cpp
src/position.cpp
src/syzygy/tbprobe.cpp
src/types.h

index 281579c4a621842e312dfe43f7058e6a55fff34e..2afd3766babf552bfecf9639ae99e3991bc59dbf 100644 (file)
@@ -80,7 +80,7 @@ void Bitboards::init() {
 
   int steps[][5] = { {}, { 7, 9 }, { 6, 10, 15, 17 }, {}, {}, {}, { 1, 7, 8, 9 } };
 
 
   int steps[][5] = { {}, { 7, 9 }, { 6, 10, 15, 17 }, {}, {}, {}, { 1, 7, 8, 9 } };
 
-  for (Color c = WHITE; c <= BLACK; ++c)
+  for (Color c : { WHITE, BLACK })
       for (PieceType pt : { PAWN, KNIGHT, KING })
           for (Square s = SQ_A1; s <= SQ_H8; ++s)
               for (int i = 0; steps[pt][i]; ++i)
       for (PieceType pt : { PAWN, KNIGHT, KING })
           for (Square s = SQ_A1; s <= SQ_H8; ++s)
               for (int i = 0; steps[pt][i]; ++i)
index 3a05f3faf6b374aee5bd72ea221dd12fce3281b4..11d4c687dfe7066ee1abda9b2d933c70f34b24c6 100644 (file)
@@ -140,7 +140,7 @@ Entry* probe(const Position& pos) {
   if ((e->evaluationFunction = Endgames::probe<Value>(key)) != nullptr)
       return e;
 
   if ((e->evaluationFunction = Endgames::probe<Value>(key)) != nullptr)
       return e;
 
-  for (Color c = WHITE; c <= BLACK; ++c)
+  for (Color c : { WHITE, BLACK })
       if (is_KXK(pos, c))
       {
           e->evaluationFunction = &EvaluateKXK[c];
       if (is_KXK(pos, c))
       {
           e->evaluationFunction = &EvaluateKXK[c];
@@ -160,7 +160,7 @@ Entry* probe(const Position& pos) {
   // We didn't find any specialized scaling function, so fall back on generic
   // ones that refer to more than one material distribution. Note that in this
   // case we don't return after setting the function.
   // We didn't find any specialized scaling function, so fall back on generic
   // ones that refer to more than one material distribution. Note that in this
   // case we don't return after setting the function.
-  for (Color c = WHITE; c <= BLACK; ++c)
+  for (Color c : { WHITE, BLACK })
   {
     if (is_KBPsK(pos, c))
         e->scalingFunction[c] = &ScaleKBPsK[c];
   {
     if (is_KBPsK(pos, c))
         e->scalingFunction[c] = &ScaleKBPsK[c];
index 9f06e174e58524535720d4f956058764630235e6..fbde810b503bc26f4574824bb9d4dd3e673236eb 100644 (file)
@@ -1299,8 +1299,8 @@ bool Position::pos_is_ok() const {
               assert(0 && "pos_is_ok: Index");
   }
 
               assert(0 && "pos_is_ok: Index");
   }
 
-  for (Color c = WHITE; c <= BLACK; ++c)
-      for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s + 1))
+  for (Color c : { WHITE, BLACK })
+      for (CastlingSide s : {KING_SIDE, QUEEN_SIDE})
       {
           if (!can_castle(c | s))
               continue;
       {
           if (!can_castle(c | s))
               continue;
index 7864486cb5fbab69a61eb1aec1cd12734adc12c5..90c86388e784534a4a377f7dde6e527f01187b8b 100644 (file)
@@ -367,7 +367,7 @@ TBTable<WDL>::TBTable(const std::string& code) : TBTable() {
     hasPawns = pos.pieces(PAWN);
 
     hasUniquePieces = false;
     hasPawns = pos.pieces(PAWN);
 
     hasUniquePieces = false;
-    for (Color c = WHITE; c <= BLACK; ++c)
+    for (Color c : {WHITE, BLACK})
         for (PieceType pt = PAWN; pt < KING; ++pt)
             if (popcount(pos.pieces(c, pt)) == 1)
                 hasUniquePieces = true;
         for (PieceType pt = PAWN; pt < KING; ++pt)
             if (popcount(pos.pieces(c, pt)) == 1)
                 hasUniquePieces = true;
index b9c01fe700c7b8074cc5ccba2f86269200118f94..b0c333b8eb887ea120a496ec9babd828e4229ade 100644 (file)
@@ -304,7 +304,6 @@ ENABLE_FULL_OPERATORS_ON(Direction)
 
 ENABLE_INCR_OPERATORS_ON(PieceType)
 ENABLE_INCR_OPERATORS_ON(Piece)
 
 ENABLE_INCR_OPERATORS_ON(PieceType)
 ENABLE_INCR_OPERATORS_ON(Piece)
-ENABLE_INCR_OPERATORS_ON(Color)
 ENABLE_INCR_OPERATORS_ON(Square)
 ENABLE_INCR_OPERATORS_ON(File)
 ENABLE_INCR_OPERATORS_ON(Rank)
 ENABLE_INCR_OPERATORS_ON(Square)
 ENABLE_INCR_OPERATORS_ON(File)
 ENABLE_INCR_OPERATORS_ON(Rank)