2121 * @return Number of moves matching the predicate.
2222 */
2323template <typename Pred>
24- int count_if (const std::vector<Move>& moves, Pred pred) {
25- return std::count_if (moves.begin (), moves.end (), pred);
24+ std:: size_t count_if (const std::vector<Move>& moves, Pred pred) {
25+ return static_cast < std::size_t >( std:: count_if (moves.begin (), moves.end (), pred) );
2626}
2727
2828/* *
@@ -95,78 +95,78 @@ bool has_valid_move_flags(const std::vector<Move>& moves) {
9595/* *
9696 * @brief Counts moves originating from a given square.
9797 */
98- int count_moves_from (const std::vector<Move>& moves, Square from) {
98+ std:: size_t count_moves_from (const std::vector<Move>& moves, Square from) {
9999 return count_if (moves, [&](const Move& m) { return m.from == from; });
100100}
101101
102102/* *
103103 * @brief Counts moves targeting a given square.
104104 */
105- int count_moves_to (const std::vector<Move>& moves, Square to) {
105+ std:: size_t count_moves_to (const std::vector<Move>& moves, Square to) {
106106 return count_if (moves, [&](const Move& m) { return m.to == to; });
107107}
108108
109109/* *
110110 * @brief Counts all capture moves (including en passant).
111111 */
112- int count_captures (const std::vector<Move>& moves) {
112+ std:: size_t count_captures (const std::vector<Move>& moves) {
113113 return count_if (moves, [](const Move& m) { return m.is_capture ; });
114114}
115115
116116/* *
117117 * @brief Counts normal captures (excluding en passant).
118118 */
119- int count_regular_captures (const std::vector<Move>& moves) {
119+ std:: size_t count_regular_captures (const std::vector<Move>& moves) {
120120 return count_if (moves, [](const Move& m) { return m.is_capture && !m.is_en_passant ; });
121121}
122122
123123/* *
124124 * @brief Counts en passant captures.
125125 */
126- int count_en_passant (const std::vector<Move>& moves) {
126+ std:: size_t count_en_passant (const std::vector<Move>& moves) {
127127 return count_if (moves, [](const Move& m) { return m.is_en_passant ; });
128128}
129129
130130/* *
131131 * @brief Counts all castling moves.
132132 */
133- int count_castling (const std::vector<Move>& moves) {
133+ std:: size_t count_castling (const std::vector<Move>& moves) {
134134 return count_if (moves, [](const Move& m) { return m.is_castling ; });
135135}
136136
137137/* *
138138 * @brief Counts promotions of any type.
139139 */
140- int count_promotions (const std::vector<Move>& moves) {
140+ std:: size_t count_promotions (const std::vector<Move>& moves) {
141141 return count_if (moves, [](const Move& m) { return m.promotion .has_value (); });
142142}
143143
144144/* *
145145 * @brief Counts promotions to a specific piece type.
146146 * @param piece Piece type and color to match.
147147 */
148- int count_promotions_to (const std::vector<Move>& moves, const Piece& piece) {
148+ std:: size_t count_promotions_to (const std::vector<Move>& moves, const Piece& piece) {
149149 return count_if (moves, [&](const Move& m) { return m.promotion .has_value () && m.promotion .value () == piece; });
150150}
151151
152152/* *
153153 * @brief Counts promotions that also capture.
154154 */
155- int count_promotion_captures (const std::vector<Move>& moves) {
155+ std:: size_t count_promotion_captures (const std::vector<Move>& moves) {
156156 return count_if (moves, [](const Move& m) { return m.promotion .has_value () && m.is_capture ; });
157157}
158158
159159/* *
160160 * @brief Counts promotions that are not captures.
161161 */
162- int count_quiet_promotions (const std::vector<Move>& moves) {
162+ std:: size_t count_quiet_promotions (const std::vector<Move>& moves) {
163163 return count_if (moves, [](const Move& m) { return m.promotion .has_value () && !m.is_capture ; });
164164}
165165
166166/* *
167167 * @brief Counts quiet moves (non-capture, non-promotion, non-castling).
168168 */
169- int count_quiet_moves (const std::vector<Move>& moves) {
169+ std:: size_t count_quiet_moves (const std::vector<Move>& moves) {
170170 return count_if (moves, [](const Move& m) {
171171 return !m.is_capture && !m.is_castling && !m.is_en_passant && !m.promotion .has_value ();
172172 });
@@ -175,7 +175,7 @@ int count_quiet_moves(const std::vector<Move>& moves) {
175175/* *
176176 * @brief Counts kingside castling moves for the king for the given side.
177177 */
178- int count_king_kingside_castling (const std::vector<Move>& moves, Color side) {
178+ std:: size_t count_king_kingside_castling (const std::vector<Move>& moves, Color side) {
179179 Square from = (side == Color::WHITE) ? Squares::E1 : Squares::E8 ;
180180 Square target = (side == Color::WHITE) ? Squares::G1 : Squares::G8;
181181 return count_if (moves, [&](const Move& m) { return m.is_castling && m.to == target && m.from == from; });
@@ -184,7 +184,7 @@ int count_king_kingside_castling(const std::vector<Move>& moves, Color side) {
184184/* *
185185 * @brief Counts queenside castling moves for the king for the given side.
186186 */
187- int count_king_queenside_castling (const std::vector<Move>& moves, Color side) {
187+ std:: size_t count_king_queenside_castling (const std::vector<Move>& moves, Color side) {
188188 Square from = (side == Color::WHITE) ? Squares::E1 : Squares::E8 ;
189189 Square target = (side == Color::WHITE) ? Squares::C1 : Squares::C8;
190190 return count_if (moves, [&](const Move& m) { return m.is_castling && m.to == target && m.from == from; });
@@ -193,7 +193,7 @@ int count_king_queenside_castling(const std::vector<Move>& moves, Color side) {
193193/* *
194194 * @brief Counts kingside castling moves for the rook for the given side.
195195 */
196- int count_rook_kingside_castling (const std::vector<Move>& moves, Color side) {
196+ std:: size_t count_rook_kingside_castling (const std::vector<Move>& moves, Color side) {
197197 Square from = (side == Color::WHITE) ? Squares::H1 : Squares::H8;
198198 Square target = (side == Color::WHITE) ? Squares::F1 : Squares::F8;
199199 return count_if (moves, [&](const Move& m) { return m.is_castling && m.to == target && m.from == from; });
@@ -202,7 +202,7 @@ int count_rook_kingside_castling(const std::vector<Move>& moves, Color side) {
202202/* *
203203 * @brief Counts queenside castling moves for the rook for the given side.
204204 */
205- int count_rook_queenside_castling (const std::vector<Move>& moves, Color side) {
205+ std:: size_t count_rook_queenside_castling (const std::vector<Move>& moves, Color side) {
206206 Square from = (side == Color::WHITE) ? Squares::A1 : Squares::A8;
207207 Square target = (side == Color::WHITE) ? Squares::D1 : Squares::D8;
208208 return count_if (moves, [&](const Move& m) { return m.is_castling && m.to == target && m.from == from; });
0 commit comments