mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Use std::count in pos_is_ok()
No functional change.
This commit is contained in:
parent
c40d4e0133
commit
cc3002ff04
1 changed files with 3 additions and 12 deletions
|
@ -1263,9 +1263,7 @@ bool Position::pos_is_ok(int* failedStep) const {
|
||||||
const bool debugPieceList = all || false;
|
const bool debugPieceList = all || false;
|
||||||
const bool debugCastlingSquares = all || false;
|
const bool debugCastlingSquares = all || false;
|
||||||
|
|
||||||
*step = 1;
|
if (*step = 1, sideToMove != WHITE && sideToMove != BLACK)
|
||||||
|
|
||||||
if (sideToMove != WHITE && sideToMove != BLACK)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((*step)++, piece_on(king_square(WHITE)) != W_KING)
|
if ((*step)++, piece_on(king_square(WHITE)) != W_KING)
|
||||||
|
@ -1275,16 +1273,9 @@ bool Position::pos_is_ok(int* failedStep) const {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((*step)++, debugKingCount)
|
if ((*step)++, debugKingCount)
|
||||||
{
|
if ( std::count(board, board + SQUARE_NB, W_KING) != 1
|
||||||
int kingCount[COLOR_NB] = {};
|
|| std::count(board, board + SQUARE_NB, B_KING) != 1)
|
||||||
|
|
||||||
for (Square s = SQ_A1; s <= SQ_H8; ++s)
|
|
||||||
if (type_of(piece_on(s)) == KING)
|
|
||||||
++kingCount[color_of(piece_on(s))];
|
|
||||||
|
|
||||||
if (kingCount[0] != 1 || kingCount[1] != 1)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if ((*step)++, debugKingCapture)
|
if ((*step)++, debugKingCapture)
|
||||||
if (attackers_to(king_square(~sideToMove)) & pieces(sideToMove))
|
if (attackers_to(king_square(~sideToMove)) & pieces(sideToMove))
|
||||||
|
|
Loading…
Add table
Reference in a new issue