Add assertion for the maximum number of pawns
authorDaniel Dugovic <dandydand@gmail.com>
Tue, 21 Mar 2017 07:32:16 +0000 (02:32 -0500)
committerJoona Kiiski <joona@zoox.com>
Mon, 27 Mar 2017 22:55:48 +0000 (15:55 -0700)
No functionl change

Closes #1039

src/material.cpp
src/position.cpp

index 498ef33fe35ee0727e46325da5c769cb609a5aa6..56ad39d3619275b18bf86ee908f97b39ec5ce6ec 100644 (file)
@@ -54,7 +54,7 @@ namespace {
   };
 
   // PawnsSet[count] contains a bonus/malus indexed by number of pawns
-  const int PawnsSet[9] = { 
+  const int PawnsSet[FILE_NB + 1] = {
      24, -32, 107, -51, 117, -9, -126, -21, 31
   };
 
index e20c822f5998902ba2149d13504bd9846a1833d0..7d0cde2146dc29e50a905f0090cf9378b1269943 100644 (file)
@@ -1192,6 +1192,7 @@ bool Position::pos_is_ok(int* failedStep) const {
       }
 
       if (step == Lists)
+      {
           for (Piece pc : Pieces)
           {
               if (pieceCount[pc] != popcount(pieces(color_of(pc), type_of(pc))))
@@ -1201,6 +1202,9 @@ bool Position::pos_is_ok(int* failedStep) const {
                   if (board[pieceList[pc][i]] != pc || index[pieceList[pc][i]] != i)
                       return false;
           }
+          if (pieceCount[PAWN] > FILE_NB)
+              return false;
+      }
 
       if (step == Castling)
           for (Color c = WHITE; c <= BLACK; ++c)