simplify promotion generation
This commit is contained in:
@@ -259,8 +259,9 @@ static inline __unused move_t *gen_pseudo_king(move_t *moves, square_t from,
|
||||
*
|
||||
* @Return: New @moves.
|
||||
*/
|
||||
static inline __unused move_t *moves_gen_flags(move_t *moves, square_t from, bitboard_t to_bb,
|
||||
__unused move_flags_t flags)
|
||||
static inline __unused move_t *moves_gen_flags(move_t *moves, square_t from,
|
||||
bitboard_t to_bb,
|
||||
__unused move_flags_t flags)
|
||||
{
|
||||
square_t to;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
return moves;
|
||||
}
|
||||
|
@@ -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,
|
||||
piece_type_t promoted)
|
||||
{
|
||||
return move_make_flags(from, to, M_PROMOTION) |
|
||||
((promoted - KNIGHT) << M_OFF_PROMOTED);
|
||||
return move_make_flags(from, to, M_PROMOTION) | (promoted << M_OFF_PROMOTED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user