From: Fabian Fichter Date: Fri, 14 Apr 2023 16:57:34 +0000 (+0200) Subject: Ensure stable count for nnueKing X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6897c7475210798967f62441e0e819bd9e1bfedc;p=fairystockfish.git Ensure stable count for nnueKing --- diff --git a/src/variant.h b/src/variant.h index a6dbee5..085e9b4 100644 --- a/src/variant.h +++ b/src/variant.h @@ -241,6 +241,15 @@ struct Variant { nnueKing = pieceTypes & KING ? KING : extinctionPieceCount == 0 && (extinctionPieceTypes & COMMONER) ? COMMONER : NO_PIECE_TYPE; + // The nnueKing has to present exactly once and must not change in count + if (nnueKing != NO_PIECE_TYPE) + { + // If the nnueKing is involved in promotion, count might change + if ( ((promotionPawnTypes[WHITE] | promotionPawnTypes[BLACK]) & nnueKing) + || ((promotionPieceTypes[WHITE] | promotionPieceTypes[BLACK]) & nnueKing) + || std::find(std::begin(promotedPieceType), std::end(promotedPieceType), nnueKing) != std::end(promotedPieceType)) + nnueKing = NO_PIECE_TYPE; + } if (nnueKing != NO_PIECE_TYPE) { std::string fenBoard = startFen.substr(0, startFen.find(' '));