simplify promotion generation

This commit is contained in:
2024-07-02 17:28:35 +02:00
parent 44f604abac
commit 902c224aa9
2 changed files with 6 additions and 5 deletions

View File

@@ -259,8 +259,9 @@ static inline __unused move_t *gen_pseudo_king(move_t *moves, square_t from,
* *
* @Return: New @moves. * @Return: New @moves.
*/ */
static inline __unused move_t *moves_gen_flags(move_t *moves, square_t from, bitboard_t to_bb, static inline __unused move_t *moves_gen_flags(move_t *moves, square_t from,
__unused move_flags_t flags) bitboard_t to_bb,
__unused move_flags_t flags)
{ {
square_t to; square_t to;
while(to_bb) { while(to_bb) {
@@ -285,7 +286,8 @@ static inline __unused move_t *moves_gen_flags(move_t *moves, square_t from, bit
*/ */
static inline move_t *move_gen_promotions(move_t *moves, square_t from, square_t to) static inline move_t *move_gen_promotions(move_t *moves, square_t from, square_t to)
{ {
for (piece_type_t pt = QUEEN; pt >= KNIGHT; --pt) /* your attention: "downto operator" */
for (piece_type_t pt = QUEEN - 1; pt --> KNIGHT - 2;)
*moves++ = move_make_promote(from, to, pt); *moves++ = move_make_promote(from, to, pt);
return moves; return moves;
} }

View File

@@ -119,8 +119,7 @@ static inline move_t move_make_enpassant(square_t from, square_t to)
static inline move_t move_make_promote(square_t from, square_t to, static inline move_t move_make_promote(square_t from, square_t to,
piece_type_t promoted) piece_type_t promoted)
{ {
return move_make_flags(from, to, M_PROMOTION) | return move_make_flags(from, to, M_PROMOTION) | (promoted << M_OFF_PROMOTED);
((promoted - KNIGHT) << M_OFF_PROMOTED);
} }
/* /*