From: Fabian Fichter Date: Sun, 5 Jan 2020 22:59:03 +0000 (+0100) Subject: Apply promotion limit to piece promotions X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=3b143209c55511523841dc1c15bec23fc5ceb971;p=fairystockfish.git Apply promotion limit to piece promotions Closes #61. --- diff --git a/src/movegen.cpp b/src/movegen.cpp index 422a91c..a12c0c0 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -263,7 +263,8 @@ namespace { // Xiangqi soldier if (pt == SOLDIER && pos.unpromoted_soldier(us, from)) b1 &= file_bb(file_of(from)); - Bitboard b2 = pos.promoted_piece_type(pt) ? b1 : Bitboard(0); + PieceType prom_pt = pos.promoted_piece_type(pt); + Bitboard b2 = prom_pt && (!pos.promotion_limit(prom_pt) || pos.promotion_limit(prom_pt) > pos.count(us, prom_pt)) ? b1 : Bitboard(0); Bitboard b3 = pos.piece_demotion() && pos.is_promoted(from) ? b1 : Bitboard(0); if (Checks) diff --git a/src/variant.h b/src/variant.h index e7f09fd..f1e1c80 100644 --- a/src/variant.h +++ b/src/variant.h @@ -47,7 +47,7 @@ struct Variant { Rank promotionRank = RANK_8; std::set > promotionPieceTypes = { QUEEN, ROOK, BISHOP, KNIGHT }; bool sittuyinPromotion = false; - uint8_t promotionLimit[PIECE_TYPE_NB] = {}; // 0 means unlimited + int promotionLimit[PIECE_TYPE_NB] = {}; // 0 means unlimited PieceType promotedPieceType[PIECE_TYPE_NB] = {}; bool piecePromotionOnCapture = false; bool mandatoryPawnPromotion = true;