From b1f5e64810114527c3dbf4c057b488d9c18de8cf Mon Sep 17 00:00:00 2001 From: Heiaha Date: Mon, 20 Jun 2022 18:49:23 -0400 Subject: [PATCH] fix move generation bug with a checking knight on the last rank captured by a pawn --- src/position.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/position.h b/src/position.h index cd43bfd..335ca9e 100644 --- a/src/position.h +++ b/src/position.h @@ -467,8 +467,16 @@ Move* Position::generate_legals(Move* list) { //If the checker is either a pawn or a knight, the only legal moves are to capture //the checker. Only non-pinned pieces can capture it b1 = attackers_from(checker_square, all) & not_pinned; - while (b1) *list++ = Move(pop_lsb(&b1), checker_square, CAPTURE); - + while (b1) { + s = pop_lsb(&b1); + if (type_of(board[s]) == PAWN && rank_of(s) == relative_rank(RANK7)) { + *list++ = Move(s, checker_square, PC_QUEEN); + *list++ = Move(s, checker_square, PC_ROOK); + *list++ = Move(s, checker_square, PC_BISHOP); + *list++ = Move(s, checker_square, PC_KNIGHT); + } + else *list++ = Move(s, checker_square, CAPTURE); + } return list; default: //We must capture the checking piece