From 06eba14dc984dc793e959ff7a5de19e1a190112b Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Tue, 21 Mar 2017 02:32:16 -0500 Subject: [PATCH] Add assertion for the maximum number of pawns No functionl change Closes #1039 --- src/material.cpp | 2 +- src/position.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/material.cpp b/src/material.cpp index 498ef33f..56ad39d3 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -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 }; diff --git a/src/position.cpp b/src/position.cpp index e20c822f..7d0cde21 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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) -- 2.39.2